Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
6107 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore

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.

Post correlati Risposte Visualizzazioni Attività
0
ago 18
2313
2
set 18
5769
1
apr 18
3255
0
gen 18
3909
0
set 17
3088