Hi. How can i add a new field in contact form? I have already this py file but is not working.
from odoo import models, fields, api
class ResPartner(models.Model):
_inherit = 'res.partner'
document_nit = fields.Char(string="NIT", required=True)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi. How can i add a new field in contact form? I have already this py file but is not working.
from odoo import models, fields, api
class ResPartner(models.Model):
_inherit = 'res.partner'
document_nit = fields.Char(string="NIT", required=True)
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
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
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
Thank you both! I just upgraded the module through CLI , now I have the new field.
Regards