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

[odoo 8]: How set value of one2many field by overriding create method with api coding standard?

By
Prince Caspion
on 7/10/16, 10:04 PM 396 views

Hello All,

I'm having problem on overriding create method.

I've one2many field in my current model, I want to update the value of that field when new record created, and this one2many field's co-model has it's own one2many fields.

So, basically there is two levels of one2many fields.

My one2many field has one2many field, I want to create record for that model as well,

How can i achieve this?

Any help on this appreciated.

This is need to be done using api coding standard.




Could you share the code that you are using with comment so everyone could better get the idea of what you are doing and trying to do

Axel Mendoza
on 7/11/16, 12:01 AM

@Axel: I've given the example in new question, because i was not able to edit my question. here is the link. https://www.odoo.com/forum/help-1/question/odoo-8-how-to-update-value-of-one2many-field-with-at-second-level-by-using-create-and-write-method-using-api-104615

Prince Caspion
on 7/11/16, 2:03 AM
1
Nikunj Antala
On 7/11/16, 1:04 AM

Hello Prince,

Try to use this code.

@api.model

def create(self,vals):

     vals.update({'one2many_field_name':[(0,0,{'field_of_co_model':'val_of_co_model'})]}})

     return super(class_name,self).create(vals)


Hope this help.

@Nikunj, thanks for your ans. but till now I've achieved already, Now the problem is that one2many field which is also one2many, than how can do? Here i got stuck. and i want the same thing for write method.

Prince Caspion
on 7/11/16, 1:49 AM

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: 7/10/16, 10:04 PM
Seen: 396 times
Last updated: 7/11/16, 1:04 AM