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

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

By
Klaus Weber
on 2/18/16, 4:42 AM 852 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

--Axel Mendoza--
10203
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

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

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: 2/18/16, 4:42 AM
Seen: 852 times
Last updated: 2/18/16, 9:39 AM