İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
2290 Görünümler

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) . 

Avatar
Vazgeç
En İyi Yanıt

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

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Mar 23
2730
0
Ağu 20
2104
3
May 16
3930
1
May 15
5460
1
Mar 15
4272