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

insert existing instance into a newly created instance one2many field

By
Adrian
on 11/22/13, 10:09 AM 851 views

I have a custom module with one2many field:

'worksheet_ids' : fields.one2many('ng.worksheet', 'machine_id', 'Munkalapok'),`

and i have both machine_id field on my current model and the ng.worksheet model.
I want to list in the form vew all the ng.worksheet that has that machine_id. But for somereason it lists wrong ones! I don't get it why, so i tried to add those existing records to the instance when i create it.

vals['worksheet_ids'] = [(6,0, worksheet_ids]

this sadly doesnt works ona newly created instance, and i get an error.

vals['worksheet_ids'] = [(4, worksheet_ids[0])]

this gives me that machine_id isn't set, when in the actual instance it is set.

So how can I do this? What am I doing wrong?

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: 11/22/13, 10:09 AM
Seen: 851 times
Last updated: 3/16/15, 8:10 AM