0
votes
  • A model [m] with a many2many field [m2m]
  • Field [m2m] have attribute [copy=False]
  • A form view [v] display the [m] and the field [m2m] with widget [many2many_tags]

I have tested that the python object did return a with False on field [m2m]

but the javascript, keep render the tags on web.

model.py

class model(models.Model):
    _name = "m"

    m2m = fields.Many2many('sale.order', string="SO", copy=False)

XML File

<record ...>

<form>
<group>
    <field name="name"/>
    <field name="ref"/>
    <field name="so_m2m" widget="many2many_tags" options="{'no_create_edit': True}"/>
    </group>
</form>
</record>

When I duplicate the current record, the field [m2m] is keeps the old tag from old record which is not expected.

After clicking the save button, the old tag will disappear.

1
So here you want something like when you duplicate record then m2m field value should not copy, right ?Keval Mehta
yes, i do not want to copy the value, i have set copy=False, and it did work at the record level, but the UI level tags are copied.Ken Ho
Which kind of tags ? Can you explain what include in term 'tag' as per you ?Keval Mehta
I used the widget many2many_tags to for the field.Ken Ho

1 Answers

0
votes

Try one thing here :

Whatever your third table is there, both fields used in many2many relation, from third table keep them as a copy false.

i.e.

    m2m = fields.Many2many('sale.order','sale_order_another_table_rel', 'sale_order_field','antother_table_field', string="SO", copy=False)

Into new table :

_name = 'sale.order.another.table.rel'
sale_order_field_id = // copy=false
another_table_field_id = //copy = false

Hopefully work.