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.

4

How to overwrite buttons save save/create in wizard of a one2many line ?

By
yellow
on 3/28/13, 9:47 AM 7,420 views

Hi all, I try to overwrite originals buttons "save" and "save/create" which are in wizard opened in a one2many line, this for version openerp 6.1 . It is possible, and if yes, how to do that.

Thanks for your contribution.

Regards.

What you want to do after overwrite them? Do you want to put your own buttons?

Sudhir Arya (SA)
on 3/29/13, 7:20 AM

Hi sudhir, thanks for your interest, no I would like to add some operations when originals buttons save or save/create in wizard of a line one2many are clicking, by overwritten java function do_save in web/addons/web/static/src/js/view_form.js, like function super in python, for buttons oe_selectcreatepopup-form-save-new, oe_selectcreatepopup-form-save defined in web/addons/web/static/src/xml/base.xml. I do not kow how to overwrite this java function in xml view or python. This is enough clear as answer, or ? Thanks.

yellow
on 3/29/13, 7:38 AM
3

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 3/29/13, 7:58 AM

I don't have any idea about web but I can give you another solution that you can override create or write method.

create method will be called when you will create a record and write will be called when you will update the record.

def create(cr, uid, vals, context=None):
    #Todo code
    super(your_class_name, self).create(cr, uid, vals, context=context)

def write(cr, uid, ids, vals, context=None):
    #Todo code
    super(your_class_name, self).write(cr, uid, ids, vals, context=context)

Hope it will work for you.

Thanks.

Thanks for your answer, I know it is possible to overwrite method write, create, unlink ..., but the problem in a one2many wizard is that when you created a new line and saved this line with button in wizard, tehre is no create or write action, due to the code in web client, there is just a temporary id created prefixed as one2many_v_id_xxx (see file data.js in web), changes are really saved only when I push button save of the form, and not when I push button save of the wizard, then in this case operations I want to do can not be done immediately. An other idea ??? Thanks

yellow
on 3/29/13, 8:06 AM

Did you try on_change on your one2many field?

Sudhir Arya (SA)
on 3/29/13, 8:11 AM

Thanks for your effort and answer, the same conclusion as Francesco, but it was the first to find, I will validate his answer, but I vote for your answer too. Thanks. Bye

yellow
on 3/29/13, 8:16 AM

My pleasure. If you get solution then please share it so that it can help to others.

Sudhir Arya (SA)
on 3/29/13, 8:19 AM

If I find an other solution I will share it. Thanks again bye.

yellow
on 3/29/13, 8:31 AM
1

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 3/29/13, 7:58 AM

The best way is to do a super on write and/or create function in your class.

Another way is to use the on_change function on the one2many field so you can do all the control you need

Thanks for your answer, I know it is possible to overwrite method write, create, unlink ..., but the problem in a one2many wizard is that when you created a new line and saved this line with button in wizard, tehre is no create or write action, due to the code in web client, there is just a temporary id created prefixed as one2many_v_id_xxx (see file data.js in web), changes are really saved only when I push button save of the form, and not when I push button save of the wizard, then in this case operations I want to do can not be done immediately. An other idea ??? Thanks

yellow
on 3/29/13, 8:06 AM

You can use the on_change function to do something when you o2m change

Francesco OpenCode
on 3/29/13, 8:10 AM

Effectively, this is the conclusion I found too. Update your answer with good conclusion, I will valid it. Thanks. Bye

yellow
on 3/29/13, 8:14 AM

done....:)

Francesco OpenCode
on 3/29/13, 8:27 AM

Done too, thanks again, bye.

yellow
on 3/29/13, 8:31 AM

Hi, I reopen question because onchange doesn't work, I have an error with virtual id .... an other idea ? thanks. Bye

yellow
on 4/13/13, 10:28 AM

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

0 follower(s)

Stats

Asked: 3/28/13, 9:47 AM
Seen: 7420 times
Last updated: 11/2/16, 3:00 AM