I would like to automatically cancel the selection of a value in a many2one field when I click for example on the invisible radio button of the interface client:
model.py file:
........
Product_id = fields.Many2one(‘product.template’)
State = fields.Selection((( ‘H’, ‘Hide’), (‘S’, ‘show’)), string=“state”)
hide_product = fields.Boolean()
@api.onchange
def _cancel_selection(self):
If ( self.state is ‘H’):
# cancel selection automatically on product_id field
Hide_product = True
Self.product_id = “ “
............
view.xml file:
..........
< field name=“State” on_change=“1” />
< field name=“product_id” attrs=“{‘invisible’ : [ (‘hide_product’, ‘=‘, True) ] } “ />
......
what means cancel the selection ? reset product_id field data or set product_id field readonly or Hide.
Reset product_id field data