If an aml has no product, it should not trigger a model that has a product. So, we now define the fields that have to be checked on the model, instead of just being the ones given as parameters. The way the field `company_id` impacts the model has also been changed. The idea is that a model with a company specified should be better than a model without one. But we also want that a model with 1 valid rule and no company is better than one with only a good selected company. closes odoo/odoo#107165 X-original-commit: feff1a8a056f1fbbc852f7cf164e73abf83c4cc9 Signed-off-by: William André (wan) <wan@odoo.com>
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from odoo import fields, models
|
|
|
|
|
|
class AccountAnalyticDistributionModel(models.Model):
|
|
_inherit = 'account.analytic.distribution.model'
|
|
|
|
account_prefix = fields.Char(
|
|
string='Accounts Prefix',
|
|
help="This analytic distribution will apply to all financial accounts sharing the prefix specified.",
|
|
)
|
|
product_id = fields.Many2one(
|
|
'product.product',
|
|
string='Product',
|
|
ondelete='cascade',
|
|
help="Select a product for which the analytic distribution will be used (e.g. create new customer invoice or Sales order if we select this product, it will automatically take this as an analytic account)",
|
|
)
|
|
product_categ_id = fields.Many2one(
|
|
'product.category',
|
|
string='Product Category',
|
|
ondelete='cascade',
|
|
help="Select a product category which will use analytic account specified in analytic default (e.g. create new customer invoice or Sales order if we select this product, it will automatically take this as an analytic account)",
|
|
)
|
|
|
|
def _create_domain(self, fname, value):
|
|
if not fname == 'account_prefix':
|
|
return super()._create_domain(fname, value)
|