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.

1

Get data from one model to another model

By
joshi
on 3/31/15, 1:14 AM 805 views

Hi,,help me in getting this,,,

when i fill the form   i.e, it contains(subject,date,amount,note) of one model,,it has to update in the another model, it contains (subject,date,amount).





 


please explain your scenario with code

Atchuthan - Technical Consultant, Sodexis Inc
on 3/31/15, 1:22 AM
1
Alby Antony
On 3/31/15, 5:00 AM

i have dobe the similar may be this will help you. i created an invoice table entry when one claim form is approved. here i will give the code

class claim_submitted(osv.osv):

_name = "claim_submitted"

_description = "claims submitted"

_columns = {

'claim_name':fields.many2one('claim_type','Claim type:',required=True),

'claim_name_edit':fields.char('Claim :' ,readonly = True),

'member_id':fields.many2one('res.users','Member ID:',required=True, ),

}


def action_approve(self,cr, uid, ids, context=None):

claim_type_obj=self.pool.get('claim_type')

invoice_amount=2000

claim_invoices = self.pool.get('claim_invoices')

vals = {'claim_id': ids[0], 'invoice_date': time.strftime('%Y-%m-%d'), 'invoice_amount':invoice_amount}

claim_invoices.create(cr, uid, vals, context=context)

self.write(cr, uid, ids, {'state': 'done','approved_date': time.strftime('%Y-%m-%d'),'approved_id':uid}, context=context)

return True

class claim_invoices(osv.osv):

_name = "claim_invoices"

_description = "invoices generated for claims"

_columns = {

'claim_id': fields.integer('claim_id:'),

'invoice_date':fields.date('Invoice date:'),

'invoice_amount':fields.integer('Invoice amount:')

}



instead of this approve function you can use create function.

0
joshi
On 3/31/15, 1:27 AM

Hi,  Atchuthan 

can u give me some examples on this 

0

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3883
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 3/31/15, 1:22 AM

You can load the value using 3 ways:

1. context (Preferred)
2. default_get
3. defaults

Context:
pass the context with default_FIELDNAME keyword

E.g. context={'default_name': name}

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

1 follower(s)

Stats

Asked: 3/31/15, 1:14 AM
Seen: 805 times
Last updated: 4/17/15, 1:46 AM