Skip to Content
Menu
This question has been flagged

Is there a way to have a default filter that is passed by a method? I know that I can add a filter with @on.change, but the problem is that I won't have any field to change. The filter has to be as a default value. The lambda won't cut it. having a computed field that I use it then in the domain filter won't work as well.

I need a filter that returns ids of used records, and then show only the projects that are not used.

So the domain should be generated as example [('project_id', 'not in', [1,2,4,8,10]), ('analytic_account_id.parent_project_id', '=', self.partner_id)]. 

My model:

free_hours = fields.Float(string='Free hours', compute='_get_free_hours')
start_date = fields.Date(string='Start date')

partner_id = fields.Many2one('res.partner', string='Contact', required=True, ondelete='cascade')
project_ids = fields.Many2many( comodel_name='project.project', relation='project_pvz_hours_rel', column1='pvz_hours_id', column2='project_id', string='Project' )
Avatar
Discard
Related Posts Replies Views Activity
0
Jul 22
732
1
Nov 19
5176
0
Aug 20
1416
1
Jul 19
4042
2
May 17
10098