跳至內容
選單
此問題已被標幟
4 回覆
24073 瀏覽次數

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



頭像
捨棄
最佳答案

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.

頭像
捨棄
作者 最佳答案

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


頭像
捨棄

Great! Glad I could help

最佳答案

options="{'no_create_edit': True}"

specify this in your many2many field,

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
12月 24
1106
2
1月 23
4768
0
8月 23
1451
1
4月 16
4431
1
7月 24
2306