For example, I want company employees to receive notifications on their page and this should be done at an automatically defined time (e.g. at 2pm today)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
1
ตอบกลับ
3650
มุมมอง
Hi,
You can use Scheduled actions from settings menu for this purpose.
In your Code
XML
Inside the data directory create an xml file for notification
< odoo>This will create scheduler with name 'Employee notification'.You can see that in scheduled actions from settings menu.You can set the Next Execution Date and time from there by manually or it will execute automatically according to the time period we given.It may be 1 day,1 month..etc.Here it is 1 day as you can see from interval_number.
< data noupdate="1">
< record id="user_notification_scheduler" model="ir.cron">
< field name="name">Employee notification
< field name="model_id" ref="model_hr_employee"/>
< field name="type">ir.actions.server
< field name="state">code
< field name="user_id" ref="base.user_root"/>
< field name="code">model.employee_notification()
< field name="interval_number">1
< field name="interval_type">days
< field name="numbercall">-1
< /record>
< /data>
< /odoo>
Python
Inherit the model 'hr.employee' and define the employee_notification() function mentioned in the above xml code
class HrEmployeeInherit(models.Model):Regards
_inherit = 'hr.employee'
def employee_notification(self):
employees = self.env['hr.employee'].search([])
user = self.env["res.users"].search([('id', '=', self._uid)])
for rec in employees:
email_values = {
'subject': 'Notification for Employees',
'email_from': user.email,
'email_to': rec.work_email,
'body_html': "< div>Dear %s,\n"
................
"< br/>Kindly Regards,"
"< br/>
%s" % (rec.name, user.name),
'auto_delete': True,
}
mail = self.env['mail.mail'].sudo().create(email_values)
mail.send(raise_exception=False)
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
2
ก.พ. 24
|
15595 | ||
|
1
ธ.ค. 22
|
5020 | ||
|
2
ธ.ค. 22
|
14502 | ||
|
2
มิ.ย. 22
|
6363 | ||
|
2
มิ.ย. 22
|
4742 |