Hi,
I am working on the Attendance module and I want to automatically send an email to the employees at the end of the day who forgets to logout keeping HR in CC odoo12.
Could anyone help me to achieve this?
Thank you in advance!!!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
I am working on the Attendance module and I want to automatically send an email to the employees at the end of the day who forgets to logout keeping HR in CC odoo12.
Could anyone help me to achieve this?
Thank you in advance!!!
Hi,
For this you can use the cron job/scheduled action which runs at the end of every day, and inside the corresponding function you can check whether the employee is logged out or not, if not you can send email notification from there.
For creating a scheduled action, see this sample:
<record forcecreate="True" id="ir_cron_scheduler_alarm" model="ir.cron">
<field name="name">Calendar: Event Reminder</field>
<field name="model_id" ref="model_calendar_alarm_manager"/>
<field name="state">code</field>
<field name="code">model.get_next_mail()</field>
<field eval="False" name="active" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">30</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall" />
</record>
Once cron job is created the function will be triggered in the given time interval, then from the function you can easily send the email notification as per the need.
See: How To Create Scheduled Actions in Odoo
For sending Email from python using Email template, see this sample code,
@api.one
def send_forum_validation_email(self, forum_id=None):
if not self.email:
return False
token = self._generate_forum_token(self.id, self.email)
activation_template = self.env.ref('website_forum.validation_email')
if activation_template:
params = {
'token': token,
'id': self.id,
'email': self.email}
if forum_id:
params['forum_id'] = forum_id
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
token_url = base_url + '/forum/validate_email?%s' % urls.url_encode(params)
with self._cr.savepoint():
activation_template.sudo().with_context(token_url=token_url).send_mail(
self.id, force_send=True, raise_exception=True)
return True
Also you can check whether the automated actions can help in this case. If you activate the debug mode, navigate to settings -> technical, here there is a menu named Automated action, have a look at it too.
Email Template: How To Create Email Template
Send Email from code: Send Email From Code Using Email Template
Thanks
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
3
Jun 23
|
3974 | ||
|
0
Apr 23
|
91 | ||
|
6
Jan 23
|
14580 | ||
|
2
Dec 22
|
3273 | ||
how can configured email
Solved
|
|
1
Nov 22
|
1224 |
Send Email: https://goo.gl/z16PBZ