Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3796 Lượt xem

Dear all,

I have a very basic question and need your help.
I am using Odoo 12, and need to inherit the code from "stock.picking" for the "button_validate" function.

My code is:

     class StockPicking(models.Model):
         _inherit = "stock.picking"

I know I can copy the full code from "button_validate", past it here on a new "button_validate" metthod and proceed with the changes I need, but I do not want to proceed like this.

Since I am not going to change the original "button_validate" code (I just need to call another method when the original "button_validate" finish), I need to find a way of inherit the code and add my own function call at the end of the original code. I.e.:

     @api.multi
     def button_validate(self):
           ...someway to run original code without having to past it here...

          //Run my function...
          self.my_function_here()

Can anyone help me?

Thank you all in advance

Best regards

Paulo

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

​@api.multi
def button_validate(self):
    res = super(StockPicking, self).button_validate()
    # Run my function...
    self.my_function_here()
    return    res                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ​                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        



Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 23
6011
2
thg 6 23
5718
4
thg 2 25
2338
1
thg 8 24
1978
2
thg 11 24
3158