Skip to main content

Add a Custom Field to Contact Form in Odoo

The Partner in Odoo is a model that represents an entity with which the company deals. It can be a customer, supplier, internal user, or any other person with whom you interact. Partners can be either individuals or companies.

Would you like to add a custom field to the Contacts form in Odoo? This tutorial will show you how to add a field to res.partner model and show it in the view. Adding a custom field to the Contact form can be helpful for tracking additional information about your contacts, such as their job title or department.

class ResParner(models.Model):
    _inherit = 'res.partner'

    reference_code = fields.Char(string='Reference Code')

Then we show the field after VAT one:

<record model="ir.ui.view" id="view_res_partner_form_inherit">
    <field name="name">module.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='vat']" position="after">
            <field name="reference_code"/>

By continuing to use the site, you agree to the use of cookies.