diff --git a/addons/point_of_sale/models/account_tax.py b/addons/point_of_sale/models/account_tax.py index 48a7ecbe0c6..37cf71324e1 100644 --- a/addons/point_of_sale/models/account_tax.py +++ b/addons/point_of_sale/models/account_tax.py @@ -25,3 +25,12 @@ class AccountTax(models.Model): 'You must close the POS sessions before modifying the tax.' )) return super(AccountTax, self).write(vals) + + def get_real_tax_amount(self): + tax_list = [] + for tax in self: + tax_repartition_lines = tax.invoice_repartition_line_ids.filtered(lambda x: x.repartition_type == 'tax') + total_factor = sum(tax_repartition_lines.mapped('factor')) + real_amount = tax.amount * total_factor + tax_list.append({'id': tax.id, 'amount': real_amount}) + return tax_list diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index fbeddf38ed5..5e681776730 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -242,6 +242,19 @@ exports.PosModel = Backbone.Model.extend({ return self.taxes_by_id[child_tax_id]; }); }); + return new Promise(function (resolve, reject) { + var tax_ids = _.pluck(self.taxes, 'id'); + rpc.query({ + model: 'account.tax', + method: 'get_real_tax_amount', + args: [tax_ids], + }).then(function (taxes) { + _.each(taxes, function (tax) { + self.taxes_by_id[tax.id].amount = tax.amount; + resolve(); + }); + }); + }); }, },{ model: 'pos.session',