I want to filter my model based on a Many2One field.
@api.multi
def read(self, fields=None, load='_classic_read'):
ctx = self.env.context.copy()
ctx.update({'equipment_id': self.env['schedone.equipment'].search([]).ids})
result = super(SchedonePlan, self.with_context(ctx)).read(fields=fields, load=load)
return result
This works for search, but if I navigate to the url, I can see every record.
@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
args += [('equipment_id', 'in', self.env['schedone.equipment'].search([]).ids)]return super(SchedonePlan, self).search(args, limit=limit)
I tried something like this, but it doesn't work.