Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
4044 Visualizzazioni


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
Abbandona
Risposta migliore

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

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