diff --git a/addons/sale_project/models/__init__.py b/addons/sale_project/models/__init__.py index 2ca122c0b24..b627bbd3dd6 100644 --- a/addons/sale_project/models/__init__.py +++ b/addons/sale_project/models/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +from . import account_move from . import product from . import project from . import project_milestone diff --git a/addons/sale_project/models/account_move.py b/addons/sale_project/models/account_move.py new file mode 100644 index 00000000000..5179cde0281 --- /dev/null +++ b/addons/sale_project/models/account_move.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +from odoo import models + + +class AccountMoveLine(models.Model): + _inherit = 'account.move.line' + + def _compute_analytic_account_id(self): + # when a project creates an aml, it adds an analytic account to it. the following filter is to save this + # analytic account from being overridden by analytic default rules and lack thereof + project_amls = self.filtered(lambda aml: aml.analytic_account_id and any(aml.sale_line_ids.project_id)) + super(AccountMoveLine, self - project_amls)._compute_analytic_account_id()