Skip to Content
Menu
This question has been flagged
1 Reply
2567 Views

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.

Avatar
Discard
Best Answer

I have same issue on Odoo v11 You already have solution?

Avatar
Discard
Related Posts Replies Views Activity
2
Dec 23
11994
0
Oct 23
33
3
Oct 23
787
1
Oct 23
569
1
Aug 23
979