Ken Ho
Ken Ho

Reputation: 3

Odoo duplicate many2many fields

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.

Upvotes: 0

Views: 1123

Answers (1)

Keval Mehta
Keval Mehta

Reputation: 664

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.

Upvotes: 0

Related Questions