Odooers论坛

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Add new field in contacts.

形象
odoo
1 备注
形象
丢弃
形象
odoo
-

Thank you both! I just upgraded the module through CLI , now I have the new field. 

Regards

2 答案
0
形象
odoo
最佳答案

Hi,

This is how we can add fields to any model by inheriting. I think, here you may be facing field does not exist error right ?

 If this is the case and if this happens on adding new field to partner model in an installed module, you should upgrade the module from command line by passing -u module_name

See: https://www.youtube.com/watch?v=c7QL1X3-Zlc

Thanks

形象
丢弃
0
形象
odoo
最佳答案

Hi kevin,

For adding a new field in the contact form first inherit the model and add corresponding field to it in python.After that add its view. find its external id of the corresponding view and add it on xml.

For example:

In python:

from odoo import models, fields, api
class ResPartner(models.Model):
    _inherit = 'res.partner'
    document_nit = fields.Char(string="NIT", required=True)

In xml:

<?xml version="1.0"?>


<odoo>


    <record id="partner_form" model="ir.ui.view">


         <field name="name">res.partner.form.inherit</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='category_id']" position="after">


              <field name="document_nit"/>


             </xpath>


         </field>


    </record>


</odoo>


Regards

形象
丢弃