Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
24039 Lượt xem

I need a widget many2many (or one2many) with disabled 'Add an item' but NOT READONLY!

Not readonly because I need manipulate sequences by drag and drop. How to do it?

Thanks in advance with the help



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Try to disable it in the tree view. Like this:

<tree create="false">
    <!-- Fields -->
</tree>

The create="false" attribute will hide the "Add an item" action on the one2many / many2many view.

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thank Andre for your very helpful suggestion. Below full solution:

I replace:

 <field name="route_new_ids" widget="many2many" domain="[('product_id','=',id)]"/>

by:

 <field name="route_new_ids" domain="[('product_id','=',id)]" context="{'from_product': True}">
<tree create="false" delete="false">
  <field name="sequence" widget="handle"/>
  <field name="route_id"/>
</tree>
</field>


context="{'from_product': True}" allows to disable, after click on list position, in form view, editions other fields than sequence


Ảnh đại diện
Huỷ bỏ

Great! Glad I could help

Câu trả lời hay nhất

options="{'no_create_edit': True}"

specify this in your many2many field,

<field name="your_field" widget="many2many_tags" options="{'no_create_edit': True}"/>

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 12 24
1084
2
thg 1 23
4749
0
thg 8 23
1442
1
thg 4 16
4415
1
thg 7 24
2293