Skip to Content
Menú
This question has been flagged
2 Respostes
126 Vistes

Hello,

I am trying to identify the correct Odoo term for the view when creating a delivery address in contacts. I mean the small view.

I want to inherit the view and add a custom field.


Thank you for your help!

Avatar
Descartar
Best Answer

Hi,


The correct Odoo term for the delivery address form view in contacts is view_partner_address_form. To confirm, activate developer mode, inspect the view, and find its External ID.


To inherit this view and add a custom field, create a custom module with a __manifest__.py file that depends on the base module. In models.py, inherit the res.partner model and add your custom field. In views.xml, create a record that inherits base.view_partner_address_form and use an XPath expression to position your custom field within the inherited view. Install the module to apply the changes.


Eg:

Python


from odoo import models, fields


class ResPartner(models.Model):

    _inherit = 'res.partner'


    my_custom_field = fields.Char(string="My Custom Field")


XML


<odoo>

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

        <field name="name">res.partner.address.form.inherit</field>

        <field name="model">res.partner</field>

        <field name="inherit_id" ref="base.view_partner_address_form"/>

        <field name="arch" type="xml">

            <xpath expr="//field[@name='city']" position="after">

                <field name="my_custom_field"/>

            </xpath>

        </field>

    </record>

</odoo>


Hope it helps

Avatar
Descartar
Best Answer

Hi, 
It's hard to understand what you're referring to. What about a screenshot? 

If I understood it correctly though, you might be looking for <record id="view_partner_address_form"

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de març 15
4908
1
d’abr. 22
7466
3
de nov. 25
349
2
d’ag. 25
915
1
de maig 25
1952