تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
2291 أدوات العرض

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
مارس 23
2730
0
أغسطس 20
2104
3
مايو 16
3930
1
مايو 15
5460
1
مارس 15
4272