From 1b714bdc6ce75f856509548f2190d4e643186d58 Mon Sep 17 00:00:00 2001 From: Darshan Kalola Date: Fri, 18 Sep 2015 12:14:30 +0530 Subject: [PATCH] [FIX] point_of_sale: fix 'Group of Taxes' calculation There were still references in the POS to a child_ids field on account.tax. This field was renamed in accounting v9 to children_tax_ids. Because child_ids wasn't loaded anymore this meant that child_ids on the taxes in the POS was always undefined. On top of that the original code used Array.prototype.concat() assuming it modified the array, when in fact it returns a new array. All of this meant that group taxes in the POS were never calculated, this resolves that. --- addons/point_of_sale/static/src/js/models.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 8bac3a12519..3f892bb9b53 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -201,7 +201,7 @@ exports.PosModel = Backbone.Model.extend({ }, },{ model: 'account.tax', - fields: ['name','amount', 'price_include', 'include_base_amount', 'amount_type'], + fields: ['name','amount', 'price_include', 'include_base_amount', 'amount_type', 'children_tax_ids'], domain: null, loaded: function(self, taxes){ self.taxes = taxes; @@ -210,9 +210,8 @@ exports.PosModel = Backbone.Model.extend({ self.taxes_by_id[tax.id] = tax; }); _.each(self.taxes_by_id, function(tax) { - tax.child_taxes = {}; - _.each(tax.child_ids, function(child_tax_id) { - tax.child_taxes[child_tax_id] = self.taxes_by_id[child_tax_id]; + tax.children_tax_ids = _.map(tax.children_tax_ids, function (child_tax_id) { + return self.taxes_by_id[child_tax_id]; }); }); }, @@ -1351,7 +1350,7 @@ exports.Orderline = Backbone.Model.extend({ total_excluded = ret.total_excluded; base = ret.total_excluded; total_included = ret.total_included; - list_taxes.concat(ret.taxes); + list_taxes = list_taxes.concat(ret.taxes); } else { var tax_amount = self._compute_all(tax, base, quantity);