简体   繁体   English

openerp:如何在日期字段上添加功能以发送通知

[英]openerp: how i can add function on date field to send notification

I create a new openerp object to monitor the insurance issuance of employee dependants the python code:我创建了一个新的 openerp 对象来监控员工家属的保险发行 python 代码:

class hr_emp_dependents(osv.osv):类 hr_emp_dependents(osv.osv):

_name = 'hr.emp.dependents'
_description = 'HR Employee Dependents Line'
_columns = {
    'emp_line': fields.many2one('hr.employee', 'Employee', readonly=False),
    'nationality':fields.many2one('res.country', 'Nationality', required=True),
    'name': fields.char('Name', size=50, readonly=False, required=True),
    'gender': fields.selection([('male', 'Male'),('female', 'Female')], 'Gender', required=True),
    'birthplace': fields.many2one('res.country', 'Birth Place', required=True),
    'relation': fields.many2one('hr.relation', 'Relation', required=True, domain="[('gender','=',gender)]"),
    'dob': fields.date('Date of Birth', required=False),
    'identification_id':fields.char('Identification No', required=False, help="Dependent's ID Information"),
    'insurance_no': fields.char('Medical Insurance No', size=10, required=False),
    'insurance_start_date': fields.date('Insurance Start Date', size=10, required=False),
    'insurance_exp_date': fields.date('Insurance Expire Date', size=10, required=False),
}

hr_emp_dependents() hr_emp_dependents()

I need to add function to automatically return the current date and if 'insurance_exp_date' is less by 5 than current date send notification to all users on HR/manger group how I can do that??我需要添加函数以自动返回当前日期,如果“insurance_exp_date”比当前日期少 5,则向 HR/manger 组的所有用户发送通知,我该怎么做?

To sent notification mails, its better to create a cron job(scheduler).Go to settings/technical/scheduler/scheduler actions.要发送通知邮件,最好创建一个 cron 作业(调度程序)。转到设置/技术/调度程序/调度程序操作。 In that create a new scheduler action.在其中创建一个新的调度程序操作。 In the extra tab specify the function name you want to execute.在额外选项卡中指定要执行的函数名称。 Check any of the scheduler actions.检查任何调度程序操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM