Odoo Help

Welcome!

This community 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.

0

create record of other object from my object

By
Atchuthan - Technical Consultant, Sodexis Inc
on 7/29/13, 4:44 AM 990 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

Write def create() for this.

Hiral Patel (hip)
on 7/29/13, 5:30 AM

@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

Atchuthan - Technical Consultant, Sodexis Inc
on 7/29/13, 5:40 AM
2

Hiral Patel (hip)

--Hiral Patel (hip)--
Tiny ERP Pvt Ltd
http://www.odoo.com
913
| 2 1 5
India
--Hiral Patel (hip)--


Hiral Patel (hip)
On 7/29/13, 7:20 AM

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.

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

Xsias
on 8/2/13, 12:08 PM

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 7/29/13, 4:44 AM
Seen: 990 times
Last updated: 3/31/15, 5:37 PM