Browse Source

Sep 04: [FIX] Bug Fixed 'pos_return_barcode'

pull/331/head
Cybrosys Technologies 8 months ago
parent
commit
8ef80f1bd8
  1. 3
      pos_return_barcode/__manifest__.py
  2. 8
      pos_return_barcode/doc/RELEASE_NOTES.md
  3. 4
      pos_return_barcode/models/pos_order.py
  4. 7
      pos_return_barcode/static/src/js/order.js
  5. 16
      pos_return_barcode/static/src/js/return_product.js
  6. 15
      pos_return_barcode/static/src/js/ticket_screen.js

3
pos_return_barcode/__manifest__.py

@ -21,7 +21,7 @@
############################################################################### ###############################################################################
{ {
'name': 'POS Return Barcode', '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 'summary': """This module in Odoo 17 allows to return product effortless
via receipt barcode scanning.""", via receipt barcode scanning.""",
'description': """The POS Return Barcode module in Odoo 17 streamlines the '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/return_product.js',
'pos_return_barcode/static/src/js/order.js', 'pos_return_barcode/static/src/js/order.js',
'pos_return_barcode/static/src/js/barcode_popup.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/return_product_template.xml',
'pos_return_barcode/static/src/xml/barcode_popup.xml', 'pos_return_barcode/static/src/xml/barcode_popup.xml',
'pos_return_barcode/static/src/xml/order_receipt.xml', 'pos_return_barcode/static/src/xml/order_receipt.xml',

8
pos_return_barcode/doc/RELEASE_NOTES.md

@ -1,6 +1,12 @@
## Module <pos_refund_password> ## Module <pos_return_barcode>
#### 21.03.2024 #### 21.03.2024
#### Version 17.0.1.0.0 #### Version 17.0.1.0.0
#### ADD #### ADD
- Initial commit for POS Return Barcode - 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

4
pos_return_barcode/models/pos_order.py

@ -46,9 +46,7 @@ class PosOrder(models.Model):
order = self.env['pos.order'].search([('barcode', '=', barcode), order = self.env['pos.order'].search([('barcode', '=', barcode),
('is_return', '=', False)]) ('is_return', '=', False)])
if order and order.is_refunded is False: if order and order.is_refunded is False:
order.refund() return order.id
return True
return False
def _prepare_refund_values(self, current_session): def _prepare_refund_values(self, current_session):
"""override this function to pass that the order is return """ """override this function to pass that the order is return """

7
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 //Patched order to fetch barcode number and to search for the order related to barcode
import { patch } from "@web/core/utils/patch"; import { patch } from "@web/core/utils/patch";
import { Order } from "@point_of_sale/app/store/models"; import { Order } from "@point_of_sale/app/store/models";
import { _t } from "@web/core/l10n/translation";
patch(Order.prototype, { patch(Order.prototype, {
setup(_defaultObj, options) { setup(_defaultObj, options) {
@ -9,11 +10,11 @@ patch(Order.prototype, {
this.barcode_reader = this.barcode_reader || null; this.barcode_reader = this.barcode_reader || null;
this.orm = options.pos.orm; this.orm = options.pos.orm;
this.is_barcode = false this.is_barcode = false
this.barcode = null let barcode = _t("%s", this.uid);
this.barcode =barcode.replace(/-/g, "")
}, },
set_barcode_reader(barcode_reader) { set_barcode_reader(barcode_reader) {
this.comment_feedback = barcode_reader.Value; this.barcode_reader = barcode_reader.Value;
}, },
get_barcode_reader() { get_barcode_reader() {
return this.barcode_reader; return this.barcode_reader;

16
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 { Component } from "@odoo/owl";
import BarcodePopup from "@pos_return_barcode/js/barcode_popup" import BarcodePopup from "@pos_return_barcode/js/barcode_popup"
import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup"; import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup";
export class ReturnProductButton extends Component { export class ReturnProductButton extends Component {
static template = "point_of_sale.ReturnProduct"; static template = "point_of_sale.ReturnProduct";
setup() { setup() {
@ -28,16 +29,23 @@ export class ReturnProductButton extends Component {
var self = this var self = this
this.pos.receipt_barcode_reader = inputbarcode; this.pos.receipt_barcode_reader = inputbarcode;
let barcode = inputbarcode.barcodeValue.toString().replace(/\n/g, ""); 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, { self.popup.add(ErrorPopup, {
title: _t("Order not found"), title: _t("Order not found"),
body: _t("Invalid data , Order could not be 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 });
} }
} }
} }

15
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",
},
});
}
})
Loading…
Cancel
Save