diff --git a/pos_return_barcode/__manifest__.py b/pos_return_barcode/__manifest__.py index 50bed3a02..c9b91068b 100644 --- a/pos_return_barcode/__manifest__.py +++ b/pos_return_barcode/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################### { 'name': 'POS Return Barcode', - 'version': '17.0.1.0.0', + 'version': '17.0.1.0.1', 'summary': """This module in Odoo 17 allows to return product effortless via receipt barcode scanning.""", 'description': """The POS Return Barcode module in Odoo 17 streamlines the @@ -42,6 +42,7 @@ 'pos_return_barcode/static/src/js/return_product.js', 'pos_return_barcode/static/src/js/order.js', 'pos_return_barcode/static/src/js/barcode_popup.js', + 'pos_return_barcode/static/src/js/ticket_screen.js', 'pos_return_barcode/static/src/xml/return_product_template.xml', 'pos_return_barcode/static/src/xml/barcode_popup.xml', 'pos_return_barcode/static/src/xml/order_receipt.xml', diff --git a/pos_return_barcode/doc/RELEASE_NOTES.md b/pos_return_barcode/doc/RELEASE_NOTES.md index ecdf42c5b..6f26f25f5 100644 --- a/pos_return_barcode/doc/RELEASE_NOTES.md +++ b/pos_return_barcode/doc/RELEASE_NOTES.md @@ -1,6 +1,12 @@ -## Module +## Module #### 21.03.2024 #### Version 17.0.1.0.0 #### ADD - Initial commit for POS Return Barcode + + +#### 03.09.2024 +#### Version 17.0.1.0.0 +#### Bug Fix +- Updated the working that is patched ticket_screen and made changes in onClick() of return_product js \ No newline at end of file diff --git a/pos_return_barcode/models/pos_order.py b/pos_return_barcode/models/pos_order.py index 38b9f8b2e..e89d6c15d 100644 --- a/pos_return_barcode/models/pos_order.py +++ b/pos_return_barcode/models/pos_order.py @@ -46,9 +46,7 @@ class PosOrder(models.Model): order = self.env['pos.order'].search([('barcode', '=', barcode), ('is_return', '=', False)]) if order and order.is_refunded is False: - order.refund() - return True - return False + return order.id def _prepare_refund_values(self, current_session): """override this function to pass that the order is return """ diff --git a/pos_return_barcode/static/src/js/order.js b/pos_return_barcode/static/src/js/order.js index 3d373ee33..dcb08f2e9 100644 --- a/pos_return_barcode/static/src/js/order.js +++ b/pos_return_barcode/static/src/js/order.js @@ -2,6 +2,7 @@ //Patched order to fetch barcode number and to search for the order related to barcode import { patch } from "@web/core/utils/patch"; import { Order } from "@point_of_sale/app/store/models"; +import { _t } from "@web/core/l10n/translation"; patch(Order.prototype, { setup(_defaultObj, options) { @@ -9,11 +10,11 @@ patch(Order.prototype, { this.barcode_reader = this.barcode_reader || null; this.orm = options.pos.orm; this.is_barcode = false - this.barcode = null + let barcode = _t("%s", this.uid); + this.barcode =barcode.replace(/-/g, "") }, - set_barcode_reader(barcode_reader) { - this.comment_feedback = barcode_reader.Value; + this.barcode_reader = barcode_reader.Value; }, get_barcode_reader() { return this.barcode_reader; diff --git a/pos_return_barcode/static/src/js/return_product.js b/pos_return_barcode/static/src/js/return_product.js index 89eb66f40..8c3b1c560 100644 --- a/pos_return_barcode/static/src/js/return_product.js +++ b/pos_return_barcode/static/src/js/return_product.js @@ -6,6 +6,7 @@ import { useService } from "@web/core/utils/hooks"; import { Component } from "@odoo/owl"; import BarcodePopup from "@pos_return_barcode/js/barcode_popup" import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup"; + export class ReturnProductButton extends Component { static template = "point_of_sale.ReturnProduct"; setup() { @@ -28,16 +29,23 @@ export class ReturnProductButton extends Component { var self = this this.pos.receipt_barcode_reader = inputbarcode; let barcode = inputbarcode.barcodeValue.toString().replace(/\n/g, ""); - await this.orm.call("pos.order", "action_barcode_return", ["", barcode]).then(function(result){ - if(result == false) + + let result = await this.orm.call("pos.order", "action_barcode_return", ["", barcode]) + if (!result) { self.popup.add(ErrorPopup, { title: _t("Order not found"), body: _t("Invalid data , Order could not be found"), }); } - window.location.reload(); - }) + const ui = { + searchDetails: { + fieldName: "BARCODE", + searchTerm: barcode, + }, + filter: "SYNCED", + }; + this.pos.showScreen("TicketScreen", { ui }); } } } diff --git a/pos_return_barcode/static/src/js/ticket_screen.js b/pos_return_barcode/static/src/js/ticket_screen.js new file mode 100644 index 000000000..9426a1691 --- /dev/null +++ b/pos_return_barcode/static/src/js/ticket_screen.js @@ -0,0 +1,15 @@ +/** @odoo-module **/ +import { TicketScreen } from "@point_of_sale/app/screens/ticket_screen/ticket_screen"; +import { patch } from "@web/core/utils/patch"; +import { _t } from "@web/core/l10n/translation"; +patch(TicketScreen.prototype, { + _getSearchFields() { + return Object.assign({}, super._getSearchFields(...arguments), { + BARCODE: { + repr: (order) => order.barcode, + displayName: _t("Barcode"), + modelField: "barcode", + }, + }); + } +})