summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2019-02-06 13:02:13 +0000
committerMartin Trigaux <mat@odoo.com>2019-02-06 13:03:03 +0000
commit2bba2e1a20c5a71e5ed5b5af7a68c7205e5c476f (patch)
tree91f5c72963d4ccca87e6c7265f5953c0a4c84fb4
parentf78b7a76d62d6b5f3e82f2f4a02b14981859df1f (diff)
[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
-rw-r--r--addons/point_of_sale/models/pos_order.py10
1 files 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'],