Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
6285 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Autor

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 Odpovědi Zobrazení Aktivita
0
srp 18
2436
2
zář 18
5938
1
dub 18
3383
0
led 18
4090
0
zář 17
3227