[MERGE] merged the branch that change the syntax to use in widget options to python instead of json

bzr revid: qdp-launchpad@openerp.com-20121010120048-7n3h1o779du2zmo1
This commit is contained in:
Quentin (OpenERP) 2012-10-10 14:00:48 +02:00
commit 454898d1ba
5 changed files with 16 additions and 9 deletions

View File

@ -106,8 +106,8 @@
<field name="zip" class="oe_inline" placeholder="ZIP"/>
<field name="city" class="oe_inline" placeholder="City"/>
</div>
<field name="state_id" placeholder="State" options='{"no_open": true}'/>
<field name="country_id" placeholder="Country" options='{"no_open": true}'/>
<field name="state_id" placeholder="State" options='{"no_open": True}'/>
<field name="country_id" placeholder="Country" options='{"no_open": True}'/>
</div>
</group>
<group name="bank" string="Information About the Bank">

View File

@ -46,10 +46,10 @@
<field name="street2"/>
<div>
<field name="city" placeholder="City" style="width: 40%%"/>
<field name="state_id" class="oe_no_button" placeholder="State" style="width: 24%%" options='{"no_open": true}'/>
<field name="state_id" class="oe_no_button" placeholder="State" style="width: 24%%" options='{"no_open": True}'/>
<field name="zip" placeholder="ZIP" style="width: 34%%"/>
</div>
<field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": true}' on_change="on_change_country(country_id)"/>
<field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": True}' on_change="on_change_country(country_id)"/>
</div>
<label for="rml_header1"/>
<div>

View File

@ -73,7 +73,7 @@
<group>
<field name="name"/>
<field name="code"/>
<field name="country_id" options='{"no_open": true}'/>
<field name="country_id" options='{"no_open": True}'/>
</group>
</form>
</field>

View File

@ -161,10 +161,10 @@
<field name="street2"/>
<div class="address_format">
<field name="city" placeholder="City" style="width: 40%%"/>
<field name="state_id" class="oe_no_button" placeholder="State" style="width: 37%%" options='{"no_open": true}'/>
<field name="state_id" class="oe_no_button" placeholder="State" style="width: 37%%" options='{"no_open": True}'/>
<field name="zip" placeholder="ZIP" style="width: 20%%"/>
</div>
<field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": true}'/>
<field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": True}'/>
</div>
<field name="website" widget="url" placeholder="e.g. www.openerp.com"/>
</group>
@ -177,7 +177,7 @@
<field name="email" widget="email"/>
<field name="title" domain="[('domain', '=', 'contact')]"
groups="base.group_no_one"
options='{"no_open": true}' attrs="{'invisible': [('is_company','=', True)]}" />
options='{"no_open": True}' attrs="{'invisible': [('is_company','=', True)]}" />
</group>
</group>

View File

@ -61,6 +61,7 @@ import openerp.netsvc as netsvc
import openerp.tools as tools
from openerp.tools.config import config
from openerp.tools.safe_eval import safe_eval as eval
from ast import literal_eval
from openerp.tools.translate import _
from openerp import SUPERUSER_ID
from query import Query
@ -1732,7 +1733,13 @@ class BaseModel(object):
field = model_fields.get(node.get('name'))
if field:
transfer_field_to_modifiers(field, modifiers)
#evaluate the options as python code, but send it as json to the client
if node.get('options'):
try:
node.set('options', simplejson.dumps(literal_eval(node.get('options'))))
except Exception, e:
_logger.exception('Invalid `options´ attribute, should be a valid python expression: %r', node.get('options'))
raise except_orm('Invalid options', 'Invalid options: %r %s' % (node.get('options'), e))
elif node.tag in ('form', 'tree'):
result = self.view_header_get(cr, user, False, node.tag, context)