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

Right now in order to send the ledger to partner, we need to download the pdf report and then attach it to the email. 

But How can I achieve this directly from the partner ledger screen in reporting. I can add a button "Send Email" but Im not familiar with what actions and methods I should use in order to achieve this result. 


One way can be I just use my custom email server and send it , but I see tha odoo has got email templates we can use in order to send emails, attaching the necessary pdf file. 

Is that way possible for pdf report (partner ledger) . 

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

Hi,

First, you need to define the button in the XML

<button name="action_send_report" class="oe_highlight"

string="Send Mail"

type="object"

help="To send part ledger"/>

Next, we need to define the py for getting the attachments,
Function for sending attachments in the mail

def action_send_report(self):
"""Send partner ledger report as mail"""
report = {
'docs': self,
}
record = self.env['ir.actions.report'].sudo()._render_qweb_pdf(
'module_name.record_id_of_ir_actions_reort', self.id,
data=report)
ir_values = {
'name': 'Partner Ledger',
'type': 'binary',
'datas': base64.b64encode(record[0]),
'store_fname': base64.b64encode(record[0]),
'mimetype': 'application/pdf',
'res_model': 'your.model',
}
report_attachment = self.env['ir.attachment'].sudo().create(ir_values)
email_values = {
'email_to': self.manager_id.work_email,
'subject': "Partner Ledger",
'attachment_ids': [report_attachment.id]
}
mail = self.env['mail.mail'].sudo().create(email_values)
mail.send()

Hope it helps

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มี.ค. 23
2767
0
ส.ค. 20
2135
3
พ.ค. 16
3985
1
พ.ค. 15
5488
1
มี.ค. 15
4319