Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
1805 มุมมอง
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


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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>



อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
Add that display_type field in your O2M field as an invisible.

Hope it's helps you.
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ม.ค. 24
4700
1
ม.ค. 25
1534
odoo exam certificate control แก้ไขแล้ว
2
ก.ย. 24
1286
1
ก.ค. 24
2410
1
ก.ค. 24
1663