← Back to team overview

openerp-india team mailing list archive

[Bug 987268] [NEW] [6.1] Fields visibility in xml views using position="attributes"

 

Public bug reported:

Hello,

Here is an issue in the use of postition "attributes" in xml views.

server revno: 4150
addons revno: 6749
openerp-web revno: 2309

When you use attributes you don't have access to the model fields.

Here is an exemple:


 1 <openerp>
  2     <data>
  3 
  4         <record model="ir.ui.view" id="view_order_form_fil    ter_shop_by_cp">
  5             <field name="name">sale.order.form.dnag_specif    ic</field>
  6             <field name="model">sale.order</field>
  7             <field name="type">form</field>
  8             <field name="inherit_id" ref="sale.view_order_    form"/>
  9             <field name="arch" type="xml">
 10                 <field name="shop_id" position="attributes    ">
 11                     <attribute name="domain">[('company_id    ', '=', company_id)]</attribute>
 12                 </field>
 13             </field>
 14         </record>
 15     </data>
 16 </openerp>


This will raise the following error :

Server Traceback (most recent call last):
  File "...openerp-web/addons/web/common/http.py", line 592, in send
    result = openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "...server/openerp/netsvc.py", line 360, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "...server/openerp/service/web_services.py", line 586, in dispatch
    res = fn(db, uid, *params)
  File "...server/openerp/osv/osv.py", line 167, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "...server/openerp/osv/osv.py", line 121, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "...server/openerp/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "...server/openerp/osv/osv.py", line 164, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "...server/openerp/osv/orm.py", line 2149, in fields_view_get
    xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=ctx)
  File "...server/openerp/osv/orm.py", line 1789, in __view_look_dom_arch
    fields_def = self.__view_look_dom(cr, user, node, view_id, False, fields, context=context)
  File "...server/openerp/osv/orm.py", line 1738, in __view_look_dom
    fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
  File "...server/openerp/osv/orm.py", line 1738, in __view_look_dom
    fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
  File "...server/openerp/osv/orm.py", line 1738, in __view_look_dom
    fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
  File "...server/openerp/osv/orm.py", line 1680, in __view_look_dom
    dom += eval(node.get('domain', '[]'), {'uid': user, 'time': time})
  File "...server/openerp/tools/safe_eval.py", line 241, in safe_eval
    return eval(test_expr(expr,_SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
  File "", line 1, in <module>
NameError: name 'company_id' is not defined

However using the following code will success :

        <field name="shop_id" position="replace">
            <field name="shop_id" domain="[('company_id', '=', company_id)]"/>
        </field>


I also tried with xpath and it is the same result:
- working with a position "replace"
- failing with a position "attributes"

Regards,
Yannick

** Affects: openobject-server
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/987268

Title:
  [6.1] Fields visibility in xml views using position="attributes"

Status in OpenERP Server:
  New

Bug description:
  Hello,

  Here is an issue in the use of postition "attributes" in xml views.

  server revno: 4150
  addons revno: 6749
  openerp-web revno: 2309

  When you use attributes you don't have access to the model fields.

  Here is an exemple:

  
   1 <openerp>
    2     <data>
    3 
    4         <record model="ir.ui.view" id="view_order_form_fil    ter_shop_by_cp">
    5             <field name="name">sale.order.form.dnag_specif    ic</field>
    6             <field name="model">sale.order</field>
    7             <field name="type">form</field>
    8             <field name="inherit_id" ref="sale.view_order_    form"/>
    9             <field name="arch" type="xml">
   10                 <field name="shop_id" position="attributes    ">
   11                     <attribute name="domain">[('company_id    ', '=', company_id)]</attribute>
   12                 </field>
   13             </field>
   14         </record>
   15     </data>
   16 </openerp>

  
  This will raise the following error :

  Server Traceback (most recent call last):
    File "...openerp-web/addons/web/common/http.py", line 592, in send
      result = openerp.netsvc.dispatch_rpc(service_name, method, args)
    File "...server/openerp/netsvc.py", line 360, in dispatch_rpc
      result = ExportService.getService(service_name).dispatch(method, params)
    File "...server/openerp/service/web_services.py", line 586, in dispatch
      res = fn(db, uid, *params)
    File "...server/openerp/osv/osv.py", line 167, in execute_kw
      return self.execute(db, uid, obj, method, *args, **kw or {})
    File "...server/openerp/osv/osv.py", line 121, in wrapper
      return f(self, dbname, *args, **kwargs)
    File "...server/openerp/osv/osv.py", line 176, in execute
      res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "...server/openerp/osv/osv.py", line 164, in execute_cr
      return getattr(object, method)(cr, uid, *args, **kw)
    File "...server/openerp/osv/orm.py", line 2149, in fields_view_get
      xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=ctx)
    File "...server/openerp/osv/orm.py", line 1789, in __view_look_dom_arch
      fields_def = self.__view_look_dom(cr, user, node, view_id, False, fields, context=context)
    File "...server/openerp/osv/orm.py", line 1738, in __view_look_dom
      fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
    File "...server/openerp/osv/orm.py", line 1738, in __view_look_dom
      fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
    File "...server/openerp/osv/orm.py", line 1738, in __view_look_dom
      fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
    File "...server/openerp/osv/orm.py", line 1680, in __view_look_dom
      dom += eval(node.get('domain', '[]'), {'uid': user, 'time': time})
    File "...server/openerp/tools/safe_eval.py", line 241, in safe_eval
      return eval(test_expr(expr,_SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
    File "", line 1, in <module>
  NameError: name 'company_id' is not defined

  However using the following code will success :

          <field name="shop_id" position="replace">
              <field name="shop_id" domain="[('company_id', '=', company_id)]"/>
          </field>

  
  I also tried with xpath and it is the same result:
  - working with a position "replace"
  - failing with a position "attributes"

  Regards,
  Yannick

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/987268/+subscriptions


Follow ups

References