Browse Source

[FIX] pos_order_mgmt: reprint tickets with fp

When the PoS is using fiscal positions it can lead to errors when
computing the reprinted ticket value because the tax mapping function
computes them from the current order instead of from the one belonging
to the line. So we set our loaded order temporarily as the selected one
just to bring it back to the current one after it's printed.
pull/378/head
David 5 years ago
committed by OCA-git-bot
parent
commit
0d4b99f485
  1. 2
      pos_order_mgmt/__manifest__.py
  2. 2
      pos_order_mgmt/static/src/js/models.js
  3. 32
      pos_order_mgmt/static/src/js/widgets.js

2
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, '

2
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];

32
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

Loading…
Cancel
Save