Remove safe eval

This commit is contained in:
resteve 2015-08-23 19:26:41 +02:00
parent 5292bb7d77
commit 1d1cc4a9c7
2 changed files with 9 additions and 4 deletions

View file

@ -3,7 +3,7 @@
# the full copyright notices and license terms. # the full copyright notices and license terms.
from trytond.model import fields from trytond.model import fields
from trytond.pool import PoolMeta from trytond.pool import PoolMeta
from trytond.pyson import Eval, Bool from trytond.pyson import Eval, Not, Bool
from trytond.model.fields import depends from trytond.model.fields import depends
__all__ = ['ProductOneClickView', 'ProductOneClick'] __all__ = ['ProductOneClickView', 'ProductOneClick']
@ -42,6 +42,13 @@ class ProductOneClickView:
res['training_registration'] = self.training_start_date res['training_registration'] = self.training_start_date
return res return res
@classmethod
def view_attributes(cls):
return super(ProductOneClickView, cls).view_attributes() + [
('//page[@id="esale"]', 'states', {
'invisible': Not(Bool(Eval('training'))),
})]
class ProductOneClick: class ProductOneClick:
__name__ = 'product.oneclick' __name__ = 'product.oneclick'

View file

@ -8,9 +8,7 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
<field name="training"/> <field name="training"/>
</xpath> </xpath>
<xpath expr="/form/notebook/page[@id='sale']" position="after"> <xpath expr="/form/notebook/page[@id='sale']" position="after">
<page string="Training" <page string="Training" id="training">
states="{'invisible': Not(Bool(Eval('training')))}"
id="training">
<label name="training_start_date"/> <label name="training_start_date"/>
<field name="training_start_date"/> <field name="training_start_date"/>
<label name="training_end_date"/> <label name="training_end_date"/>