From 2bba2e1a20c5a71e5ed5b5af7a68c7205e5c476f Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 6 Feb 2019 13:02:13 +0000 Subject: [PATCH] [IMP] point_of_sale: map accounts based on fiscal position If a fiscal position is set on an order had uses account mapping, the account for the generated accounting entries must be adapted Changed in master for stability reason opw-1910475 closes odoo/odoo#30883 --- addons/point_of_sale/models/pos_order.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 81937a534ff..777833b861d 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -269,13 +269,15 @@ class PosOrder(models.Model): # Search for the income account if line.product_id.property_account_income_id.id: - income_account = line.product_id.property_account_income_id.id + income_account = line.product_id.property_account_income_id elif line.product_id.categ_id.property_account_income_categ_id.id: - income_account = line.product_id.categ_id.property_account_income_categ_id.id + income_account = line.product_id.categ_id.property_account_income_categ_id else: raise UserError(_('Please define income ' 'account for this product: "%s" (id:%d).') % (line.product_id.name, line.product_id.id)) + if order.fiscal_position_id.account_ids: + income_account = order.fiscal_position_id.map_account(income_account) name = line.product_id.name if line.notice: @@ -290,7 +292,7 @@ class PosOrder(models.Model): 'name': name, 'quantity': line.qty, 'product_id': line.product_id.id, - 'account_id': income_account, + 'account_id': income_account.id, 'analytic_account_id': self._prepare_analytic_account(line), 'credit': ((amount_subtotal > 0) and amount_subtotal) or 0.0, 'debit': ((amount_subtotal < 0) and -amount_subtotal) or 0.0, @@ -317,7 +319,7 @@ class PosOrder(models.Model): 'name': _('Tax') + ' ' + tax['name'], 'product_id': line.product_id.id, 'quantity': line.qty, - 'account_id': tax['account_id'] or income_account, + 'account_id': tax['account_id'] or income_account.id, 'credit': ((amount_tax > 0) and amount_tax) or 0.0, 'debit': ((amount_tax < 0) and -amount_tax) or 0.0, 'tax_line_id': tax['id'],