Skip to Content
Menu
This question has been flagged
1 Reply
5036 Views

I have a m2m field in my custom module, in the py file i have these:

product = fields.Many2many('stock.quant', string="Product")

in the xml:

<notebook>

    <page string="Product">

          <field name="product" options="{'no_open':True, 'no_quick_create': True, 'no_create_edit': True, 'no_create': True}" domain="[('lot_id','!=', context.get('lot_id', False)), ('state', '=', 'buffer')]">

                   <tree open="false" editable="bottom">

                         <field name="product_id"/>

                          <field name="lot_id"/>

                          <field name="state" />   

                   </tree>

          </field>

    </page>

</notebook>

It works fine when i add an item but when I started editing the state column of the m2m to active, after clicking the Save button, the item disappears in the form. I have a screenshot below:

1st

https://pasteboard.co/GL3pDg2.png

2nd

https://pasteboard.co/GL3pMHs.png

3rd (the item disappeared after saving)

https://pasteboard.co/GL3pTKJ.png

Avatar
Discard
Best Answer

Hello Sarah Meh,

In your scenario, You added domain  domain="[('lot_id','!=', context.get('lot_id', False)), ('state', '=', 'buffer')]"

focus on both the domain condition:
you added domain State='buffer', and you select 'active' state in the record. so the based on the domain it will remove from records.

If you want to visible record in that tree so remove the condition ('state', '=', 'buffer') from the domain.

Thanks

Avatar
Discard
Author

I need the ('state', '=', 'buffer') to filter the values shown in the many2many field. I already removed it before but the values added in the field is still not showing. I think it's not in the domain filter condition.

Related Posts Replies Views Activity
0
Aug 18
1571
2
Sep 18
4785
1
Apr 18
2473
0
Jan 18
3088
0
Sep 17
2433