Odoo Help


Function to get number of records from another class does not output anything on the screen

on 4/3/15, 12:18 PM 923 views

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):
        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)
        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

Can you give me any suggestion, any idea where my mistake is? Please...

on 4/3/15, 12:56 PM

openerp version ? you should put entire 2 class wih fields, with your description, no enough informations

Cyril Gaspard (GEM)
on 4/3/15, 5:18 PM


| 6 5 7
Lodz, Poland

On 4/3/15, 2:11 PM

Try adding the parameter  store=True to fields.function.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 4/3/15, 12:18 PM
Seen: 923 times
Last updated: 4/3/15, 5:18 PM