콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2221 화면

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
3088
2
6월 25
4020
0
7월 21
1596
0
9월 16
3496
0
9월 24
1260