This question has been flagged
1 Reply
9164 Views

I need to clear "many2many" fields value, So i tried these code but it does not empty the field

My Code:

            purchase_id = fields.Many2many(

                        'purchase.order',

                        string='Purchase Order',

                        store=False,

                        readonly=True,

                        help='Associated Purchase Order. Filled in automatically when a PO is chosen on the vendor bill.'

             )


            @api.onchange('purchase_id')

            def _onchage_purchase(self):

            self.purchase_id = [6, 0, []] 


I tried like this, but it doesn't works.. Please, can anyone help me to resolve this.

Avatar
Discard
Best Answer

Hi,

Check this link : https://www.odoo.com/forum/help-1/question/removing-elements-from-many2many-field-122928


Avatar
Discard
Author

I referred and tried the methods given from this link.. But still i can't get the result

Check if the onchange function is being called by just putting a print .

if try this :

self.purchase_id = [(6, 0, [])]