Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
1785 Представления
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
4683
1
янв. 25
1521
2
сент. 24
1272
1
июл. 24
2392
1
июл. 24
1652