簡體   English   中英

當用戶單擊 Odoo 13 表單中的保存按鈕時,我如何運行一段代碼?

[英]How can i run a piece of code when user clicks on save button in a form in Odoo 13?

我有一個 function 如下所示,我正在向 X 發送郵件,目前,我已經創建了一個按鈕來發送它,但我希望一旦用戶單擊表單視圖中的保存按鈕和實際功能就發送它保存按鈕應該像往常一樣工作。

def action_send_card(self):
        print("sending")
        template_id = self.env.ref('germi_leave_plugin.leave_email_template').id
        self.env['mail.template'].browse(template_id).send_mail(self.id,force_send=True)

你必須重寫 function 並在那里調用你的 function 只是在調用你的 function 后要注意你應該使用超級()

def write(self, vals):
    print("sending")
    template_id = self.env.ref('germi_leave_plugin.leave_email_template').id
    self.env['mail.template'].browse(template_id).send_mail(self.id, force_send=True)
    return super(self).write(vals)
 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM