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.

0

Why <field>_ids might not exist.

By
Dale E. Moore
on 12/6/13, 10:57 PM 2,353 views

I can't seem to get this <field>_ids to appear. I get fatal errors when I try to install the module.

OpenERP Version 7.0-20131021-232357
cat /etc/issue
Ubuntu 13.10 \n \l

/var/log/openerp/openerp.log shows me:

2013-12-08 13:30:01,654 16215 ERROR eo2-3 openerp.addons.base.ir.ir_ui_view: Can't render view  for model: project.project
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131021_232357-py2.7.egg/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 "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131021_232357-py2.7.egg/openerp/osv/orm.py", line 2239, in fields_view_get
    arch=apply_view_inheritance(cr, user, source, sql_res['id']),
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131021_232357-py2.7.egg/openerp/osv/orm.py", line 2197, in apply_view_inheritance
    source = apply_inheritance_specs(source, view_arch, view_id)
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131021_232357-py2.7.egg/openerp/osv/orm.py", line 2181, in apply_inheritance_specs
    raise_view_error("Element '%s' not found in parent view '%%(parent_xml_id)s'" % tag, inherit_id)
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131021_232357-py2.7.egg/openerp/osv/orm.py", line 2074, in raise_view_error
    %  (child_view.xml_id, self._name, error_msg))
AttributeError: View definition error for inherited view '' on model 'project.project': Element '<field colspan="6" name="cert_ids" nolabel="1">' not found in parent view 'project.edit_project'
2013-12-08 13:30:01,657 16215 ERROR eo2-3 openerp.tools.convert: Parse error in /usr/local/lib/python2.7/dist-packages/openerp-7.0_20131021_232357-py2.7.egg/openerp/addons/med_test_2/project_view.xml:17: 
<record id="view_project_project_form" model="ir.ui.view">
            <field name="name">project.project.medical.form</field>
            <field name="model">project.project</field>
            <field name="inherit_id" ref="project.edit_project"/>
            <field name="arch" type="xml">
                <data><field name="user_id" position="after">
                    <field name="client_id" string="Client"/>
                    <field name="status" string="Status"/>
                </field>
                <field colspan="6" name="cert_ids" nolabel="1">
                    <form string="Certification by Doctor">
                        <group col="1" colspan="2">
                            <button name="copy_cert" type="object" string="Duplicate" icon="gtk-ok"/>
                        </group>
                        <field name="effective" string="Effective"/>
                        <field name="note" string="Note" select="1"/>
                    </form>
                </field>
            </data></field>
        </record>
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131021_232357-py2.7.egg/openerp/tools/convert.py", line 847, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131021_232357-py2.7.egg/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 "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131021_232357-py2.7.egg/openerp/addons/base/ir/ir_model.py", line 967, in _update
    res_id = model_obj.create(cr, uid, values, context=context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131021_232357-py2.7.egg/openerp/addons/base/ir/ir_ui_view.py", line 103, in create
    return super(view, self).create(cr, uid, values, context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131021_232357-py2.7.egg/openerp/osv/orm.py", line 4478, in create
    self._validate(cr, user, [id_new], context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20131021_232357-py2.7.egg/openerp/osv/orm.py", line 1548, 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!')

Though other fields defined in the .py are added.

2013-12-08 13:30:01,402 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_project': added column 'status' with definition=VARCHAR
2013-12-08 13:30:01,415 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_project': column 'alias_id': dropped NOT NULL constraint
2013-12-08 13:30:01,427 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_project': added column 'client_id' with definition=int4
2013-12-08 13:30:01,427 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_project': added foreign key 'client_id' with definition=REFERENCES "res_partner" ON DELETE set null
2013-12-08 13:30:01,485 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_medical_cert': created
2013-12-08 13:30:01,493 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_medical_cert': added column 'create_uid' with definition=INTEGER REFERENCES res_users ON DELETE SET NULL
2013-12-08 13:30:01,497 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_medical_cert': added column 'create_date' with definition=TIMESTAMP
2013-12-08 13:30:01,500 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_medical_cert': added column 'write_date' with definition=TIMESTAMP
2013-12-08 13:30:01,509 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_medical_cert': added column 'write_uid' with definition=INTEGER REFERENCES res_users ON DELETE SET NULL
2013-12-08 13:30:01,516 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_medical_cert': added column 'note' with definition=VARCHAR(30)
2013-12-08 13:30:01,518 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_medical_cert': added column 'project_id' with definition=int4
2013-12-08 13:30:01,519 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_medical_cert': added foreign key 'project_id' with definition=REFERENCES "project_project" ON DELETE set null
2013-12-08 13:30:01,523 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_medical_cert': column 'project_id': added a NOT NULL constraint
2013-12-08 13:30:01,530 16215 DEBUG eo2-3 openerp.osv.orm.schema: Table 'project_medical_cert': added column 'effective' with definition=timestamp

__init__.py:

import project

__openerp__.py:

{
    'name': 'med_test_2',
    'version': '1.6.13',
    "category": "Project Management",
    'author': 'Dale E. Moore',
    'website': 'MooreWorks.Net',
    'depends': ['project'],
    'update_xml': [
        'project_view.xml',
    ],
    'installable': True,
    'application': False,
}

project.py:

    from osv import fields, osv
import time
class partner(osv.osv):
    _inherit = "res.partner"
    _columns = {
        'project_id':fields.many2one('project.project', 'Project'),
        'dob':fields.date('Date of Birth'),
        'shift':fields.selection([('afterSchool','After School'), ('day','Day'), ('anytime', 'Anytime')], 'Shift', help="What shift can the client be seen? Anytime, Day, or After School."),
    }
partner()
class project(osv.osv):
    _inherit = "project.project"
    _columns = {
        'cert_ids': fields.one2many('project.medical.cert', 'project_id', 'Doctor Certification'),
        'client_id':fields.many2one('res.partner', 'Client'),
        'status':fields.selection([
                            ('active', 'Active'),
                            ('inProcess', 'In Process'),
                            ('holdParent', 'Parent Hold'), 
                            ('discharged', 'Discharged'), 
                            ('dnq', 'Does Not Qualify (DNQ)'), 
                            ], 'Status', help="Project Status; active, ..."),
    }
project()
class project_medical_cert(osv.osv):
    _name = "project.medical.cert"
    _description = "Doctor Certification"
    _columns = {
        'project_id': fields.many2one('project.project', 'Project', ondelete='set null', select="1", required=True),
        'effective': fields.datetime('Effective', help='The date and time this record became effective.'),
        'note': fields.char('Note',size=30,help='What is the difference between this certification and the previous?'),
    }

    _order = 'effective desc'
    _defaults = {
        'effective': time.strftime('%Y-%m-%d %H:%M:%S'),
    }

    def copy_cert(self, cr, uid, ids, context=None):
        for rec in self.browse(cr, uid, ids, context):
            self.copy(cr,uid, rec.id , {'effective' : time.strftime('%Y-%m-%d %H:%M:%S'),},context)
        return True
project_medical_cert()

project_view.xml:

    <?xml version="1.0" encoding="utf-8"?>

<openerp>
    <data>
        <record id="view_partner_form" model="ir.ui.view">
            <field name="name">partner.project.form</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <field name="email" position="after">
                    <field name="project_id" string="Project"/>
                    <field name="dob" string="DOB"/>
                    <field name="shift" string="Shift"/>
                </field>
            </field>
        </record>
        <record id="view_project_project_form" model="ir.ui.view">
            <field name="name">project.project.medical.form</field>
            <field name="model">project.project</field>
            <field name="inherit_id" ref="project.edit_project"/>
            <field name="arch" type="xml">
                <field name="user_id" position="after">
                    <field name="client_id" string="Client"/>
                    <field name="status" string="Status"/>
                </field>
                <field colspan="6" name="cert_ids" nolabel="1">
                    <form string="Certification by Doctor">
                        <group col="1" colspan="2">
                            <button name="copy_cert" type="object" string="Duplicate" icon="gtk-ok"/>
                        </group>
                        <field name="effective" string="Effective"/>
                        <field name="note" string="Note" select="1"/>
                    </form>
                </field>
            </field>
        </record>        
        <record id="view_project_project_treeP" model="ir.ui.view">
            <field name="name">project.project.medical.treeP</field>
            <field name="model">project.project</field>
            <field name="inherit_id" ref="project.edit_project"/>
            <field name="arch" type="xml">
                <xpath expr="//notebook/page[@string='Team']" position="before" >
                    <page string="Medical Dates">
                        <field colspan="6" name="cert_ids" nolabel="1">
                            <tree string="Certification by Doctor">
                                <field name="effective" string="Effective"/>
                                <field name="note" string="Note" select="1"/>
                                <field string="OT End" name="ot_cp_end" select="1"/>
                                <field string="PT End" name="pt_cp_end" select="1"/>
                                <field string="ST End" name="st_cp_end" select="1"/>
                            </tree>
                        </field>
                    </page>
                </xpath>
            </field>
        </record>
    </data>
</openerp>

How can I go about determining why cert_ids is not found?

You should post your xml code also.

Sudhir Arya (SA)
on 12/7/13, 11:18 AM

Thanks Sudhir Arya, I've edited the question!

Moore Works, Dale E. Moore
on 12/7/13, 11:52 AM
1
Tony Gu
On 12/8/13, 11:49 PM

sorry, I didn't read your error message carefully. The 'project.project.medical.form' is not defined properly. The 'data' element is not necessary for V7, and the <field colspan="6" name="cert_ids" nolabel="1"> element is not anchored with any element on your parent view. you will either make the previous anchor point include your other view definition in "project.project.medical.form" or make another anchor point like <field name="FieldName" posistion="xxx"> to include your view changes.

Thanks for the thoughts +Tony Gu! There are no records with "SELECT * FROM ir_ui_view WHERE name='project.project.medical.treeP'".

Moore Works, Dale E. Moore
on 12/9/13, 1:36 AM

sorry, I didn't read your error message carefully. The 'project.project.medical.form' is not defined properly. The 'data' element is not necessary for V7, and the <field colspan="6" name="cert_ids" nolabel="1"> element is not anchored with any element on your your parent view. you will either make the previous anchor point include your other view definition in "project.project.medical.form" or make another anchor point like <field name=FieldName posistion=xxx> to include your view changes.

Shine IT Co.,Ltd., Tony Gu
on 12/9/13, 2:00 AM

Thanks +Tony Gu! I was thinking that "position=" in the following "<xpath expr="//notebook/page[@string='Team']" position="before" >" met that need. Does it not? And, I thought that data defined in the ".py" would be created before the error occurred processing the ".xml". Are there any database artifacts for a functional field like cert_ids; something that would prove to me that cert_ids had been created?

Moore Works, Dale E. Moore
on 12/9/13, 9:06 AM

"AssertionError: Did not expect element record there, line 4" occurs when there are no <data> and </data> tags.

Moore Works, Dale E. Moore
on 12/9/13, 9:21 AM

I wonder about the "AttributeError: View definition error for inherited view ''" part of the error message. The empty view name '' has me thinking I've triggered something that discards the inherited view name which seems to appear later in the error message "not found in parent view 'project.edit_project'".

Moore Works, Dale E. Moore
on 12/9/13, 9:24 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

2 follower(s)

Stats

Asked: 12/6/13, 10:57 PM
Seen: 2353 times
Last updated: 3/16/15, 8:10 AM