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
This commit is contained in:
1 parent
8a201cb9b8
commit
019263aa59
1 file changed
+7
-6
+7
-6
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user