onchange_storage_device(self, cr, uid, ids, storage_type, context=None):
if storage_type:
storage_type = self.pool.get('archive.storage.type').browse(cr, uid, storage_type, context=context)
cr.execute("""select max(CAST(nullif(split_part(name, '-', 2), '') AS integer)) from archive_storage WHERE storage_device= %d""", (storage_type,))
sn = cr.fetchone()[0]
return {'value': {'name': storage_type.name + str( "%05d"% sn+1)}}
return {'value': {}}
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
1
Reply
6644
Views
Try to put storage_type.id instead of storage_type at the end of your statement like this
cr.execute("""select max(CAST(nullif(split_part(name, '-', 2), '') AS integer)) from archive_storage WHERE storage_device= %d""", (storage_type.id,))
Query engine does not recognize orm class, and you passed storage_type in params, it should rather be the id viz storage_type.id