Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
1795 Tampilan
steps followed:
1.widget="section_and_note_one2many" add to one2many field
2. context="{'default_display_type': 'line_section'}" for add a section control


From the above code i'm trying to add a section , so the add a section option is reflecting but when i click on it it works same as add a line


Avatar
Buang
Jawaban Terbai

Step 1  .py file:

name = fields.Char('Description')
display_type = fields.Selection(
selection=[
('line_section', "Section"),
],
default=False)

@api.model
def create(self, vals_list):
if vals_list.get('display_type'):
vals_list.update(product_id=False, qty=0)
return super().create(vals_list)

Step 2 .xml file:

<field name="parts_ids" widget="section_and_note_one2many" mode="tree"
context="{'default_display_type': False}">
<tree editable="bottom">
<control>
<create string="Add Line"/>
<create name="add_section_control"
string="Add a section"
context="{'default_display_type':'line_section'}"/>
</control>
<field name="product_id" domain="[('sparce_part', '=', True)]"
required="not display_type"/>
<field name="display_type" column_invisible="1"/>
​</tree>
</field>



Avatar
Buang
Jawaban Terbai
Add that display_type field in your O2M field as an invisible.

Hope it's helps you.
Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
0
Jan 24
4693
1
Jan 25
1530
2
Sep 24
1286
1
Jul 24
2402
1
Jul 24
1660