summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorNans Lefebvre <len@odoo.com>2019-09-17 19:23:15 +0000
committerfw-bot <otis@odoo.com>2019-09-19 12:50:03 +0000
commiteb2885bc79a7efecd7456cb1a0fbaa142e8da83f (patch)
tree1a1e9fa50781ea93911eefa87915c734766937b3 /addons
parent7571b086bdfc58df90f204869d9bbfb138605efb (diff)
[FIX] sale: get correct account to create corresponding invoice
Sibling commit of 427280d9760a71e6ca2961bcf4a2f9f157e6dddd, same use case. Be in company C1. Create the invoice I for a SO in company C2. The invoice line is with an account created of C1. This is because property_account_income_id or property_account_income_categ_id are company dependent properties that need to be accessed with a force_company. This happens when e.g. C2 is a child company of C1. However, accounts are not readable across companies, so the resulting invoice cannot be validated in either company, since there is a mix of accounts. Note that in case force_company is False, it defaults to the user's company, which is already the default. opw 2068291 forwardport of 79714bafe4b closes odoo/odoo#37146 X-original-commit: ae84e7fd416c38404c20607b5b04fc1c9b790cde Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/sale/models/sale.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py
index aac6b338754..65a979b6b39 100644
--- a/addons/sale/models/sale.py
+++ b/addons/sale/models/sale.py
@@ -1358,7 +1358,8 @@ class SaleOrderLine(models.Model):
"""
self.ensure_one()
res = {}
- account = self.product_id.property_account_income_id or self.product_id.categ_id.property_account_income_categ_id
+ product = self.product_id.with_context(force_company=self.company_id.id)
+ account = product.property_account_income_id or product.categ_id.property_account_income_categ_id
if not account and self.product_id:
raise UserError(_('Please define income account for this product: "%s" (id:%d) - or for its category: "%s".') %