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

I have a new module that depends on crm.lead, and I want to display the fields of the new module in its list view. How can I do this? Currently, it seems to only show the fields from the original module.

아바타
취소
베스트 답변

Hi,

Please refer to the code below:

Python


from odoo import models, fields

class CrmLead(models.Model):
_inherit = 'crm.lead'

x_custom_field = fields.Char(string="Custom Field")
# Add Your Custom fields

XML:

<record id="view_crm_lead_tree_custom" model="ir.ui.view">
<field name="name">crm.lead.tree.inherit.custom</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_leads_view_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="x_custom_field"/>
</xpath>
</field>
</record>


Hope it helps.

아바타
취소
베스트 답변

To show your custom fields in the crm.lead list view, you need to inherit the tree view and add your fields.
<record id="crm_lead_tree_view_custom" model="ir.ui.view">

    <field name="name">crm.lead.tree.view.custom</field>

    <field name="model">crm.lead</field>

    <field name="inherit_id" ref="crm.crm_lead_view_tree"/>

    <field name="arch" type="xml">

        <xpath expr="//tree" position="inside">

            <field name="x_custom_field"/>

        </xpath>

    </field>

</record>

Make sure your model extension correctly adds the new fields:
from odoo import models, fields


class CrmLead(models.Model):

    _inherit = 'crm.lead'


    x_custom_field = fields.Integer(string="Another Field")


아바타
취소
관련 게시물 답글 화면 활동
0
5월 25
694
0
8월 24
1020
2
3월 24
1320
1
7월 22
2646
0
5월 22
1667