Hello,
I want to create schedule action for the button send by email in invoicing for customer every month, How can I do that.
Thanks in advance for any help.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello,
I want to create schedule action for the button send by email in invoicing for customer every month, How can I do that.
Thanks in advance for any help.
Hi,
The "Send by Email" button on the invoice opens the default email template (like account.email_template_edi_invoice ) and sends the invoice as a PDF attachment to the customer.
Create a simple custom module (eg, auto_invoice_mailer ) and add the following logic.
{ 'name' : 'Auto Invoice Email Sender' , 'version' : '1.0' , 'category' : 'Accounting' , 'depends' : [ 'account' ], 'data' : [ 'data/auto_invoice_cron.xml' , ], }
from odoo import models, api from datetime import datetime, timedelta class AutoInvoiceSender (models.Model): _inherit = 'account. move' @api.model def cron_send_invoices_by_email ( self ): # Set your criteria for invoices to send (eg, posted, customer invoice, not already sent) invoices = self. search([ ( 'move_type' , '=' , 'out_invoice' ), ( 'state' , '=' , 'posted' ), ( 'invoice_date' , '>=' , (datetime.today() - timedelta(days= 30 )).date()), ( 'invoice_sent' , '=' , False ), # Make sure it's not already sent ]) template = self.env.ref( 'account.email_template_edi_invoice' , raise_if_not_found= False ) for invoice in invoices: if template: invoice.message_post_with_template( template.id ) invoice.write({ 'invoice_sent' : True }) # Mark as sent
<odoo> <data noupdate = "1"> <record id = "ir_cron_auto_invoice_sender" model = "ir.cron"> <field name = "name" >Send Monthly Customer Invoices by Email </field> <field name = "model_id" ref = "account.model_account_move"/> <field name = "state" >code </field> <field name = "code" >model.cron_send_invoices_by_email() </field> <field name = "user_id" ref = "base.user_admin"/> <field name = "interval_number">1 </field> <field name = "interval_type">months </field> <field name = "numbercall" >-1 </field> <field name = "doall" eval = "False"/> <field name = "active" eval = "True"/> </record> </data> </odoo>
i hope it is usefull
Hi,
Create schedule action with the button click function.
<data noupdate="1">
<record id="ir_cron_scheduler_recurring_action" model="ir.cron">
<field name="name">Recurring Todo Activity</field>
<field name="model_id" ref="model_mail_activity"/>
<field name="state">code</field>
<field name="code">model.action_done()</field>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
</record>
</data>
Change the interval type as days/months
For creating email template please go through this blog
https://www.cybrosys.com/blog/creating-email-templates-in-odoo-15
Create python function to send email through button function
def action_done(self):
mail_template = self.env.ref("module_name.email_template_name")
mail_template_send_mail(self.id,force_send=True)
Hope it helps
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
InscribirsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
2
dic 24
|
7442 | ||
How to ORDER BY? [Odoo 10]
Resuelto
|
|
2
nov 24
|
28125 | |
|
2
may 24
|
7197 | ||
|
3
mar 24
|
6627 | ||
|
0
mar 24
|
1443 |