This question has been flagged
2 Replies
4910 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?

Avatar
Discard
Author Best Answer

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

Avatar
Discard
Best Answer

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()
Avatar
Discard