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

How can I add custom fields to inherited Models and views when I Tried to add it is throwing an Parse Error solve this

ParseError: "Error while validating constraint

Field `district` does not exist

Error context:
View `res.partner`
[view_id: 1094, xml_id: n/a, model: res.partner, parent_id: 124]
None" while parsing file:///c:/program files (x86)/odoo 10.0/server/odoo/addons/localizationindonesia/views/partner.xml:4, near
<record id="add_new_partner" model="ir.ui.view">
            <field name="name">res.partner</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
              <field name="country_id" position="after">
                <field name="district" placeholder="District"/>
              </field>
            </field>
    </record>


I tried to add like this

In Model

class ResPartner(models.Model):

    _name = 'res.partner'
    _inherit = 'res.partner'
    district = fields.Char(string='district', Size=32)

In Xml:

<record id="add_new_partner" model="ir.ui.view">
            <field name="name">res.partner</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
              <xpath expr="//field[@name='country_id']" position="after">
                <field name="district" placeholder="district"/>
              <xpath/>
            </field>
    </record>
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

were you able to solve the issue? if yes, how?


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

Read this link.I hope it will be help you.

https://stackoverflow.com/questions/34490479/odoo-9-field-does-not-exist

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

You must do an module update  to add the field to 'res.partner' model. All that if  your field decalaration is done in a base class ResPartner not a custom added class.

อวตาร
ละทิ้ง
ผู้เขียน

Thanks for that, Can you elaborate it with code so I see the difference, As I am new to Odoo this is the first module I am customizing

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 17
167
1
พ.ย. 19
4865
2
ก.ค. 19
5138
0
พ.ค. 19
3236
1
เม.ย. 19
4079