Odoo Help


This community 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.


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

on 4/3/15, 12:18 PM 511 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


| 5 4 7
Lodz, Poland

On 4/3/15, 2:11 PM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)


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