[IMP] osv/orm.py: evaluate in python the 'options' attribute of a field in an xml...
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Tue, 9 Oct 2012 14:26:07 +0000 (16:26 +0200)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Tue, 9 Oct 2012 14:26:07 +0000 (16:26 +0200)
bzr revid: qdp-launchpad@openerp.com-20121009142607-rk3l00atu3w3kksp

openerp/addons/base/res/res_bank_view.xml
openerp/addons/base/res/res_company_view.xml
openerp/addons/base/res/res_country_view.xml
openerp/addons/base/res/res_partner_view.xml
openerp/osv/orm.py
openerp/tools/safe_eval.py

index ac91684..33b98c6 100644 (file)
                                     <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">
index cac53b7..b8cb12d 100644 (file)
                                         <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>
index c8046d3..52c8b64 100644 (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>
index f90e297..caa5ce2 100644 (file)
                                 <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>
                             <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>
 
index c713c03..8bc5c38 100644 (file)
@@ -60,7 +60,7 @@ import openerp
 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 openerp.tools.safe_eval import const_eval, safe_eval as eval
 from openerp.tools.translate import _
 from openerp import SUPERUSER_ID
 from query import Query
@@ -1732,7 +1732,11 @@ class BaseModel(object):
                 field = model_fields.get(node.get('name'))
                 if field:
                     transfer_field_to_modifiers(field, modifiers)
-
+                if node.get('options'):
+                    try:
+                        node.set('options', simplejson.dumps(const_eval(node.get('options'))))
+                    except Exception, msg:
+                        raise except_orm('Invalide Python code in %s'%(node.get('options')), msg[0])
 
         elif node.tag in ('form', 'tree'):
             result = self.view_header_get(cr, user, False, node.tag, context)
index 601fd95..6bc92e5 100644 (file)
@@ -46,7 +46,7 @@ _ALLOWED_MODULES = ['_strptime', 'time']
 _CONST_OPCODES = set(opmap[x] for x in [
     'POP_TOP', 'ROT_TWO', 'ROT_THREE', 'ROT_FOUR', 'DUP_TOP', 'DUP_TOPX',
     'POP_BLOCK','SETUP_LOOP', 'BUILD_LIST', 'BUILD_MAP', 'BUILD_TUPLE',
-    'LOAD_CONST', 'RETURN_VALUE', 'STORE_SUBSCR'] if x in opmap)
+    'LOAD_CONST', 'RETURN_VALUE', 'STORE_SUBSCR', 'STORE_MAP', 'LOAD_NAME'] if x in opmap)
 
 _EXPR_OPCODES = _CONST_OPCODES.union(set(opmap[x] for x in [
     'UNARY_POSITIVE', 'UNARY_NEGATIVE', 'UNARY_NOT',