From d117bad18cd26d4dc575b703cffba49d728d60df Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 3 Feb 2015 17:08:45 +0100 Subject: [PATCH] [FIX] point_of_sale: invalid tax amount on grouped entries If "Group Journal Items" option is checked, the generated accounting entries may get an invalid tax amout. This will happen when several entries for the same product do not use the same tax amout (e.g. discount). Avoid grouping products with different taxes under the same line by creating one line per tax_code_id. opw 626695 --- addons/point_of_sale/point_of_sale.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 0d4f0275401..304f7d71061 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -1108,11 +1108,16 @@ class pos_order(osv.osv): if not grouped_data[key]: grouped_data[key].append(values) else: - current_value = grouped_data[key][0] - current_value['quantity'] = current_value.get('quantity', 0.0) + values.get('quantity', 0.0) - current_value['credit'] = current_value.get('credit', 0.0) + values.get('credit', 0.0) - current_value['debit'] = current_value.get('debit', 0.0) + values.get('debit', 0.0) - current_value['tax_amount'] = current_value.get('tax_amount', 0.0) + values.get('tax_amount', 0.0) + for line in grouped_data[key]: + if line.get('tax_code_id') == values.get('tax_code_id'): + current_value = line + current_value['quantity'] = current_value.get('quantity', 0.0) + values.get('quantity', 0.0) + current_value['credit'] = current_value.get('credit', 0.0) + values.get('credit', 0.0) + current_value['debit'] = current_value.get('debit', 0.0) + values.get('debit', 0.0) + current_value['tax_amount'] = current_value.get('tax_amount', 0.0) + values.get('tax_amount', 0.0) + break + else: + grouped_data[key].append(values) else: grouped_data[key].append(values)