Skip to Content
Menu
This question has been flagged

I have a custom report and i want to send it in a custom email template via a cron job

Report:

            model="sale.purchase.summary.wizard"
string="Daily Activity Report"
report_type="qweb-pdf"
name="sale_purchase_summary.sale_purchase_summary_rep"
print_report_name="Daily Activity Report" menu="False"/>

Python Script to send mail:

def send_mail(self):
template = self.env.ref('sale_purchase_summary.email_template_sale_purchase_summary')
email_addresses = self.env['ir.config_parameter'].sudo().get_param('sale_purchase_summary.executive_summary_emails')
template.email_to = email_addresses
mail_id = template.send_mail(self.env.user.id,force_send=False)
if mail_id:
mail = self.env['mail.mail'].browse(mail_id)
mail.send()


Error i am getting while running the cron job manually:

 Failed to render template  using values {'user': res.users(1,), 'object': sale.purchase.summary.wizard(1,), 'format_tz': . at 0x7f0a898fd048>, 'format_date': . at 0x7f0a893d3ea0>, 'format_amount': . at 0x7f0a898fdd08>, 'ctx': {'safe': False, 'search_default_all': 1, 'lang': 'en_US', 'params': {'id': 7, 'model': 'ir.cron', 'menu_id': 4, '_push_me': False, 'action': 10, 'view_type': 'form'}, 'mail_notify_force_send': False, 'uid': 1, 'tz': 'Europe/Brussels'}}

SecurityError: access to attribute '_get_report_name' of 'sale.purchase.summary' object is unsafe
Avatar
Discard
Related Posts Replies Views Activity
1
Nov 24
634
0
Jan 24
418
0
Jan 24
245
0
Feb 22
1311
2
Sep 16
8610