[FIX] account: No account on invoice lines

Create a product category with no accounts defined
Create a product [DEMO] in such category with no account defined
Create an invoice with the default journal which will have the default
account

Create an invoice line with [DEMO]
Upon selecting the product the default account taken from the journal
get cleared and there will be no replacement.
Since the account field is mandatory the account should be preserved

opw-2299228

closes odoo/odoo#54751

X-original-commit: f4c41997cfd560ded6d387324e5dbcf1b7183a36
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2020-07-22 09:37:07 +00:00
parent 3922182c97
commit ff64332424
+2 -2
View File
@@ -2963,10 +2963,10 @@ class AccountMoveLine(models.Model):
accounts = self.product_id.product_tmpl_id.get_product_accounts(fiscal_pos=fiscal_position)
if self.move_id.is_sale_document(include_receipts=True):
# Out invoice.
return accounts['income']
return accounts['income'] or self.account_id
elif self.move_id.is_purchase_document(include_receipts=True):
# In invoice.
return accounts['expense']
return accounts['expense'] or self.account_id
def _get_computed_taxes(self):
self.ensure_one()