[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
This commit is contained in:
Joren Van Onder
2017-02-08 10:28:33 -08:00
parent 00cf180862
commit 0556bc6d9e
+9
View File
@@ -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,