Odoo Help


Save the register on the BBDD (like press the save button) in onchange method

on 5/12/16, 10:38 AM 797 views

I have a field type char "name" and a function onchange for this field. I want save the register complete when i modified the field "name" Something like:

    def _onchange_name(self):
        #Save the register on the BBDD (like press the save button)

you want to have the history of name changes,, am I correct?

Baiju KS
on 5/12/16, 11:41 AM

I have more fields, i want automatically save all fields at the change the name

on 5/12/16, 12:19 PM

could you please explain in detail about what you want?

Baiju KS
on 5/13/16, 1:53 AM
On 5/19/16, 3:30 AM

Finally override create method

def create(self,values):
    <my code>

Axel Mendoza

--Axel Mendoza--
| 7 8 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 and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 5/13/16, 6:58 AM

You need to have another field of type one2many for that and also set the new value in the return of the onchange. Something like this:

def _onchange_name(self, cr, uid, ids, name, history_ids, context=None):
history_ids.append(0,0,{'name': name})
return {'value': {'history_ids': history_ids}}

There are a few things to notice here, in the onchange with the new api does not allow you to return values for one2many or many2many fields so your need to hack into that to get it working. Like redefining the onchange method of your model like in this example:


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.


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)


Asked: 5/12/16, 10:38 AM
Seen: 797 times
Last updated: 5/19/16, 3:32 AM