[7.0] XML replace fails on a new update

Bug #1111340 reported by Yannick Vaucher @ Camptocamp
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
New
Undecided
OpenERP Publisher's Warranty Team

Bug Description

Hello,

I have a strange issue. I'm currently removing the default contact form in res_partner view form.

Using:

    <record id="view_partner_form_usedefault_form_for_contacts" model="ir.ui.view">
        <field name="name">res.partner.form</field>
        <field name="model">res.partner</field>
        <field eval="1" name="priority"/>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <form string="Contact" position="replace">
                <form string="Contact">
                </form>
            </form>
        </field>
    </record>

Fisrt time I update my module everythings go fine.

However, while I'm developping this module if I do some changes in my xml file on other inherit on the res_partner_view, this change fails and raise the following error on module update.

Can't render view test.view_partner_form_usedefault_form_for_contacts for model: res.partner
Traceback (most recent call last):
  File ".../server/openerp/addons/base/ir/ir_ui_view.py", line 125, in _check_render_view
    fvg = self.pool.get(view.model).fields_view_get(cr, uid, view_id=view.id, view_type=view.type, context=context)
  File ".../server/openerp/addons/base/res/res_partner.py", line 291, in fields_view_get
    res = super(res_partner,self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
  File ".../server/openerp/osv/orm.py", line 2262, 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 1934, in __view_look_dom_arch
    model = res[0][1]
IndexError: list index out of range
2013-01-31 10:36:11,872 12143 ERROR openerp_test openerp.tools.convert: Parse error in .../specific-addons/test/res_partner_view.xml:149:
<record id="view_partner_form_usedefault_form_for_contacts" model="ir.ui.view">
            <field name="name">res.partner.form</field>
            <field name="model">res.partner</field>
            <field eval="1" name="priority"/>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <form string="Contact" position="replace">
                    <form string="Contact">
                    </form>
                </form>
            </field>
        </record>
Traceback (most recent call last):
  File ".../server/openerp/tools/convert.py", line 847, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File ".../server/openerp/tools/convert.py", line 814, in _tag_record
    id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File ".../server/openerp/addons/base/ir/ir_model.py", line 929, in _update
    model_obj.write(cr, uid, [res_id], values, context=context)
  File ".../server/openerp/addons/base/ir/ir_ui_view.py", line 207, in write
    return super(view, self).write(cr, uid, ids, vals, context)
  File ".../server/openerp/osv/orm.py", line 4203, in write
    self._validate(cr, user, ids, context)
  File ".../server/openerp/osv/orm.py", line 1546, in _validate
    raise except_orm('ValidateError', '\n'.join(error_msgs))
except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
2013-01-31 10:36:11,873 12143 ERROR openerp_test openerp: Failed to initialize database `openerp_test`.
Traceback (most recent call last):
  File ".../server/openerp/cli/server.py", line 98, in preload_registry
    db, registry = openerp.pooler.get_db_and_pool(dbname,update_module=update_module)
  File ".../server/openerp/pooler.py", line 33, in get_db_and_pool
    registry = RegistryManager.get(db_name, force_demo, status, update_module)
  File ".../server/openerp/modules/registry.py", line 192, in get
    update_module)
  File ".../server/openerp/modules/registry.py", line 214, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File ".../server/openerp/modules/loading.py", line 343, in load_modules
    processed = load_marked_modules(cr, graph, states_to_load, force, status, report, loaded_modules, update_module)
  File ".../server/openerp/modules/loading.py", line 258, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File ".../server/openerp/modules/loading.py", line 189, in load_module_graph
    load_update_xml(module_name, idref, mode)
  File ".../server/openerp/modules/loading.py", line 73, in <lambda>
    load_update_xml = lambda *args: _load_data(cr, *args, kind='update_xml')
  File ".../server/openerp/modules/loading.py", line 126, in _load_data
    tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report)
  File ".../server/openerp/tools/convert.py", line 954, in convert_xml_import
    obj.parse(doc.getroot())
  File ".../server/openerp/tools/convert.py", line 847, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File ".../server/openerp/tools/convert.py", line 814, in _tag_record
    id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File ".../server/openerp/addons/base/ir/ir_model.py", line 929, in _update
    model_obj.write(cr, uid, [res_id], values, context=context)
  File ".../server/openerp/addons/base/ir/ir_ui_view.py", line 207, in write
    return super(view, self).write(cr, uid, ids, vals, context)
  File ".../server/openerp/osv/orm.py", line 4203, in write
    self._validate(cr, user, ids, context)
  File ".../server/openerp/osv/orm.py", line 1546, in _validate
    raise except_orm('ValidateError', '\n'.join(error_msgs))
except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')

I assume the form string="Contact" is somehow already deleted and it tries to delete it a second time...

To resolve I can
1. remove view_partner_form_usedefault_form_for_contacts from my from XML file
2. update the module.
3. add again view_partner_form_usedefault_form_for_contacts
4. update the module.

And there I have what I need. But this is quite anoying...

revision-ids
server: <email address hidden>
webclient: <email address hidden>
addons: <email address hidden>

Tags: maintenance
description: updated
Revision history for this message
Gustavo Adrian Marino (gamarino) wrote : Re: [Bug 1111340] Re: [7.0] XML replace fails on a new update
Download full text (20.5 KiB)

Please, try:

     <record id="view_partner_form_usedefault_form_for_contacts"
model="ir.ui.view">
          <field name="name">res.partner.form</field>
          <field name="model">res.partner</field>
          <field eval="1" name="priority"/>
          <field name="inherit_id" ref="base.view_partner_form"/>
          <field name="arch" type="xml">
              <//xpath expr="//field[@name='Contact']" position="replace" />
          </field>
      </record>

The tag form name="Contact" does not make sense. Eventually, you could try
with field tag, but in this case you will wipe out all attributes, but the
field will still be in the view
Best regards

2013/1/31 Yannick Vaucher @ Camptocamp <email address hidden>

> ** Description changed:
>
> Hello,
>
> I have a strange issue. I'm currently removing the default contact form
> in res_partner view form.
>
> Using:
>
> - <record id="view_partner_form_usedefault_form_for_contacts"
> model="ir.ui.view">
> - <field name="name">res.partner.form</field>
> - <field name="model">res.partner</field>
> - <field eval="1" name="priority"/>
> - <field name="inherit_id" ref="base.view_partner_form"/>
> - <field name="arch" type="xml">
> - <form string="Contact" position="replace">
> - <form string="Contact">
> - </form>
> - </form>
> - </field>
> - </record>
> -
> + <record id="view_partner_form_usedefault_form_for_contacts"
> model="ir.ui.view">
> + <field name="name">res.partner.form</field>
> + <field name="model">res.partner</field>
> + <field eval="1" name="priority"/>
> + <field name="inherit_id" ref="base.view_partner_form"/>
> + <field name="arch" type="xml">
> + <form string="Contact" position="replace">
> + <form string="Contact">
> + </form>
> + </form>
> + </field>
> + </record>
>
> Fisrt time I update my module everythings go fine.
>
> However, while I'm developping this module if I do some changes in my
> xml file on other inherit on the res_partner_view, this change fails and
> raise the following error on module update.
>
> Can't render view test.view_partner_form_usedefault_form_for_contacts
> for model: res.partner
> Traceback (most recent call last):
> - File ".../server/openerp/addons/base/ir/ir_ui_view.py", line 125, in
> _check_render_view
> - fvg = self.pool.get(view.model).fields_view_get(cr, uid, view_id=
> view.id, view_type=view.type, context=context)
> - File ".../server/openerp/addons/base/res/res_partner.py", line 291, in
> fields_view_get
> - res = super(res_partner,self).fields_view_get(cr, user, view_id,
> view_type, context, toolbar=toolbar, submenu=submenu)
> - File ".../server/openerp/osv/orm.py", line 2262, 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 1934, in
> __view_look_dom_arch
> - model = res[0][1]
> + File ".../server/openerp/addons/base/ir/ir_ui_view.py", line 125, in
> _ch...

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Well in that case it isn't a single field I want to get ride the inside form : //field[@name='child_ids']/form

This because I don't need the minimal form for contact in res.partner

Revision history for this message
Nikola Stojanoski (nstojanoski) wrote :

Hello,

I'm having the same issue. I'm adding one more field to project module and i have to remove the view, update module, add back the view, update module again.

My code:
----------------------------------------------------------------------------------------
        <record model="ir.ui.view" id="view_project_form_bom">
            <field name="name">project.task.form</field>
            <field name="model">project.task</field>
            <field name="inherit_id" ref="project.view_task_form2" />
            <field name="arch" type="xml">
                <field name="user_id" position="after">
                    <field name="bom_id"/>
                </field>
            </field>
        </record>

----------------------------------------------------------------------------------------
class project_task(osv.Model):
    _inherit = 'project.task'
    _columns = {
            'sub_products':fields.one2many('mrp.subproduct', 'bom_id', 'Byproducts'),
            'bom_id': fields.many2one('mrp.bom', 'BOM', ondelete='set null', domain=[('in_project', '=', True)]),
            'daily_journal':fields.one2many('construction.journal', 'task_id', 'Journals'),
            'tasks_id': fields.many2one('construction.task', 'Task', ondelete='set null'),

    }

project_task()

-------------------------------------------------------------------------------------
the error:

2013-04-23 16:11:15,118 6683 ERROR construction openerp.addons.base.ir.ir_ui_view: Can't render view construction.view_project_form_bom for model: project.task

---------------------------------

    xarch, xfields = relation.__view_look_dom_arch(cr, user, f, view_id, ctx)
AttributeError: 'NoneType' object has no attribute '_BaseModel__view_look_dom_arch'
2013-04-23 16:11:15,120 6683 ERROR construction openerp.tools.convert: Parse error in /home/mrks/openerp7/vion_addons/construction/project_bom_view.xml:17:
<record model="ir.ui.view" id="view_project_form_bom">
            <field name="name">project.task.form</field>
            <field name="model">project.task</field>
            <field name="inherit_id" ref="project.view_task_form2"/>
            <field name="arch" type="xml">
                <field name="user_id" position="after">
                    <field name="bom_id"/>
                </field>
            </field>
        </record>

--------
  File "/home/mrks/openerp7/server/openerp/osv/orm.py", line 1544, in _validate
    raise except_orm('ValidateError', '\n'.join(error_msgs))
except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')

-------------------

The error is exactly the same, the fix is the same and annoying during development.

Regards,
Nikola

Changed in openobject-server:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Revision history for this message
Michael Karrer (michaelkarrer81) wrote :

We do have the same problems - any news on this or any workaround or at least a clear description why this happens?!?

Revision history for this message
Kalpana Hemnani(SerpentCS) (khemnani-serpentcs) wrote :

Hello Yannick Vaucher,

We have tried replacing Contact form with xpath:

    <record id="view_partner_form_usedefault_form_for_contacts" model="ir.ui.view">
        <field name="name">res.partner.form</field>
        <field name="model">res.partner</field>
        <field eval="1" name="priority"/>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <xpath expr="//notebook/page[@string='Contacts']/field[@name='child_ids']/form[@string='Contact']" position="replace" >
                <form string="Contact"></form>
            </xpath>
        </field>
     </record>

by above view, we are able to replace Contact form. We prefer to use xpath while working with internal views.

But some fields of Contact form are inherited in sales module, so in this case we also have to remove that inheritance from sales module:

        <record id="sale.res_partner_address_type" model="ir.ui.view">
            <field name="name">res.partner.view.address_type</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form" />
            <field name="arch" type="xml">
                <xpath expr="//label[@for='type']" position="attributes">
                    <attribute name="groups">sale.group_delivery_invoice_address</attribute>
                    <attribute name="invisible">False</attribute>
                </xpath>
                <xpath expr="//div[@name='div_type']" position="attributes">
                    <attribute name="invisible">False</attribute>
                    <attribute name="groups">sale.group_delivery_invoice_address</attribute>
                </xpath>
                <!-- Version-specific hacks to avoid breaking view inheritance when the sale module
                      is installed on top of an older 7.0 version of the base module
                      (as the second embedded div_type was added later in the 7.0 release)
                      TODO: remove the hacks in trunk -->
<!-- comment out or remove below two xpath attributes -->
<!-- <xpath expr="//div[@name='div_type'][field[@name='use_parent_address']] | //field[@name='child_ids']//div[@name='div_type']" position="attributes"> -->
<!-- <attribute name="invisible">False</attribute> -->
<!-- <attribute name="groups">sale.group_delivery_invoice_address</attribute> -->
<!-- </xpath> -->
<!-- <xpath expr="//label[@for='type'][following-sibling::div[@name='div_type']/field[@name='use_parent_address']] | //field[@name='child_ids']//label[@for='type']" position="attributes"> -->
<!-- <attribute name="invisible">False</attribute> -->
<!-- <attribute name="groups">sale.group_delivery_invoice_address</attribute> -->
<!-- </xpath> -->
            </field>
        </record>

Hope this helps.

Thanks and Regards,
Kalpana Hemnani,
Serpent Consulting Services Pvt. Ltd.

Revision history for this message
Serpent Consulting Services (serpent-consulting-services) wrote :

Guys,

Does not the above comment help resolving the issue?

Thanks.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.