ParseError:“视图定义无效”

时间:2016-04-14 09:30:01

标签: python openerp odoo-9

我开始开发openerp模块。以下代码可能有什么问题:

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>

我收到错误:ValidateError验证字段时发生错误ParseError:“视图定义无效!可能是什么问题?

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="&#1575;&#1604;&#1571;&#1605;" modifiers="{}"/>
                            <field name="cas_pere_id" string="&#1575;&#1604;&#1571;&#1576;" modifiers="{}"/>
                            <field name="cas_sexe" modifiers="{}" string="&#1575;&#1604;&#1580;&#1606;&#1587;"/>
                            <field name="cas_photo" modifiers="{}" widget="image"/>
                        </group>
                        <notebook>
                            <page string="&#1602;&#1575;&#1574;&#1605;&#1577; &#1575;&#1604;&#1607;&#1608;&#1575;&#1578;&#1601;">
                                <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="&#1575;&#1604;&#1581;&#1575;&#1604;&#1577; &#1575;&#1604;&#1605;&#1583;&#1606;&#1610;&#1577;">
                                <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="&#1593;&#1606;&#1575;&#1608;&#1610;&#1606; &#1575;&#1604;&#1581;&#1575;&#1604;&#1575;&#1578;">
                                <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="&#1575;&#1604;&#1588;&#1594;&#1604;">
                                <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="&#1575;&#1604;&#1586;&#1610;&#1575;&#1585;&#1575;&#1578;">
                                <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="&#1575;&#1604;&#1605;&#1587;&#1575;&#1593;&#1583;&#1575;&#1578;">
                                <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="&#1604;&#1587;&#1603;&#1606;">
                                <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 个答案:

答案 0 :(得分:0)

目前形成共享日志我可以建议您调试与modelsfields相关联的问题的一般方法。

如果您收到错误消息:

  

The field_abc does not exitreturn self.models[model_name] KeyError: 'model.abc

请通过第1步和第2步查找model_abc:cas.customercas,第3步查找field_abc:cas_boulot_ids

  1. 检查您的__init__.py,并确保models.py(in this case custmercas.py)应该在那里。
  2. 现在打开ir.modelsearch您的型号名称的菜单。
  3. 现在打开模型记录并找到field name或只打开ir.model.fields的视图并在此处搜索字段。
  4. 如果您完成了3个提及步骤而未在field view of ir.model.fieldsview of ir.model中看到return self.models[model_name] KeyError: 'model.abc,那么请再做两步:

    • 重新启动odoo服务器
    • 升级模块

    现在再次按照步骤1到2进行调试The field_abc does not exit,再按步骤3进行调试object

    You can go through this link for visual details (ODOO8) .

    我希望这可以帮助您调试问题。