diff --git a/pos_order_mgmt/__manifest__.py b/pos_order_mgmt/__manifest__.py index 8ee74902..d90bc1c6 100644 --- a/pos_order_mgmt/__manifest__.py +++ b/pos_order_mgmt/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'POS Frontend Orders Management', 'summary': 'Manage old POS Orders from the frontend', - 'version': '11.0.1.0.0', + 'version': '11.0.1.0.1', 'category': 'Point of Sale', 'author': 'GRAP, ' 'Tecnativa, ' diff --git a/pos_order_mgmt/static/src/js/models.js b/pos_order_mgmt/static/src/js/models.js index b76d7740..0a6c4bb3 100644 --- a/pos_order_mgmt/static/src/js/models.js +++ b/pos_order_mgmt/static/src/js/models.js @@ -12,7 +12,7 @@ odoo.define('pos_order_mgmt.models', function (require) { if (arguments.length && arguments[0] && arguments[0].uid) { var order = this.db.get_order(arguments[0].uid); if (order && order.data) { - var data = Object.assign({}, order.data); + var data = _.extend({}, order.data); var partner = this.db.get_partner_by_id(data.partner_id); if (partner && partner.id && partner.name) { data.partner_id = [partner.id, partner.name]; diff --git a/pos_order_mgmt/static/src/js/widgets.js b/pos_order_mgmt/static/src/js/widgets.js index 0c55b24b..369a1799 100644 --- a/pos_order_mgmt/static/src/js/widgets.js +++ b/pos_order_mgmt/static/src/js/widgets.js @@ -37,6 +37,13 @@ odoo.define('pos_order_mgmt.widgets', function (require) { return this._super(); } this.pos.from_loaded_order = false; + // When reprinting a loaded order we temporarily set it as the + // active one. When we get out from the printing screen, we set + // it back to the one that was active + if (this.pos.current_order) { + this.pos.set_order(this.pos.current_order); + this.pos.current_order = false; + } return this.gui.show_screen(this.gui.startup_screen); }, }); @@ -145,6 +152,10 @@ odoo.define('pos_order_mgmt.widgets', function (require) { action_print: function (order) { var receipt = order.export_for_printing(); + // We store temporarily the current order so we can safely compute + // taxes based on fiscal position + this.pos.current_order = this.pos.get_order() + this.pos.set_order(order); if (this.pos.config.iface_print_via_proxy) { this.pos.proxy.print_receipt(QWeb.render( 'XmlReceipt', { @@ -155,6 +166,8 @@ odoo.define('pos_order_mgmt.widgets', function (require) { orderlines: order.get_orderlines(), paymentlines: order.get_paymentlines(), })); + this.pos.set_order(this.pos.current_order); + this.pos.current_order = false; } else { this.pos.reloaded_order = order; this.gui.show_screen('receipt'); @@ -182,6 +195,14 @@ odoo.define('pos_order_mgmt.widgets', function (require) { order_data.partner_id = order_data.partner_id[0]; } order.set_client(this.pos.db.get_partner_by_id(order_data.partner_id)); + // Set fiscal position + if (order_data.fiscal_position && this.pos.fiscal_positions) { + var fiscal_positions = this.pos.fiscal_positions; + order.fiscal_position = fiscal_positions.filter(function (p) { + return p.id === order_data.fiscal_position; + })[0]; + order.trigger('change'); + } // Set order lines var orderLines = order_data.line_ids || order_data.lines || []; _.each(orderLines, function (orderLine) { @@ -204,17 +225,6 @@ odoo.define('pos_order_mgmt.widgets', function (require) { }); } }); - // Set fiscal position - if (order_data.fiscal_position && this.pos.fiscal_positions) { - var fiscal_positions = this.pos.fiscal_positions; - order.fiscal_position = fiscal_positions.filter(function (p) { - return p.id === order_data.fiscal_position; - })[0]; - _.each(order.orderlines.models, function (line) { - line.set_quantity(line.quantity); - }); - order.trigger('change'); - } if (order_data.return) { order.return = true; // A credit note should be emited if there was an invoice