From c1276c154eae4d6f29d692d75b31d8045d04278d Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 14 Feb 2018 17:47:23 +0100 Subject: [PATCH] [FIX] point_of_sale: flattening only group of taxes when creating amls Revision 89c63096cb95f10f8bb3770e10d330aa904ac159 fixed the creation of the taxes applied to account move lines when validating a pos session The fix though overlooked two things: - protection against recursivity (nothing prevents a group of taxes to have a grand-parent as one of its children) - the fact that when converting a group of taxes into a regular computed one, the field children_ids is never reset Those two caveats provoked a "max recursivity error" in python within the right conditions This commit protects the recursive process from the two issues, and there is no traceback OPW 816163 --- addons/point_of_sale/models/pos_order.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 9ac6ed90ea8..13f6b90d706 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -197,10 +197,14 @@ class PosOrder(models.Model): return InvoiceLine.sudo().create(inv_line) def _create_account_move_line(self, session=None, move=None): - def _flatten_tax_and_children(taxes): + def _flatten_tax_and_children(taxes, group_done=None): children = self.env['account.tax'] - for tax in taxes: - children |= _flatten_tax_and_children(tax.children_tax_ids) + if group_done is None: + group_done = set() + for tax in taxes.filtered(lambda t: t.amount_type == 'group'): + if tax.id not in group_done: + group_done.add(tax.id) + children |= _flatten_tax_and_children(tax.children_tax_ids, group_done) return taxes + children # Tricky, via the workflow, we only have one id in the ids variable