This question has been flagged
1 Reply
3729 Views
Hi,

     When I click on "SAVE" event to create a record in my object, my field values are also used to create a record in other object.

Also my requirement doesnt go well with _inherits of other object.

Thanks & Regards,
Atchuthan
Avatar
Discard

Write def create() for this.

Author

@Hiral Patel

def create() is used only to provide the values to be set at the time of create for my object

but my requirement is to create a record of other object

If we can use create() ORM method, give me in detail

Best Answer

Hello,

class test1(osv.osv): _name = 'test1'

class test(osv.osv):

_name = 'test'

def create(self, cr, uid, vals, context=None):

    att_id = self.pool.get('test1').create(cr, uid, {'key':value}, context=context)

    res = super(test, self).create(cr, uid, vals, context=context)

    return res

Here, 'test' & 'test1' are two objects. I have written a create() in 'test', When we create a record for this object it will create record for 'test1' as we have written self.pool.get('test1').create(cr, uid, {'key':value}, context=context).

we have to pass a dictionary of 'Key' & of it's value.

Thank you.

Avatar
Discard

Don't hesitate to mark as "correct" the answer. That will be helpful for future search.