Remove safe eval

This commit is contained in:
resteve 2015-08-23 19:15:53 +02:00
parent ca6e6fe9d6
commit 6fe2bd1804
2 changed files with 14 additions and 5 deletions

View File

@ -3,7 +3,7 @@
# the full copyright notices and license terms.
from trytond.model import ModelView, fields
from trytond.pool import Pool
from trytond.pyson import Eval, PYSONEncoder
from trytond.pyson import Eval, Not, Bool, PYSONEncoder
from trytond.wizard import Wizard, StateView, StateAction, StateTransition, \
Button
from trytond.config import config as config_
@ -96,6 +96,17 @@ class ProductOneClickView(ModelView):
template = Template(id=None, default_uom=self.default_uom)
return template.on_change_with_default_uom_category(name)
@classmethod
def view_attributes(cls):
return super(ProductOneClickView, cls).view_attributes() + [
('//page[@id="sale"]', 'states', {
'invisible': Not(Bool(Eval('salable'))),
}),
('//page[@id="purchase"]', 'states', {
'invisible': Not(Bool(Eval('purchasable'))),
}),
]
class ProductOneClick(Wizard):
'Product OneClick'

View File

@ -19,15 +19,13 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
<label name="default_uom"/>
<field name="default_uom"/>
</page>
<page string="Sale" id="sale"
states="{'invisible': Not(Bool(Eval('salable')))}">
<page string="Sale" id="sale">
<label name="list_price"/>
<field name="list_price"/>
<label name="sale_uom"/>
<field name="sale_uom"/>
</page>
<page string="Purchase" id="purchase"
states="{'invisible': Not(Bool(Eval('purchasable')))}">
<page string="Purchase" id="purchase">
<label name="cost_price"/>
<field name="cost_price"/>
<label name="cost_price_method"/>