Hello. I am new to OpenERP and i am trying to build a function in class library.book which is supposed to output the number of book that are reserved by the students (which means the number of books that are registered in the class library.reservation). But even the raise I have build output correctly the number of reserved books for each book, the function does not output anything in the field i have build for it. Further more when I write the function all the books disappeared from the list and the tree view of the class library.function is empty.
Here is the function i have build:
def _book_available(self, cr, uid, ids, name, args, context=None):res={}books = self.browse(cr, uid, ids, context=context)for book_avail in books:book_ids=self.pool.get('library.reservation').search(cr, uid,[('book_id', '=', book_avail.id)], context=context)res[book_avail.id]=len(book_ids)raise osv.except_osv(_('Error _reservationed_book_number'),_('"%s"') % (res)return res
and here is the corresponding field:
'available_number_book':fields.function(_book_available, string='Available number of books'),Please can you help me? I have been stuck on this for hours
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
2
Replies
3337
Views
Try adding the parameter store=True to fields.function.
Can you give me any suggestion, any idea where my mistake is? Please...
openerp version ? you should put entire 2 class wih fields, with your description, no enough informations