Hi,
You can achieve this functionality using a scheduled action. You can send the email notification using triggering a scheduled action.
example:
1)First create a scheduled action in a XML file
<record id="run_mail_notification" model="ir.cron">
<field name="name">Invoice: Email Notification Unpaid</field>
<field name="interval_number">1</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field name="user_id" ref="base.user_root"/>
<field name="doall" eval="False"/>
<field name="model_id" ref="model_account.move"/>
<field name="code">model.run_unpaid_invoice_notification()</field>
<field name="state">code</field>
</record>
2) Write the Python function to execute the scheduled action in the model account.move by inheriting the model account.move
def run_unpaid_invoice_notification(self):
not_paid_invoices = self.env['account.move].search([('payment_state','=','not_paid')])
for rec in not_paid_invoices:
email_values = {
'email_cc': False,
'email_to': rec.partner_id.email,
}
mail_template = self.env.ref(
'module_name.unpaid_invoice_mail')
mail_template.send_mail(http://rec.id" target="_blank" data-saferedirecturl="rec.id,
" rel="ugc">https://www.google.com/url?q=http://rec.id&source=gmail&ust=1710908582329000&usg=AOvVaw2eTE3bY3BBixRqBli-r2Kl">rec.id
, email_values=email_values,
force_send=True)
3) Create a mail template
<record id="unpaid_invoice_mail" model="mail.template">
<field name="name">Invoice: Unpaid State</field>
<field name="email_from">{{user.email}}</field>
<field name="subject">{{http://object.name" target="_blank" data-saferedirecturl="object.name" rel="ugc">https://www.google.com/url?q=http://object.name&source=gmail&ust=1710908582329000&usg=AOvVaw1SOx5zJQ2B5zQDmrv50O0V">object.name}} is still unpaid</field>
<field name="model_id" ref="module_name.model_account_move"/>
<field name="auto_delete" eval="True"/>
<field name="body_html" type="html">
<div>
<p>
<t t-out="http://object.name" target="_blank" data-saferedirecturl="object.name"/>
" rel="ugc">https://www.google.com/url?q=http://object.name&source=gmail&ust=1710908582329000&usg=AOvVaw1SOx5zJQ2B5zQDmrv50O0V">object.name"/>
Is still in Unpaid state,
<br/>
</p>
</div>
</field>
</record>
Please check with the above codes to send an email notification when the amount is not paid.
In the same way you can send notifications for project delay
Please refer to the below blogs also:
How to configure scheduled action in odoo 17
How to Create an Email Template in Odoo 17
Hope it helps