Skip to content
Snippets Groups Projects
Commit 27b70a87 authored by Nasreddin (bon)'s avatar Nasreddin (bon)
Browse files

[FIX] account_analytic_default: disable on receivable/payable when comes from partner


Issue

	- Install "Accounting" and "Account Analytic Defaults".
	- Create an Analytic Tag and use the distribution (eg.: 60/40)
	- Create an Analytic Defaults for a specific partner.
	  with the Analytc tag just created.
	- Create a bill, select the the same partner as the Analytic Defaults and
	  add a new Invoice Line with a price (eg.: 1000).

	The tag is applied to the payable account, which is
	wrong and it leads to an analytic inconsistency.

Cause

	In odoo 13 we are using single model for both the invoice and for journal entries.

Solution

	Apply analytic tags only on move lines not excluded from invoice tab.

opw-2269757

closes odoo/odoo#54137

Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent a3582e1f
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,8 @@ class AccountMoveLine(models.Model):
@api.depends('product_id', 'account_id', 'partner_id', 'date_maturity')
def _compute_analytic_account(self):
for record in self:
record.analytic_account_id = (record._origin or record).analytic_account_id
record.analytic_tag_ids = (record._origin or record).analytic_tag_ids
rec = self.env['account.analytic.default'].account_get(
product_id=record.product_id.id,
partner_id=record.partner_id.commercial_partner_id.id or record.move_id.partner_id.commercial_partner_id.id,
......@@ -83,5 +85,6 @@ class AccountMoveLine(models.Model):
date=record.date_maturity,
company_id=record.move_id.company_id.id
)
record.analytic_account_id = (record._origin or record).analytic_account_id or rec.analytic_id
record.analytic_tag_ids = (record._origin or record).analytic_tag_ids or rec.analytic_tag_ids
if rec and not record.exclude_from_invoice_tab:
record.analytic_account_id = rec.analytic_id
record.analytic_tag_ids = rec.analytic_tag_ids
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment