Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
2024 Vizualizări

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)

Imagine profil
Abandonează

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???

Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
feb. 22
2871
2
iun. 25
3688
0
iul. 21
1354
0
sept. 16
3214
0
sept. 24
1023