Odoo Help

0

How to filter list view with m2m relation

By
Ugne
on 6/19/17, 8:51 AM 180 views

I want to filter list view in supply.conditions and show only these values that have a m2m relation with my.request class. I don't know how can I filter it by domain.

class my_request(models.Model):
    _name = 'my.request'
    supply_ids  = fields.Many2many(comodel_name='supply.conditions',
                                              relation='purchase_supply_rel',
                                              column1='purchase_requests_id', column2='supply_conditions_id',
                                              string='Supply Conditions')

class SupplyConditions(models.Model):
    _name = 'supply.conditions'

Function in SupplyConditions class:

@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
    context = self.env.context or {}
    if context.get('search_to_split'):
        args.append(((???????)))
    return super(SupplyConditions, self).search(args, offset, limit, order, count=count)

??????? - here I want to write domain that gives only these values thar have a relation with my_request class.

I tried something like that:

domain = [('supply_ids.ids', '=', self.ids)]

But I feel I am doing wrong. I don't know how else can I filter results I need.... I am going crazy with this m2m relation

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 6/19/17, 8:51 AM
Seen: 180 times
Last updated: 6/19/17, 8:59 AM