İçereği Atla
Menü
Bu soru işaretlendi
4 Cevaplar
24400 Görünümler

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



Avatar
Vazgeç
En İyi Yanı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.

Avatar
Vazgeç
Üretici En İyi Yanı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


Avatar
Vazgeç

Great! Glad I could help

En İyi Yanıt

options="{'no_create_edit': True}"

specify this in your many2many field,

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

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Eyl 25
1457
2
Oca 23
5078
0
Ağu 23
1683
1
Nis 16
4686
1
Tem 24
2600