This question has been flagged
1 Reply
2823 Views

I have written this code here

'name_job_card_flow' is a field name so whatever value inside this field that should display.But here it is treating as string then it is matching the values which is equal to string like 'name_job_card_flow'

so anyone here help me how to give field name as a value in search domain?

res=self.env['vehicle.time.card.table'].search([('name_job_card_flow_id.name_job_card_flow','i=','name_job_card_flow')])

 

Avatar
Discard
Best Answer

There are two way

Create a related field name_job_card_flow in model  vehicle.time.card.table as Below

name_job_card_flow =fields.Char(related = 'name_job_card_flow_id.name_job_card_flow',store=1)

And make the search query :

res=self.env['vehicle.time.card.table'].search([('name_job_card_flow','i=','name_job_card_flow')])

Or  Use filtered :

domain=[]
card_tables=self.env['vehicle.time.card.table'].search(domain)
res=card_tables.filtered(lambda table:
table.name_job_card_flow_id.name_job_card_flow
!=='name_job_card_flow' )


Hope i may help in your case.

Avatar
Discard