0

my filter no work, because sel.id get value false, i don't now where the error?

    def default_domain_users(self):
        at=[]
        userx = self.env.user.login
        if userx == "name.user":
            ids_biens=self.env['gmat.journaleline'].search([('exp_P','=',0),('rapJor_ids','=',self.id)])
            for item in ids_biens:
                    at.append(item.bien_id.id)
        else:
            ids_biens=self.env['gmat.journaleline'].search([('rapJor_ids','=',self.id)])
            for item in ids_biens:
                at.append(item.bien_id.id)
        return [('id','in', at)]

    user_filter = fields.Many2one('gmat.nbien',domain=default_domain_users)
Charif DZ
  • 14,415
  • 3
  • 21
  • 40
a.CHOURAR
  • 29
  • 4
  • Because the record is not created yet in database, record don't have id yet – Charif DZ Feb 02 '18 at 20:55
  • i sorry, but the record exit in database, – a.CHOURAR Feb 11 '18 at 10:06
  • Yes True but when odoo calls the method he call it with empty record set. Like `api.model` did you try onchange ? – Charif DZ Feb 11 '18 at 12:24
  • but i use domain, how use onchange in my code?, domain call function, the model when i call function with domain (nbien) and this code in model in (rapportjournalier) – a.CHOURAR Feb 13 '18 at 09:31
  • take a look at this: onchange is used to change the domain dynamically in the form view: https://stackoverflow.com/questions/47123563/how-get-id-with-onchange-for-filtering – Charif DZ Feb 13 '18 at 09:34

0 Answers0