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.

0

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

By
josemi
on 5/12/16, 10:38 AM 249 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:

@api.onchange('name')
    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
on 5/12/16, 11:41 AM

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

josemi
on 5/12/16, 12:19 PM

could you please explain in detail about what you want?

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

Finally override create method

@api.model
def create(self,values):
    <my code>
0

Axel Mendoza

--Axel Mendoza--
10205
| 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 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:

https://www.odoo.com/forum/ayuda-1/question/access-one2many-list-in-many2one-onchange-event-93056#answer_93121

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: 5/12/16, 10:38 AM
Seen: 249 times
Last updated: 5/19/16, 3:32 AM