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

Avatar
Discard
Author Best Answer

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. 



Avatar
Discard

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

Author

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.

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

Author

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.

Best Answer

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

Avatar
Discard