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'
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
5
Replies
2438
Views
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,
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'
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)])
whats the error or issue
"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'