This question has been flagged
1 Reply
3498 Views


Hi


In the write method I can access the current created object using the browse orm method as follows:

o = self.browse(cr,uid,ids,context=context)[0]
I need to do the same thing in the 'create' method as I need to access some function fields that are not listed in the vals parameter of the create method, pls advise

Avatar
Discard
Best Answer

Hi,

As you access browse inside write method, you can also access browse inside create method as like below.

Inside Odoo V8.

def create(self, vals):

    new_object = super(self,class_name).create(vals) # create method in odoo V8 return browse object instead of integer ID.

    new_object.xxx_field #you can get any of the field as like this.

    return new_object


Inside OpenERP V7.

def create(self, cr, uid, vals, context={})

    new_id = super(self, class_name).create(cr, uid, vals, context=context)

    new_obj = self.browse(cr, uid, new_id, context=context)

    new_obj.xxx_field #you can access any field as like this.

    return new_id

I hope it is helpful to you.

Avatar
Discard
Author

Thx for answer, I found it useful and applied it in my code