Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
2171 Widoki

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)

Awatar
Odrzuć

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

Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lut 22
3037
2
cze 25
3951
0
lip 21
1554
0
wrz 16
3421
0
wrz 24
1217