From 019263aa5996f3147b611fb073f5d202d412cc1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 27 Sep 2017 00:04:44 +0200 Subject: [PATCH] Replace domain on cost_price_method by an on_change_type Function fields like cost_price_method can not have a domain if they do not have a searcher. issue2356 review36641002 --- product.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/product.py b/product.py index 8346f62dd9..c1c0f3a275 100644 --- a/product.py +++ b/product.py @@ -7,7 +7,7 @@ from decimal import Decimal from sql import Null, Column from trytond.model import ModelView, ModelSQL, Model, fields -from trytond.pyson import Eval, If +from trytond.pyson import Eval from trytond.transaction import Transaction from trytond.pool import Pool from trytond import backend @@ -60,11 +60,7 @@ class Template(ModelSQL, ModelView, CompanyMultiValueMixin): "Cost Price", digits=price_digits), 'get_cost_price') cost_price_method = fields.MultiValue(fields.Selection( COST_PRICE_METHODS, "Cost Price Method", required=True, - domain=[If((Eval('type') == 'service'), - ('cost_price_method', '=', 'fixed'), - (), - ) - ], states=STATES, depends=DEPENDS + ['type'])) + states=STATES, depends=DEPENDS)) cost_price_methods = fields.One2Many( 'product.cost_price_method', 'template', "Cost Price Methods") default_uom = fields.Many2One('product.uom', 'Default UOM', required=True, @@ -146,6 +142,11 @@ class Template(ModelSQL, ModelView, CompanyMultiValueMixin): return [] return [{}] + @fields.depends('type', 'cost_price_method') + def on_change_type(self): + if self.type == 'service': + self.cost_price_method = 'fixed' + @fields.depends('default_uom') def on_change_with_default_uom_category(self, name=None): if self.default_uom: