Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
23186 Переглядів

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}"/>

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
груд. 24
461
2
січ. 23
3918
0
серп. 23
883
1
квіт. 16
3846
1
лип. 24
1173