From ed2badcd7248a946ccac7a0810f93c612f7ce166 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 23 May 2016 11:50:01 +0200 Subject: [PATCH] [FIX] account: sort taxes In the case of grouped taxes, the taxes would not be applied anymore after commit 0a5b943d19129545724488f6026632bacd66a97b opw-678158 opw-678219 --- addons/account/models/account.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 3e98bdf40d7..d6161126dfd 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -639,7 +639,11 @@ class AccountTax(models.Model): prec += 5 total_excluded = total_included = base = round(price_unit * quantity, prec) - for tax in self.sorted(): + # Sorting key is mandatory in this case. When no key is provided, sorted() will perform a + # search. However, the search method is overridden in account.tax in order to add a domain + # depending on the context. This domain might filter out some taxes from self, e.g. in the + # case of group taxes. + for tax in self.sorted(key=lambda r: r.sequence): if tax.amount_type == 'group': ret = tax.children_tax_ids.compute_all(price_unit, currency, quantity, product, partner) total_excluded = ret['total_excluded']