Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5 ตอบกลับ
4842 มุมมอง

Hello, i'm using odoo8, and need to inherit "view_partner_form" and add a page inside notebook tag:
My record in xml view is : 

<record model="ir.ui.view" id="respartner_viewform">
<field name="name">respartner_form</field>
<field name="model">respartner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
         <form><xpath expr="/form/sheet/notebook" position="inside">
            <page string="Management System">
                 <group>
                     <field name="partnerform_ids" widget="one2many_list">
                         <tree >
                             <field name="id_type"/>
                             <field name="id_product"/>
                             <field name="valdate"/>
                        </tree>
                    </field>
                 </group>
 </page>
</xpath>
</form>
 </field>
</record>


And my module is : 

class respartner(models.Model):

    _name='respartner'

    _inherit='res.partner'

     partnerform_ids=fields.One2many('partnerform','id_partner',string="respartners")


But i get the following error : 

File "C:\Program Files (x86)\Odoo 8.0-20160715\server\openerp\models.py", line 1271, in _validate_fields raise ValidationError('\n'.join(errors))ParseError: "ValidateErrorField(s) `arch` failed against a constraint: Invalid view definition" while parsing file:///C:/Program Files (x86)/Odoo 8.0-20160715/server/openerp/addons/mgmsys/mgmsys.xml:28, near<record model="ir.ui.view" id="respartner_viewform"><field name="name">respartner_form</field><field name="model">respartner</field><field name="inherit_id" ref="base.view_partner_form"/> <field name="arch" type="xml"> <form><xpath expr="/form/sheet/notebook" position="inside"> <page string="Management System"> <group> <field name="partnerform_ids" widget="one2many_list"> <tree> <field name="id_type"/> <field name="id_product"/> <field name="reqdate"/> <field name="recdate"/> <field name="valdate"/> </tree> </field> </group> </page></xpath> </form> </field></record>


It must be a problem in xpath tag, but still can't figure it out ! 

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด
hank you ! the problems was in using the right module ! my mistake( beginner )Xpath does work ! .
<record model="ir.ui.view" id="respartner_viewform">
<field name="name">respartner_form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/> <field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="sys">
 <group>
 <field name="partnerform_ids" widget="one2many_list">
<tree editable="bottom" >
 <field name="id_type"/>
 <field name="id_product"/>
 <field name="valdate"/>
</tree> </field>
 </group>
 </page>
</xpath>
</field></record>
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

In Odoo/OpenERP we can inherit or use existing modules object/class/model and views. We can also inherit single field of existing modules. The question is why we need such inheritance.

The purpose of inheritance or why we need inheritance is given below:

  1. To change attributes of some fields which exists on existing/custom model (e.g. making fields readonly,invisible)

  2. To add/modify/delete old or new fields in existing/custom model (e.g. Product, Sales, HR, Fleet Management, Attendance modules model etc)

  3. We can also add buttons in already existing/custom model (form and tree) view by using inheritance

To get complete guidance about xpath and inheritance in odoo read: http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

This is not a proper way to inherit views.

try like this,

your_module.py

class respartner(models.Model):
     _inherit='res.partner'
     partnerform_ids=fields.One2many('partnerform','id_partner',string="respartners")

your_view.xml

<record id="respartner_inherit_viewform" model="ir.ui.view">			
    <field name="name">respartner_inherit_form</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
        <notebook position="inside">
            <page string="Management System">
                <group>
                    <field name="partnerform_ids" widget="one2many_list">
                        <tree>
                            <field name="id_type"/>
                            <field name="id_product"/>
                            <field name="valdate"/>
                        </tree>
                    </field>
                </group>
            </page>
        </notebook>
    </field>
</record>

 I hope this will help you.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
xpath problems with string แก้ไขแล้ว
3
มิ.ย. 16
9058
0
เม.ย. 24
1726
4
พ.ย. 23
5739
0
ต.ค. 23
1476
0
ธ.ค. 22
2415