Skip to Content
Menú
This question has been flagged
1 Respondre
1950 Vistes

Hello,


i searched everywhere in this forum but i didn't find out what i'm looking for. I need to create a field in the contacts who is related to the Serial number of a single product. How can i do that?

Odoo version: Odoo 13.0+e (Enterprise edition)

Avatar
Descartar

please specify the use case, as it is not clear for which SN, if it's for example for a product that the contact has purchased or???

Best Answer

Hi

Create a custom module and inherit the res.partner model


Python :

from odoo import fields, models

class ResPartner(models.Model):
    _inherit = 'res.partner'  # Inherit the res.partner model

product_id = fields.Many2one('product.product', string='Product')

    product_serial_number = fields.Char(string='Product Serial Number', related='product_id.your required_field)


<!-- res_partner_views.xml -->

<odoo>
<record id="view_res_partner_form_inherit" 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">
            <field name="email" position="after">

                 <field name="product_id"/>
                <field name="product_serial_number"/>
            </field>
        </field>
    </record>
</odoo>

Once you choose a product the related field will be displayed.


Hope it helps

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de febr. 22
2793
2
de juny 25
3519
0
de jul. 21
1279
0
de set. 16
3147
0
de set. 24
940