Odoo Help


Is it possible to use the create method from withint one class to another?

on 2/13/13, 10:33 PM 1,764 views


I have a class student and my idea is that each time the class gets called I need to insert some data into another table, lets call it logs

The problem is that when I call

logs.create(cr, uid, i, context)

Inside the class student, OpenERP will give me back the error:

unbound method create() must be called with logs instance as first argument (got Cursor instance instead)

I tried changing the cr with logs but it will keep giving me a similar error.

Is is possible to insert records in a table created by another class from within a given class?

Any tip or module with this functionalities will be much appreciated

On 2/14/13, 3:07 AM
def create(self, cr, user, vals, context=None):
    Create a new record for the model.

    The values for the new record are initialized using the ``vals``
    argument, and if necessary the result of ``default_get()``.

    :param cr: database cursor
    :param user: current user id
    :type user: integer
    :param vals: field values for new record, e.g {'field_name': field_value, ...}
    :type vals: dictionary
    :param context: optional context arguments, e.g. {'lang': 'en_us', 'tz': 'UTC', ...}
    :type context: dictionary
    :return: id of new record created

For example we can create the log as

self.pool.get('student.log').create(cr, uid, {'name': 'logname'}, context=context)

Thanks a lot!! I was not aware of self.pool.get, I knew it existed but didn't know it was for this use. Thanks a lot for your help and your time!

on 2/14/13, 11:58 AM
On 2/14/13, 4:59 AM

Are you talking about Python classes or OpenERP objects? In both cases it's possible, but not at all in the same way...

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

0 follower(s)


Asked: 2/13/13, 10:33 PM
Seen: 1764 times
Last updated: 3/16/15, 8:10 AM