Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

AttributeError: View definition error for inherited view [Closed]

By
Atchuthan
on 6/4/13, 11:34 AM 2,746 views

The Question has been closed

by
Sudhir Arya (SA)
on 06/04/2013 11:47:36
I have two custom modules -
    1. notebook
    2. bpc
I tried to inherit the notebook module view to bpc module view with addition of a field. but error came as "Attribute Error: View definition error for inherited view.... as below

traceback:

2013-06-04 13:17:59,079 18852 INFO multi openerp.modules.module: module bpc: creating or updating database tables
2013-06-04 13:17:59,098 18852 INFO multi openerp.modules.loading: module bpc: loading bpc_view.xml
2013-06-04 13:17:59,116 18852 ERROR multi openerp.addons.base.ir.ir_ui_view: Can't render view bpc.bpc_form_view for model: bpc
Traceback (most recent call last):
  File "/var/app/openerp/server/openerp/addons/base/ir/ir_ui_view.py", line 126, 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 "/var/app/openerp/server/openerp/osv/orm.py", line 2235, in fields_view_get
    arch=apply_view_inheritance(cr, user, source, sql_res['id']),
  File "/var/app/openerp/server/openerp/osv/orm.py", line 2193, in apply_view_inheritance
    source = apply_inheritance_specs(source, view_arch, view_id)
  File "/var/app/openerp/server/openerp/osv/orm.py", line 2177, in apply_inheritance_specs
    raise_view_error("Element '%s' not found in parent view '%%(parent_xml_id)s'" % tag, inherit_id)
  File "/var/app/openerp/server/openerp/osv/orm.py", line 2070, in raise_view_error
    %  (child_view.xml_id, self._name, error_msg))
AttributeError: View definition error for inherited view 'bpc.bpc_form_view' on model 'bpc': Element '<form string="bpc">' not found in parent view 'notebook.notebook_form_view'
bpc.bpc_form_view
2013-06-04 13:17:59,131 18852 ERROR multi openerp.tools.convert: Parse error in /var/app/openerp/addons/bpc/bpc_view.xml:5: 
<record model="ir.ui.view" id="bpc_form_view">
            <field name="name">bpc.form</field>
            <field name="model">bpc</field>
            <field name="inherit_id" ref="notebook.notebook_form_view"/>
            <field name="arch" type="xml">
                <form string="bpc">
                    <field name="title"/>
                    <field name="title" position="after">
                        <field name="bpc"/>
                    </field>
                </form>
            </field>
        </record>
Traceback (most recent call last):
  File "/var/app/openerp/server/openerp/tools/convert.py", line 847, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File "/var/app/openerp/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 "/var/app/openerp/server/openerp/addons/base/ir/ir_model.py", line 936, in _update
    model_obj.write(cr, uid, [res_id], values, context=context)
  File "/var/app/openerp/server/openerp/addons/base/ir/ir_ui_view.py", line 209, in write
    return super(view, self).write(cr, uid, ids, vals, context)
  File "/var/app/openerp/server/openerp/osv/orm.py", line 4201, in write
    self._validate(cr, user, ids, context)
  File "/var/app/openerp/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!')
2013-06-04 13:17:59,132 18852 ERROR multi openerp.netsvc: ValidateError
Error occurred while validating the field(s) arch: Invalid XML for View Architecture!
Traceback (most recent call last):
  File "/var/app/openerp/server/openerp/netsvc.py", line 293, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/var/app/openerp/server/openerp/service/web_services.py", line 622, in dispatch
    security.check(db,uid,passwd)
  File "/var/app/openerp/server/openerp/service/security.py", line 40, in check
    pool = pooler.get_pool(db)
  File "/var/app/openerp/server/openerp/pooler.py", line 49, in get_pool
    return get_db_and_pool(db_name, force_demo, status, update_module)[1]
  File "/var/app/openerp/server/openerp/pooler.py", line 33, in get_db_and_pool
    registry = RegistryManager.get(db_name, force_demo, status, update_module)
  File "/var/app/openerp/server/openerp/modules/registry.py", line 192, in get
    update_module)
  File "/var/app/openerp/server/openerp/modules/registry.py", line 218, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File "/var/app/openerp/server/openerp/modules/loading.py", line 344, in load_modules
    processed = load_marked_modules(cr, graph, states_to_load, force, status, report, loaded_modules, update_module)
  File "/var/app/openerp/server/openerp/modules/loading.py", line 259, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/var/app/openerp/server/openerp/modules/loading.py", line 191, in load_module_graph
    load_data(module_name, idref, mode)
  File "/var/app/openerp/server/openerp/modules/loading.py", line 76, in <lambda>
    load_data = lambda *args: _load_data(cr, *args, kind='data')
  File "/var/app/openerp/server/openerp/modules/loading.py", line 127, in _load_data
    tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report)
  File "/var/app/openerp/server/openerp/tools/convert.py", line 954, in convert_xml_import
    obj.parse(doc.getroot())
  File "/var/app/openerp/server/openerp/tools/convert.py", line 847, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File "/var/app/openerp/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 "/var/app/openerp/server/openerp/addons/base/ir/ir_model.py", line 936, in _update
    model_obj.write(cr, uid, [res_id], values, context=context)
  File "/var/app/openerp/server/openerp/addons/base/ir/ir_ui_view.py", line 209, in write
    return super(view, self).write(cr, uid, ids, vals, context)
  File "/var/app/openerp/server/openerp/osv/orm.py", line 4201, in write
    self._validate(cr, user, ids, context)
  File "/var/app/openerp/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!')

NOTEBOOK MODULE

In __openerp__.py:
{
    "name" : "notebook",
    "version" : "0.1",
    "author" : "Atchuthan",
    "category" : "Generic Modules/Others",
    "depends" : ["base"],
    "description" : "Simple demo module",
    "data" : ["notebook_view.xml"],
    "demo_xml" : [],
    "update_xml" : [],
    "active": False,
    "installable": True
}
In notebook.py:
from osv import fields, osv
import time

class notebook(osv.osv):
    _name = "notebook"
    _description = "Simple Notebook"
    _columns = {
        'title' : fields.char('Title', size=30, required=True),
    }

notebook()

In notebook_view.xml:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <record model="ir.ui.view" id="notebook_form_view">
            <field name="name">notebook.form</field>
            <field name="model">notebook</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Notebook">
                    <field name="title" />
                </form>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_notebook_form">
            <field name="name">notebook</field>
            <field name="res_model">notebook</field>
        </record>

        <menuitem name="NotebookParent" icon="terp-project" id="NotebookParent_menu" />

        <menuitem name="NotesChild" parent="NotebookParent_menu" id="NotesChild_menu" />

        <menuitem name="Header" parent="NotesChild_menu" id="Header_menu_mainform"
            action="action_notebook_form" />
    </data>
</openerp>

BPC MODULE

In __openerp__.py:
{
    "name" : "bpc",
    "version" : "0.1",
    "author" : "bpc",
    "category" : "Generic Modules/Others",
    "depends" : ["base","notebook"],
    "description" : "Simple demo module",
    "data" : ['bpc_view.xml'],
    "demo_xml" : [],
    "update_xml" : [],
    "active": False,
    "installable": True
}

In bpc.py:
from osv import fields, osv
import time

class bpc(osv.osv):
    _name = "bpc"
    _inherit = "notebook"
    _description = "Simple bpc"
    _columns = {
        'bpc' : fields.text('bpc'),
    }

bpc()

In bpc_view.xml:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <record model="ir.ui.view" id="bpc_form_view">
            <field name="name">bpc.form</field>
            <field name="model">bpc</field>
            <field name="inherit_id" ref="notebook.notebook_form_view" />
            <field name="arch" type="xml">
                <form string="bpc">
                    <field name="title" />
                    <field name="title" position="after">
                        <field name="bpc" />
                    </field>
                </form>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_bpc_form">
            <field name="name">bpc</field>
            <field name="res_model">bpc</field>
        </record>

        <menuitem name="bpc1" icon="terp-project" id="bpc_menu" />

        <menuitem name="bpc2" parent="bpc_menu" id="bpc2_menu_mainform" />

        <menuitem name="bpc3" parent="bpc2_menu_mainform" id="bpc3_menu_mainform"
            action="action_bpc_form" />
    </data>
</openerp>

Give me suggestion regarding this error.

3

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 6/4/13, 11:38 AM

Error is because you have used form tag inside inherited view.

Try this:

    <record model="ir.ui.view" id="bpc_form_view">
        <field name="name">bpc.form</field>
        <field name="model">bpc</field>
        <field name="inherit_id" ref="notebook.notebook_form_view" />
        <field name="arch" type="xml">
                <field name="title" position="after">
                    <field name="bpc" />
                </field>
            </form>
        </field>
    </record>

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 6/4/13, 11:34 AM
Seen: 2746 times
Last updated: 3/16/15, 8:10 AM