Please i have this python class:
class class4(models.Model):
_inherit = 'sale.order.line'
categorie = fields.Many2one('module.categorie')
list1 = []
# item = fields.Many2one('module.item', domain=[('id','=',[1,2])])
item = fields.Many2one('module.item', domain=[('id','=',list1)])
items = fields.Char()
@api.onchange('categorie')
def onchange_method(self):
print(self.categorie.name,'changed !')
res = {}
items_list = []
self.list1 = []
records = self.env['module.categorieitem'].search([('name','=',self.categorie.id)])
# for record in records:
# print(record.item.name)
# items_list.append(record.item.name)
for record in records:
print(record.item.id)
items_list.append(record.item.id)
self.items = items_list
self.list1 = items_list
print('list1: ',self.list1)
res['domain'] = {'item': [('id', 'in', items_list)]}
return res
How to set value of list1 = items_list and pass it in domain attribute to keep filter of items iven if i refresh page and not on-change method