تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
17 الردود
21907 أدوات العرض

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?

الكاتب

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.

أفضل إجابة

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

Did you try on_change on your one2many field?

الكاتب

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

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

الكاتب

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

أفضل إجابة

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

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

الكاتب

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

الكاتب

Done too, thanks again, bye.

الكاتب

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

أفضل إجابة

Hi all, any update about this issue????

Thanks in advance.

الصورة الرمزية
إهمال
أفضل إجابة

any update on this? any solution?

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يونيو 24
442
1
نوفمبر 16
5797
0
أغسطس 16
4187
1
فبراير 16
4867
1
مارس 15
6762