The `analytic_distribution` field is a Json. It was stored temporarily as a char. Search is not available yet, so we do queries by hand when we need to search on keys. Also added a constraint on account_analytic_distribution_model, so we don't have models with accounts specific to a company when the model has no company or another company. It would cause an issue when looking at the models from another company. X-original-commit: 7064c95aa04e5138bb12ae97acfee04ebb67cc0e Part-of: odoo/odoo#103097
14 lines
574 B
Python
14 lines
574 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
from odoo import models
|
|
|
|
|
|
class AccountMoveLine(models.Model):
|
|
_inherit = 'account.move.line'
|
|
|
|
def _compute_analytic_distribution(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_distribution and any(aml.sale_line_ids.project_id))
|
|
super(AccountMoveLine, self - project_amls)._compute_analytic_distribution()
|