This question has been flagged
5 Replies
2438 Views
in_use = fields.Char(string='Active', compute='_area_project')
@api.one
def _area_project(self):
area_project = self.env['battery.rent'].search_count([('state','=','confirmed')])
if area_project :
self.in_use = 'Active'
Avatar
Discard

whats the error or issue

Author

"Invalid value %r in domain term %r" % (right, leaf)

AssertionError: Invalid value battery.rent(8,) in domain term ('equipment_id', '=', battery.rent(8,))

i has change to

@api.one

def _area_project(self):

area_project = self.env['battery.rent'].search([('state','=','confirmed'),('equipment_id','=',self.equipment_ids)])

for data in area_project :

if data :

self.in_use = 'Active'

else :

self.in_use = 'Deactive'

Best Answer

Hello Herry,

Error occur due to trying to access recordset instead of record. Following code may help you.

@api.one
def _area_project(self):
    area_project = self.env['battery.rent'].search([('state','=','confirmed'),('equipment_id','=',self.equipment_ids.ids or [])])

    for data in area_project :
        if data :
           self.in_use = 'Active'
        else :
           self.in_use = 'Deactive'

Thanks,

Avatar
Discard
Author Best Answer

Emipro technoligy,  thank you so much, it's solved, thanks again

@api.one
def _area_project(self):
area_project = self.env['battery.rent'].search([('state','=','confirmed'),('equipment_id','=',self.equipment_ids.id or [])])

for data in area_project :
if data :
self.in_use = 'Active'
else :
self.in_use = 'Deactive'
Avatar
Discard
Best Answer

It seems you lack the condition. I don't check
area_project = self.env['battery.rent'].search(['|',('state','=','confirmed'),('equipment_id','=',self.equipment_ids)])
or

area_project = self.env['battery.rent'].search(['&',('state','=','confirmed'),('equipment_id','=',self.equipment_ids)])

Avatar
Discard