From e7f16e116dd074b3d981db15eae6a84cb5416ced Mon Sep 17 00:00:00 2001 From: Maxime Richez Date: Sun, 11 Jul 2021 11:26:46 +0200 Subject: [PATCH] Add domain to cost_price_method depending of type issue9720 --- CHANGELOG | 2 ++ product.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 06f11d6610..cf12b6531b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Allow only fixed cost price as method for service + Version 6.0.0 - 2021-05-03 * Bug fixes (see mercurial logs for details) * Deactivate variants when product is deactivated diff --git a/product.py b/product.py index cbca2bb664..06ae725844 100644 --- a/product.py +++ b/product.py @@ -14,7 +14,7 @@ from trytond.i18n import gettext from trytond.model import ( ModelView, ModelSQL, Model, UnionMixin, DeactivableMixin, sequence_ordered, Exclude, fields) -from trytond.pyson import Eval, If +from trytond.pyson import Eval, If, Get from trytond.transaction import Transaction from trytond.pool import Pool from trytond import backend @@ -129,6 +129,16 @@ class Template( super().__setup__() cls._order.insert(0, ('rec_name', 'ASC')) + types_cost_method = cls._cost_price_method_domain_per_type() + cls.cost_price_method.domain = [ + Get(types_cost_method, Eval('type'), []), + ] + cls.cost_price_method.depends = ['type'] + + @classmethod + def _cost_price_method_domain_per_type(cls): + return {'service': [('cost_price_method', '=', 'fixed')]} + @classmethod def multivalue_model(cls, field): pool = Pool()