Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
4043 Vizualizări


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

Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează
Autor

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