From 0556bc6d9e780e1d7100dc3f85d3fc4eee18502f Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Mon, 30 Jan 2017 14:42:20 -0800 Subject: [PATCH] [FIX] point_of_sale: properly round taxes with round_globally When tax_calculation_rounding_method is configured to round_globally the compute_all method of account.tax will not round the taxes based on the currency. The result of the compute_all function is used when creating the tax parts of a pos.order account.move. Taxes are aggregated per session, so 2 orders with orderlines in them with the same tax will turn into 1 single tax account.move.line. To correctly handle round_globally, we round all tax values we have after processing each order. Fixes #14672 Fixes #14673 --- addons/point_of_sale/point_of_sale.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 86a2764a005..3380208b484 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -1295,6 +1295,7 @@ class pos_order(osv.osv): grouped_data = {} have_to_group_by = session and session.config_id.group_by or False + rounding_method = session and session.config_id.company_id.tax_calculation_rounding_method for order in self.browse(cr, uid, ids, context=context): if order.account_move: @@ -1420,6 +1421,14 @@ class pos_order(osv.osv): 'partner_id': order.partner_id and self.pool.get("res.partner")._find_accounting_partner(order.partner_id).id or False }) + # round tax lines per order + if rounding_method == 'round_globally': + for group_key, group_value in grouped_data.iteritems(): + if group_key[0] == 'tax': + for line in group_value: + line['credit'] = cur.round(line['credit']) + line['debit'] = cur.round(line['debit']) + # counterpart insert_data('counter_part', { 'name': _("Trade Receivables"), #order.name,