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

How to save a model.new record

By
Jorge Barcelo Cortes
on 4/19/16, 4:30 AM 162 views

Hi. Im trying to make a sale.order virtually. In my code i have:

record = self.env['model'].new(data)

record.change_product()

record.compute_totals()

record.save()


Now, that last line is raising an exception. Can someone help?

0
Jorge Barcelo Cortes
On 4/19/16, 9:16 AM

I cant use the create method, some of the required data are set by the onchange methods

0
Motez
On 4/19/16, 7:15 AM

If you want to create a new record you should use the\ create method.

Then your code shoud look like :

record = self.env['model'].create(data)
record.change_product()
record.compute_totals()

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: 4/19/16, 4:30 AM
Seen: 162 times
Last updated: 4/19/16, 9:16 AM