summaryrefslogtreecommitdiff
path: root/hr_employee_updation/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 17:14:58 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 17:14:58 +0700
commit1ca3b3df3421961caec3b747a364071c80f5c7da (patch)
tree6778a1f0f3f9b4c6e26d6d87ccde16e24da6c9d6 /hr_employee_updation/models
parentb57188be371d36d96caac4b8d65a40745c0e972c (diff)
initial commit
Diffstat (limited to 'hr_employee_updation/models')
-rw-r--r--hr_employee_updation/models/__init__.py29
-rw-r--r--hr_employee_updation/models/hr_contract_days.py16
-rw-r--r--hr_employee_updation/models/hr_employee.py123
-rw-r--r--hr_employee_updation/models/updation_config.py31
4 files changed, 199 insertions, 0 deletions
diff --git a/hr_employee_updation/models/__init__.py b/hr_employee_updation/models/__init__.py
new file mode 100644
index 0000000..56e67b7
--- /dev/null
+++ b/hr_employee_updation/models/__init__.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+###################################################################################
+# A part of Open HRMS Project <https://www.openhrms.com>
+#
+# Cybrosys Technologies Pvt. Ltd.
+# Copyright (C) 2018-TODAY Cybrosys Technologies (<https://www.cybrosys.com>).
+# Author: Jesni Banu (<https://www.cybrosys.com>)
+#
+# 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 <https://www.gnu.org/licenses/>.
+#
+###################################################################################
+from . import hr_employee
+from . import updation_config
+from . import hr_contract_days
+
+
+
+
diff --git a/hr_employee_updation/models/hr_contract_days.py b/hr_employee_updation/models/hr_contract_days.py
new file mode 100644
index 0000000..11f161c
--- /dev/null
+++ b/hr_employee_updation/models/hr_contract_days.py
@@ -0,0 +1,16 @@
+from odoo.exceptions import Warning
+from odoo import models, fields, api, _
+
+
+class HrEmployeeContract(models.Model):
+ _inherit = 'hr.contract'
+
+ def _get_default_notice_days(self):
+ if self.env['ir.config_parameter'].get_param(
+ 'hr_resignation.notice_period'):
+ return self.env['ir.config_parameter'].get_param(
+ 'hr_resignation.no_of_days')
+ else:
+ return 0
+
+ notice_days = fields.Integer(string="Notice Period", default=_get_default_notice_days)
diff --git a/hr_employee_updation/models/hr_employee.py b/hr_employee_updation/models/hr_employee.py
new file mode 100644
index 0000000..17a0185
--- /dev/null
+++ b/hr_employee_updation/models/hr_employee.py
@@ -0,0 +1,123 @@
+# -*- coding: utf-8 -*-
+###################################################################################
+# A part of Open HRMS Project <https://www.openhrms.com>
+#
+# Cybrosys Technologies Pvt. Ltd.
+# Copyright (C) 2018-TODAY Cybrosys Technologies (<https://www.cybrosys.com>).
+# Author: Jesni Banu (<https://www.cybrosys.com>)
+#
+# 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 <https://www.gnu.org/licenses/>.
+#
+###################################################################################
+from datetime import datetime, timedelta
+from odoo import models, fields, _, api
+
+GENDER_SELECTION = [('male', 'Male'),
+ ('female', 'Female'),
+ ('other', 'Other')]
+
+
+class HrEmployeeFamilyInfo(models.Model):
+ """Table for keep employee family information"""
+
+ _name = 'hr.employee.family'
+ _description = 'HR Employee Family'
+
+ employee_id = fields.Many2one('hr.employee', string="Employee", help='Select corresponding Employee',
+ invisible=1)
+ relation_id = fields.Many2one('hr.employee.relation', string="Relation", help="Relationship with the employee")
+ member_name = fields.Char(string='Name')
+ member_contact = fields.Char(string='Contact No')
+ birth_date = fields.Date(string="DOB", tracking=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 + ",<br>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 + ",<br>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,
+ help="Personal mobile number of the employee")
+ joining_date = fields.Date(string='Joining Date', help="Employee joining date computed from the contract start date",compute='compute_joining', store=True)
+ 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')
+
+ @api.depends('contract_id')
+ def compute_joining(self):
+ if self.contract_id:
+ date = min(self.contract_id.mapped('date_start'))
+ self.joining_date = date
+ else:
+ self.joining_date = False
+
+ @api.onchange('spouse_complete_name', 'spouse_birthdate')
+ def onchange_spouse(self):
+ relation = self.env.ref('hr_employee_updation.employee_relationship')
+ lines_info = []
+ spouse_name = self.spouse_complete_name
+ date = self.spouse_birthdate
+ if spouse_name and date:
+ lines_info.append((0, 0, {
+ 'member_name': spouse_name,
+ 'relation_id': relation.id,
+ 'birth_date': date,
+ })
+ )
+ self.fam_ids = [(6, 0, 0)] + lines_info
+
+
+class EmployeeRelationInfo(models.Model):
+ """Table for keep employee family information"""
+
+ _name = 'hr.employee.relation'
+
+ name = fields.Char(string="Relationship", help="Relationship with thw employee")
diff --git a/hr_employee_updation/models/updation_config.py b/hr_employee_updation/models/updation_config.py
new file mode 100644
index 0000000..34a958d
--- /dev/null
+++ b/hr_employee_updation/models/updation_config.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import fields, models, api
+
+
+class JournalConfig(models.TransientModel):
+ _inherit = ['res.config.settings']
+
+ notice_period = fields.Boolean(string='Notice Period')
+ no_of_days = fields.Integer()
+
+ def set_values(self):
+ super(JournalConfig, self).set_values()
+ self.env['ir.config_parameter'].sudo().set_param("hr_resignation.notice_period",
+ self.notice_period)
+ self.env['ir.config_parameter'].sudo().set_param("hr_resignation.no_of_days",
+ self.no_of_days)
+
+ @api.model
+ def get_values(self):
+ res = super(JournalConfig, self).get_values()
+ get_param = self.env['ir.config_parameter'].sudo().get_param
+ res['notice_period'] = get_param('hr_resignation.notice_period')
+ res['no_of_days'] = int(get_param('hr_resignation.no_of_days'))
+ return res
+
+ # @api.onchange('service_expense_journal')
+ # def onchange_accounts(self):
+ # self.service_credit_account = self.service_expense_journal.default_credit_account_id.id
+ # self.service_debit_account = self.service_expense_journal.default_debit_account_id.id