Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
3205 มุมมอง

I am trying to replace the validate button of the stock.picking model with a custom one since I need my custom button in addition to the function that I declare to also do the function that came by default of the validate button
I am trying this some help please


py file

def validate(self):
if not self.quien_elabora:
self.quien_elabora = str(\self.env.user.name)
self.env["stock.picking"].button_validate()






















                                                                                                               





























อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

If you need to add functionalities to the `button_validate` method you need to extend it.

class StockPickingInherit(models.Model):

    _inherit = "stock.picking"


    def button_validate(self):

        # add your stuff

        # ..

        return super().button_validate()


    # If tou don't want change the original behaviour of the method you can create a new one

    def validate(self):

        # add your stuff

        return self.button_validate()

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thanks for the help but it was not what I really needed what I served was the following

from odoo.addons.stock.models import stock_picking

def button_validate1(self):
if not self.quien_elabora:
var = stock_picking
var.Picking.button_validate(self)
self.quien_elabora = str(self.env.user.name)


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
5
ต.ค. 24
32486
1
ก.ค. 23
7169
2
ก.ค. 22
11385
0
ส.ค. 21
1959
0
ก.ค. 21
3841