Hello, I have an API that creates the customer details and paid invoices in odoo. When the invoice is created I want to send the invoice as a pdf to the customer automatically. This is my code, it is not working. Please review it
@api.model
def send_membership_invoice_emails(self):
invoices = self.env['account.move'].search([('invoice_line_ids.product_id.name', '=', 'Product membership') ])
for invoice in invoices:
_logger.info("Product 'Product membership' found in invoice %s. Proceeding to send email.", invoice.name)
invoice_report_id = self.env.ref('account.account_invoices_without_payment')
generated_report = invoice_report_id._render_qweb_pdf(invoice.id, email_values=email_values, force_send=True)
email_template.attachment_ids = [(5, 0, 0)]
_logger.info("Email sent successfully to %s for invoice %s", invoice.partner_id.email, invoice.name)
Which odoo version sir ?
odoo 16