问题
I am starting developing openerp modules. What could be wrong with the following code:
custmercas.py
# encoding: utf-8
from openerp.osv import osv,fields
class cas_customercas(osv.osv):
_name = 'cas.customercas'
_columns = {
'cas_lastname':fields.char('اللقب', size=50, required=True, readonly=False),
'cas_firstname':fields.char('الإسم', size=50, required=True, readonly=False),
#TODO : import time required to get currect date
'cas_datenaiss': fields.date('تاريخ الولادة'),
'cas_lieunaiss':fields.char('مكان الولادة', size=100, required=False, readonly=False),
'cas_cin': fields.integer('رقم بطاقة التعريف الوطنية'),
'cas_lieu_cin':fields.char('مكان اصدارها', size=64, required=False, readonly=False),
'color': fields.integer('Color'),
#TODO : import time required to get currect date
'cas_datecin': fields.date('تاريخ اصدارها'),
'cas_photo':fields.binary('صورة', filters=None),
'cas_ref':fields.char('المعرف', size=6, required=True, readonly=False),
'cas_sexe':fields.char('الجنس', size=10, required=False, readonly=False),
'cas_pere_id':fields.many2one('cas.customercas', 'الأب', required=False),
'cas_mere_id':fields.many2one('cas.customercas', 'الأم', required=False),
'cas_telcontacts_ids':fields.one2many('cas.telcontacts', 'cas_customercas_id','قائمة الهواتف', required=False),
'cas_etatcivil_ids':fields.one2many('cas.customercas.etatcivile', 'cas_customercas_id', 'الحالة المدنية', required=False),
'cas_adr_ids':fields.one2many('cas.customercas.address', 'cas_adr_customercas_id', 'عناوين الحالات', required=False),
'cas_boulot_ids':fields.one2many('cas.customercas.boulotsinfo', 'cas_boulot_customercas_id', 'الشغل', required=False),
'cas_visite_ids':fields.one2many('cas.customercas.visite', 'cas_visite_customercas_id', 'الزيارات', required=False),
'cas_aide_ids':fields.one2many('cas.customercas.aide', 'cas_aide_customercas_id', 'المساعدات', required=False),
'cas_logement_ids':fields.one2many('cas.customercas.logement', 'cas_logement_customercas_id', 'المسكن', required=False),
}
customarcas_view.xml
<?xml version="1.0" ?>
<openerp>
<data>
<record model="ir.ui.view" id="cas_customercas_view_graph">
<field name="name">cas.customercas</field>
<field name="model">cas.customercas</field>
<field name="arch" type="xml">
<graph string="Graph View" type="pie">
<field name="cas_cin" />
</graph>
</field>
</record>
<record model="ir.ui.view" id="cas_customercas_kanban_view">
<field name="name">cas.customercas Kanban</field>
<field name="model">cas.customercas</field>
<field name="arch" type="xml">
<kanban>
<field name="cas_photo" />
<field name="cas_lastname" />
<field name="cas_firstname" />
<templates>
<t t-name="kanban-box">
<div class="oe_employee_vignette">
<div class="oe_employee_image">
<a data-type="open" href="#" class=" oe_kanban_action oe_kanban_action_a">
<img t-att-src="kanban_image('cas.customercas', 'cas_photo', record.id.value)" class="oe_employee_picture" />
</a>
</div>
<div class="oe_employee_details">
<h4>
<a data-type="open" href="#" class=" oe_kanban_action oe_kanban_action_a">
<b>
<field name="cas_ref" />
</b>
<t t-if="record.cas_lastname.raw_value">
-
<b>
<t t-esc="record.cas_firstname.value" />
<field name="cas_lastname" />
</b>
</t>
</a>
</h4>
</div>
</div>
<script> $('.oe_employee_picture').load(function() { if($(this).width() > $(this).height()) { $(this).addClass('oe_employee_picture_wide') }
});
</script>
</t>
</templates>
</kanban>
</field>
</record>
<record model="ir.ui.view" id="cas_customercas_tree_view">
<field name="name">cas.customercas.tree</field>
<field name="model">cas.customercas</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Liste des cas sociaux">
<field name="cas_lastname" />
<field name="cas_firstname" />
<field name="cas_datenaiss" />
<field name="cas_lieunaiss" />
<field name="cas_ref" />
<field name="cas_photo" widget="image" />
<field name="cas_pere_id" />
<field name="cas_mere_id" />
</tree>
</field>
</record>
<record model="ir.ui.view" id="cas_customercas_form_view">
<field name="name">cas.customercas.form</field>
<field name="model">cas.customercas</field>
<field name="priority" eval="8" />
<field name="arch" type="xml">
<form string="OpenERP Version 9" version="9.0">
<sheet>
<group colspan="4" col="4">
<field name="cas_ref" modifiers="{}" />
<field name="cas_cin" modifiers="{}" />
<field name="cas_datecin" modifiers="{}" />
<field name="cas_lieu_cin" modifiers="{}" />
<field name="cas_lastname" modifiers="{}" />
<field name="cas_firstname" modifiers="{}" />
<field name="cas_datenaiss" modifiers="{}" />
<field name="cas_lieunaiss" modifiers="{}" />
<field name="cas_mere_id" string="الأم" modifiers="{}" />
<field name="cas_pere_id" string="الأب" modifiers="{}" />
<field name="cas_sexe" modifiers="{}" string="الجنس" />
<field name="cas_photo" modifiers="{}" widget="image" />
</group>
<notebook>
<page string="قائمة الهواتف">
<group colspan="4" col="4">
</group>
<field name="cas_telcontacts_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'cas_telcontact_form_view'}"/>
</page>
<page string="الحالة المدنية">
<group colspan="4" col="4">
</group>
<field name="cas_etatcivil_ids" nolabel="1" colspan="3" modifiers="{'readonly': true}" context="{'form_view_ref': 'customercas_etatcivil_tree_view'}"/>
</page>
<page string="عناوين الحالات">
<group colspan="4" col="4">
</group>
<field name="cas_adr_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'customercas_adr_form_view'}"/>
</page>
<page string="الشغل">
<group colspan="4" col="4">
</group>
<field name="cas_boulot_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'customercas_boulot_form_view'}"/>
</page>
<page string="الزيارات">
<group colspan="4" col="4">
</group>
<field name="cas_visite_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'customercas_visite_form_view'}"/>
</page>
<page string="المساعدات">
<group colspan="4" col="4">
</group>
<field name="cas_aide_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'customercas_aide_form_view'}"/>
</page>
<page string="لسكن">
<group colspan="4" col="4">
</group>
<field name="cas_logement_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'customercas_logement_form_view'}"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="cas_customercas_search_view" model="ir.ui.view">
<field name="name">cas.customercas.search</field>
<field name="model">cas.customercas</field>
<field name="arch" type="xml">
<search string="Search">
<field name="cas_lastname" string="اللقب" filter_domain="[()]" />
<separator />
<filter string="اللقب" name="cas_lastname" domain="[('cas_lastname','!=','g')]" />
<group expand="0" string="Group By...">
<filter string="اللقب" domain="[]" context="{'group_by':'cas_lastname'}" />
</group>
</search>
</field>
</record>
</data>
</openerp>
I am getting the error: ValidateError Error occurred while validating the field(s) ParseError: "Invalid view definition!What could be the problem?
Odoo Server Error
Traceback (most recent call last):
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\http.py", line 643, in _handle_exception
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\http.py", line 680, in dispatch
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\http.py", line 316, in _call_function
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\service\model.py", line 118, in wrapper
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\http.py", line 309, in checked_call
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\http.py", line 959, in __call__
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\http.py", line 509, in response_wrap
File "C:\Program Files\Odoo 9.0-20160413\server\openerp\addons\web\controllers\main.py", line 896, in call_button
File "C:\Program Files\Odoo 9.0-20160413\server\openerp\addons\web\controllers\main.py", line 884, in _call_kw
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\api.py", line 250, in wrapper
File "C:\Program Files\Odoo 9.0-20160413\server\openerp\addons\base\module\module.py", line 459, in button_immediate_install
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\api.py", line 250, in wrapper
File "C:\Program Files\Odoo 9.0-20160413\server\openerp\addons\base\module\module.py", line 533, in _button_immediate_function
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\modules\registry.py", line 386, in new
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\modules\loading.py", line 338, in load_modules
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\modules\loading.py", line 237, in load_marked_modules
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\modules\loading.py", line 156, in load_module_graph
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\modules\loading.py", line 98, in _load_data
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\tools\convert.py", line 851, in convert_file
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\tools\convert.py", line 938, in convert_xml_import
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\tools\convert.py", line 801, in parse
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\tools\convert.py", line 804, in parse
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\tools\convert.py", line 708, in _tag_record
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\api.py", line 250, in wrapper
File "C:\Program Files\Odoo 9.0-20160413\server\openerp\addons\base\ir\ir_model.py", line 1142, in _update
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\api.py", line 250, in wrapper
File "C:\Program Files\Odoo 9.0-20160413\server\openerp\addons\base\ir\ir_ui_view.py", line 351, in create
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\api.py", line 250, in wrapper
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\api.py", line 354, in old_api
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\models.py", line 4150, in create
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\api.py", line 248, in wrapper
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\api.py", line 490, in new_api
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\models.py", line 4341, in _create
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\api.py", line 248, in wrapper
File "C:\Program Files\Odoo 9.0-20160413\server\.\openerp\models.py", line 1271, in _validate_fields
ParseError: "Invalid view definition
D\xe9tails de l'erreur :
Le champ `cas_boulot_ids` n'existe pas
Contexte de l'erreur :
Vue `cas.customercas.form`
[view_id: 916, xml_id: n/a, model: cas.customercas, parent_id: n/a]
None" while parsing file:///C:/Program%20Files/Odoo%209.0-20160413/server/openerp/addons/academy/views/contentview/customercas_view.xml:87, near
<record model="ir.ui.view" id="cas_customercas_form_view">
<field name="name">cas.customercas.form</field>
<field name="model">cas.customercas</field>
<field name="priority" eval="8"/>
<field name="arch" type="xml">
<form string="OpenERP Version 9" version="9.0">
<!-- <header> <button name="action_button" string="gooo" type="object" class="oe_highlight" /> </header> -->
<sheet>
<group colspan="4" col="4">
<field name="cas_ref" modifiers="{}"/>
<field name="cas_cin" modifiers="{}"/>
<field name="cas_datecin" modifiers="{}"/>
<field name="cas_lieu_cin" modifiers="{}"/>
<field name="cas_lastname" modifiers="{}"/>
<field name="cas_firstname" modifiers="{}"/>
<field name="cas_datenaiss" modifiers="{}"/>
<field name="cas_lieunaiss" modifiers="{}"/>
<field name="cas_mere_id" string="الأم" modifiers="{}"/>
<field name="cas_pere_id" string="الأب" modifiers="{}"/>
<field name="cas_sexe" modifiers="{}" string="الجنس"/>
<field name="cas_photo" modifiers="{}" widget="image"/>
</group>
<notebook>
<page string="قائمة الهواتف">
<group colspan="4" col="4">
</group>
<field name="cas_telcontacts_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'cas_telcontact_form_view'}"/>
</page>
<page string="الحالة المدنية">
<group colspan="4" col="4">
</group>
<field name="cas_etatcivil_ids" nolabel="1" colspan="3" modifiers="{'readonly': true}" context="{'form_view_ref': 'customercas_etatcivil_tree_view'}"/>
</page>
<page string="عناوين الحالات">
<group colspan="4" col="4">
</group>
<field name="cas_adr_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'customercas_adr_form_view'}"/>
</page>
<page string="الشغل">
<group colspan="4" col="4">
</group>
<field name="cas_boulot_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'customercas_boulot_form_view'}"/>
</page>
<page string="الزيارات">
<group colspan="4" col="4">
</group>
<field name="cas_visite_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'customercas_visite_form_view'}"/>
</page>
<page string="المساعدات">
<group colspan="4" col="4">
</group>
<field name="cas_aide_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'customercas_aide_form_view'}"/>
</page>
<page string="لسكن">
<group colspan="4" col="4">
</group>
<field name="cas_logement_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'customercas_logement_form_view'}"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
回答1:
Form the shared log at present i can just suggest you a general approach for debugging the problem associate with models
and fields
.
If you are getting the Error Like :
The field_abc does not exit
orreturn self.models[model_name] KeyError: 'model.abc
Please go through step 1 and 2 for finding the model_abc:cas.customercas
and step 3 for for finding field_abc:cas_boulot_ids
:
- Check your
__init__.py
and must ensure thatmodels.py(in this case custmercas.py)
should be there . - Now Open the menu of ir.model and
search
your model name. - Now open the record of model and find the
field name
or just open the view ofir.model.fields
and search the field here.
IF you have go through of 3 mention steps and not seeing field
in the view of ir.model.fields
and model in the view of ir.model
then just do two more step:
- Restart your odoo server
- Upgrade the module
Now again follow the step 1 to 2 for debugging return self.models[model_name] KeyError: 'model.abc
and step 3 for debugging The field_abc does not exit
.
You can go through this link for visual details (ODOO8) .
I hope this may help you in debugging the issue .
来源:https://stackoverflow.com/questions/36618984/parseerror-invalid-view-definition