跳至内容
菜单
此问题已终结
1 回复
2026 查看

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)

形象
丢弃

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

最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
1
2月 22
2871
2
6月 25
3690
0
7月 21
1354
0
9月 16
3215
0
9月 24
1024