# -*- coding: utf-8 -*- ################################################################################### # A part of Open HRMS Project # # Cybrosys Technologies Pvt. Ltd. # Copyright (C) 2018-TODAY Cybrosys Technologies (). # Author: Jesni Banu () # # This program is free software: you can modify # it under the terms of the GNU Affero General Public License (AGPL) as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # ################################################################################### from datetime import datetime, timedelta from odoo import models, fields, _ GENDER_SELECTION = [('male', 'Male'), ('female', 'Female'), ('other', 'Other')] class HrEmployeeContractName(models.Model): """This class is to add emergency contact table""" _name = 'hr.emergency.contact' _description = 'HR Emergency Contact' number = fields.Char(string='Number', help='Contact Number') relation = fields.Char(string='Contact', help='Relation with employee') employee_obj = fields.Many2one('hr.employee', invisible=1) class HrEmployeeFamilyInfo(models.Model): """Table for keep employee family information""" _name = 'hr.employee.family' _description = 'HR Employee Family' member_name = fields.Char(string='Name', related='employee_ref.name', store=True) employee_ref = fields.Many2one(string="Is Employee", help='If family member currently is an employee of same company, ' 'then please tick this field', comodel_name='hr.employee') employee_id = fields.Many2one(string="Employee", help='Select corresponding Employee', comodel_name='hr.employee', invisible=1) relation = fields.Selection([('father', 'Father'), ('mother', 'Mother'), ('daughter', 'Daughter'), ('son', 'Son'), ('wife', 'Wife')], string='Relationship', help='Relation with employee') member_contact = fields.Char(string='Contact No', related='employee_ref.personal_mobile', store=True) class HrEmployee(models.Model): _inherit = 'hr.employee' def mail_reminder(self): """Sending expiry date notification for ID and Passport""" now = datetime.now() + timedelta(days=1) date_now = now.date() match = self.search([]) for i in match: if i.id_expiry_date: exp_date = fields.Date.from_string(i.id_expiry_date) - timedelta(days=14) if date_now >= exp_date: mail_content = " Hello " + i.name + ",
Your ID " + i.identification_id + "is going to expire on " + \ str(i.id_expiry_date) + ". Please renew it before expiry date" main_content = { 'subject': _('ID-%s Expired On %s') % (i.identification_id, i.id_expiry_date), 'author_id': self.env.user.partner_id.id, 'body_html': mail_content, 'email_to': i.work_email, } self.env['mail.mail'].sudo().create(main_content).send() match1 = self.search([]) for i in match1: if i.passport_expiry_date: exp_date1 = fields.Date.from_string(i.passport_expiry_date) - timedelta(days=180) if date_now >= exp_date1: mail_content = " Hello " + i.name + ",
Your Passport " + i.passport_id + "is going to expire on " + \ str(i.passport_expiry_date) + ". Please renew it before expiry date" main_content = { 'subject': _('Passport-%s Expired On %s') % (i.passport_id, i.passport_expiry_date), 'author_id': self.env.user.partner_id.id, 'body_html': mail_content, 'email_to': i.work_email, } self.env['mail.mail'].sudo().create(main_content).send() personal_mobile = fields.Char(string='Mobile', related='address_home_id.mobile', store=True) emergency_contact = fields.One2many('hr.emergency.contact', 'employee_obj', string='Emergency Contact') joining_date = fields.Date(string='Joining Date') id_expiry_date = fields.Date(string='Expiry Date', help='Expiry date of Identification ID') passport_expiry_date = fields.Date(string='Expiry Date', help='Expiry date of Passport ID') id_attachment_id = fields.Many2many('ir.attachment', 'id_attachment_rel', 'id_ref', 'attach_ref', string="Attachment", help='You can attach the copy of your Id') passport_attachment_id = fields.Many2many('ir.attachment', 'passport_attachment_rel', 'passport_ref', 'attach_ref1', string="Attachment", help='You can attach the copy of Passport') fam_ids = fields.One2many('hr.employee.family', 'employee_id', string='Family', help='Family Information')