Odoo Help

-1

Open ERP 7 - What python function is called to update a record

By
Klaus Weber
on 2/18/16, 4:42 AM 1,468 views

It was said that in OpenERP the functions 

def create(self, cr, user, vals, context=None)

 and 

def update(self, cr, user, vals, context=None)

 exist within the orm.Model that are called if you save a new record or if you update one. I need to inherit those functions to prevent ERP from saving or updating any records if certain typed-in data have the wrong format. I found the create function and was able to inherit and my implementation for this what I wanted works fine with that. However, I wasn't able to find the function that is called when I want to update a record. It is definitely not "update" I'm using OpenERP 7. What function is called for updating a record? Please can anybody help

0
Klaus Weber
On 2/18/16, 9:39 AM

I tested overwriting the "write function", but it doesn't seem to use this function. Even if I try using a variable that obviously doesn't exist, there is no error. Only if I delete the write function from the orm Model it uses this function.

What do I do wrong? It works fine with the inherited "create" function. how can I force the system to use the new write function?


Regards. 



the write method only get called for the model record update, you need to create a record, save it, edit it and save it again to get the write called

Axel Mendoza
on 2/18/16, 9:44 AM

I meant that the overwritten function "create" is called when I want to create this record. Never wanted to say that I expect that the create function is called after an update. The create function contains the same functionality that I need for all updates. For creating a record it works, i.e. the function create is called. For updating my overwritten write function is not called.

Klaus Weber
on 2/18/16, 10:06 AM

I don't say that you need to call the write method in the create method, just that you need to do it in the ui to get the write method called, also you need to provide the code that you are using for because without that nobody will be able to see your error

Axel Mendoza
on 2/18/16, 10:49 AM

Sorry, I am telling you two different things: 1. I create a record -> the inherited create method is called. --> works fine. 2. I want to edit this record --> the inherited write method is not called --> does not work fine. I didn't say that the write function shall be called within the create method. The two methods are completely independent. I'm just telling that the Inheritance worked for the create method but not for the write method. Kind regards.

Klaus Weber
on 2/18/16, 11:21 AM
0
Axel Mendoza
On 2/18/16, 9:30 AM

As you said the function update doesn't exist, it's the function write the responsible to update the model records. Find it to change it

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 2/18/16, 4:42 AM
Seen: 1468 times
Last updated: 2/18/16, 9:39 AM