diff --git a/hr_insurance/README.rst b/hr_insurance/README.rst new file mode 100644 index 000000000..f5cae3780 --- /dev/null +++ b/hr_insurance/README.rst @@ -0,0 +1,39 @@ +OHRMS Employee Insurance Management v10 +======================================= + +Employee insurance management for Open HRMS. + +Depends +======= +[hr] addon Odoo + +Tech +==== +* [Python] - Models +* [XML] - Odoo views + +Installation +============ +- www.odoo.com/documentation/10.0/setup/install.html +- Install our custom addon + + +Bug Tracker +=========== +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Credits +======= +* Cybrosys Techno Solutions + +Author +------ + +Developer: Treesa Maria Jude @ cybrosys, treesa@cybrosys.in + +Maintainer +---------- + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com. diff --git a/hr_insurance/RELEASE_NOTES.md b/hr_insurance/RELEASE_NOTES.md new file mode 100644 index 000000000..1d80f982a --- /dev/null +++ b/hr_insurance/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module hr_insurance + +#### 30.03.2018 +#### Version 10.0.1.0.0 +##### ADD +- Initial commit for OpenHrms Project diff --git a/hr_insurance/__init__.py b/hr_insurance/__init__.py new file mode 100644 index 000000000..1609385da --- /dev/null +++ b/hr_insurance/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Treesa Maria Jude () +# +# 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 . import models diff --git a/hr_insurance/__manifest__.py b/hr_insurance/__manifest__.py new file mode 100644 index 000000000..42fa4accb --- /dev/null +++ b/hr_insurance/__manifest__.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Treesa Maria Jude () +# +# 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 . +# +################################################################################### + +{ + 'name': 'OHRMS Employee Insurance Management', + 'version': '10.0.1.0.0', + 'summary': """Employee Insurance Management for Open HRMS.""", + 'description': """Manages insurance amounts for employees to be deducted from salary""", + 'category': 'Human Resources', + 'author': 'Cybrosys Techno solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'https://www.openhrms.com', + 'depends': [ + 'base', 'hr', 'hr_payroll', + ], + 'data': [ + 'security/ir.model.access.csv', + 'security/hr_insurance_security.xml', + 'views/employee_insurance_view.xml', + 'views/insurance_salary_stucture.xml', + 'views/policy_management.xml', + ], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} \ No newline at end of file diff --git a/hr_insurance/models/__init__.py b/hr_insurance/models/__init__.py new file mode 100644 index 000000000..d83103344 --- /dev/null +++ b/hr_insurance/models/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Treesa Maria Jude () +# +# 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 . import policy_details +from . import employee_insurance diff --git a/hr_insurance/models/employee_insurance.py b/hr_insurance/models/employee_insurance.py new file mode 100644 index 000000000..bd6cf5d58 --- /dev/null +++ b/hr_insurance/models/employee_insurance.py @@ -0,0 +1,121 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Treesa Maria Jude () +# +# 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 . +# +################################################################################### + +import time +from datetime import datetime +from dateutil import relativedelta +from odoo import models, fields, api, _ + + +class EmployeeInsurance(models.Model): + _name = 'hr.insurance' + _description = 'HR Insurance' + _rec_name = 'employee_id' + + employee_id = fields.Many2one('hr.employee', string='Employee', required=True) + policy_id = fields.Many2one('insurance.policy', string='Policy', required=True) + amount = fields.Float(string='Policy Amount', required=True) + sum_insured = fields.Float(string="Sum Insured", required=True) + policy_coverage = fields.Selection([('monthly', 'Monthly'), ('yearly', 'Yearly')], + required=True, default='monthly', + string='Policy Coverage',) + date_from = fields.Date(string='Date From', + default=time.strftime('%Y-%m-%d'), readonly=True) + date_to = fields.Date(string='Date To', readonly=True, + default=str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10]) + state = fields.Selection([('active', 'Active'), + ('expired', 'Expired'), ], + default='active', string="State",compute='get_status') + company_id = fields.Many2one('res.company', string='Company', required=True, + default=lambda self: self.env.user.company_id) + + def get_status(self): + current_datetime = datetime.now() + for i in self: + x = datetime.strptime(i.date_from, '%Y-%m-%d') + y = datetime.strptime(i.date_to, '%Y-%m-%d') + print x + print current_datetime + print y + if x <= current_datetime and y >= current_datetime: + i.state = 'active' + + else: + i.state = 'expired' + + @api.constrains('policy_coverage') + @api.onchange('policy_coverage') + def get_policy_period(self): + + if self.policy_coverage == 'monthly': + self.date_to = str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10] + if self.policy_coverage == 'yearly': + self.date_to = str(datetime.now() + relativedelta.relativedelta(months=+12))[:10] + + +class HrInsurance(models.Model): + _inherit = 'hr.employee' + + insurance_percentage = fields.Float(string="Company Percentage ") + deduced_amount_per_month = fields.Float(string="Salary deduced per month", compute="get_deduced_amount") + deduced_amount_per_year = fields.Float(string="Salary deduced per year", compute="get_deduced_amount") + insurance = fields.One2many('hr.insurance', 'employee_id', string="Insurance", + domain=[('state', '=', 'active')]) + + def get_deduced_amount(self): + current_datetime = datetime.now() + for emp in self: + ins_amount = 0 + for ins in emp.insurance: + + x = datetime.strptime(ins.date_from, '%Y-%m-%d') + y = datetime.strptime(ins.date_to, '%Y-%m-%d') + if x < current_datetime and y > current_datetime: + if ins.policy_coverage == 'monthly': + + ins_amount = ins_amount + (ins.amount*12) + else: + + ins_amount = ins_amount + ins.amount + + emp.deduced_amount_per_year = ins_amount-((ins_amount*emp.insurance_percentage)/100) + emp.deduced_amount_per_month = emp.deduced_amount_per_year/12 + + +class InsuranceRuleInput(models.Model): + _inherit = 'hr.payslip' + + # insurance_amount = fields.Float("Insurance amount", compute='get_inputs') + + def get_inputs(self, contract_ids, date_from, date_to): + """This Compute the other inputs to employee payslip. + """ + res = super(InsuranceRuleInput, self).get_inputs(contract_ids, date_from, date_to) + + contract_obj = self.env['hr.contract'] + emp_id = contract_obj.browse(contract_ids[0]).employee_id + for result in res: + if emp_id.deduced_amount_per_month != 0 and result.get('code') == 'INSUR': + result['amount'] = emp_id.deduced_amount_per_month + return res + diff --git a/hr_insurance/models/policy_details.py b/hr_insurance/models/policy_details.py new file mode 100644 index 000000000..0b0b07866 --- /dev/null +++ b/hr_insurance/models/policy_details.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Treesa Maria Jude () +# +# 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 odoo import models, fields, api + + +class InsurancePolicy(models.Model): + _name = 'insurance.policy' + + name = fields.Char(string='Name', required=True) + note_field = fields.Html(string='Comment') + company_id = fields.Many2one('res.company', string='Company', required=True, + default=lambda self: self.env.user.company_id) diff --git a/hr_insurance/security/hr_insurance_security.xml b/hr_insurance/security/hr_insurance_security.xml new file mode 100644 index 000000000..e96c9cb84 --- /dev/null +++ b/hr_insurance/security/hr_insurance_security.xml @@ -0,0 +1,16 @@ + + + + Hr Insurancy Company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + + Hr Insurance Policy company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + \ No newline at end of file diff --git a/hr_insurance/security/ir.model.access.csv b/hr_insurance/security/ir.model.access.csv new file mode 100644 index 000000000..030098bdb --- /dev/null +++ b/hr_insurance/security/ir.model.access.csv @@ -0,0 +1,8 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink + +access_hr_insurance_policy_officer,hr.insurance_policy.officer,hr_insurance.model_insurance_policy,hr.group_hr_user,1,1,1,1 +access_hr_insurance_policy_employee,hr.insurance_policy.employee,hr_insurance.model_insurance_policy,hr.group_hr_manager,1,1,1,1 +access_hr_insurance_policy_manager,hr.insurance_policy.manager,hr_insurance.model_insurance_policy,base.group_user,1,0,0,0 +access_hr_insurance_officer,hr.insurance.officer,hr_insurance.model_hr_insurance,hr.group_hr_user,1,1,1,1 +access_hr_insurance_employee,hr.insurance.employee,hr_insurance.model_hr_insurance,hr.group_hr_manager,1,1,1,1 +access_hr_insurance_manager,hr.insurance.manager,hr_insurance.model_hr_insurance,base.group_user,1,0,0,0 diff --git a/hr_insurance/static/description/HRMS-BUTTON.png b/hr_insurance/static/description/HRMS-BUTTON.png new file mode 100644 index 000000000..0f1b65bea Binary files /dev/null and b/hr_insurance/static/description/HRMS-BUTTON.png differ diff --git a/hr_insurance/static/description/banner.jpg b/hr_insurance/static/description/banner.jpg new file mode 100644 index 000000000..f64af7d11 Binary files /dev/null and b/hr_insurance/static/description/banner.jpg differ diff --git a/hr_insurance/static/description/cybro-service.png b/hr_insurance/static/description/cybro-service.png new file mode 100644 index 000000000..252929a86 Binary files /dev/null and b/hr_insurance/static/description/cybro-service.png differ diff --git a/hr_insurance/static/description/cybro_logo.png b/hr_insurance/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/hr_insurance/static/description/cybro_logo.png differ diff --git a/hr_insurance/static/description/employee.png b/hr_insurance/static/description/employee.png new file mode 100644 index 000000000..aedb04779 Binary files /dev/null and b/hr_insurance/static/description/employee.png differ diff --git a/hr_insurance/static/description/icon.png b/hr_insurance/static/description/icon.png new file mode 100644 index 000000000..b65b2782f Binary files /dev/null and b/hr_insurance/static/description/icon.png differ diff --git a/hr_insurance/static/description/index.html b/hr_insurance/static/description/index.html new file mode 100644 index 000000000..9dfc661a4 --- /dev/null +++ b/hr_insurance/static/description/index.html @@ -0,0 +1,113 @@ +
+
+

OpenHRMS

+

Most advanced open source HR management software

+
+
+
+
+
+
+ + + +
+
+
+
+ +
+
+

OHRMS Employee Insurance Management

+

Employee Insurance Management for OHRMS

+

Cybrosys Technologies , www.cybrosys.com

+

+ This module allows tracking the insurance details allowed for employees. Also + efficiently manages the insurance allowances with the salary. You can manage + the percentage of insurance amount to be deduced from the salary. +

+
+
+ +
+
+

Set Insurance For Employees

+
+ +
+
+
+ +
+
+
+
+ + +
+
+

Policy Management

+ +
+
+ +
+
+ +
+
+ + +
+
+
+

Employee Insurance Details

+ +
+
+
+ +
+
+
+ +
+
+
+

Amount Deduced On Payslip

+
+
+
+ +
+
+
+ +
+
+

Our Odoo Services

+ + +
+ +
+ +
+

Need Any Help?

+ +
+ diff --git a/hr_insurance/static/description/insurance.png b/hr_insurance/static/description/insurance.png new file mode 100644 index 000000000..c6ebe5d9e Binary files /dev/null and b/hr_insurance/static/description/insurance.png differ diff --git a/hr_insurance/static/description/payslip.png b/hr_insurance/static/description/payslip.png new file mode 100644 index 000000000..d9cc5b743 Binary files /dev/null and b/hr_insurance/static/description/payslip.png differ diff --git a/hr_insurance/static/description/policy.png b/hr_insurance/static/description/policy.png new file mode 100644 index 000000000..9c15d8646 Binary files /dev/null and b/hr_insurance/static/description/policy.png differ diff --git a/hr_insurance/views/employee_insurance_view.xml b/hr_insurance/views/employee_insurance_view.xml new file mode 100644 index 000000000..af2fc270c --- /dev/null +++ b/hr_insurance/views/employee_insurance_view.xml @@ -0,0 +1,105 @@ + + + + + + hr.employee.Insurance_form + hr.employee + + + + + + + % + + + + + + + + + + + + + + + + + + Employee Insurance + hr.insurance + +
+
+ +
+ + + + + + + + + + + + + + + + + + +
+
+
+ + Employee Insurance + hr.insurance + + + + + + + + + + + + + + + Employee Insurance + hr.insurance + form + tree,form + +

+ You have'nt created any policy yet. +

+
+
+ + + + +
+
\ No newline at end of file diff --git a/hr_insurance/views/insurance_salary_stucture.xml b/hr_insurance/views/insurance_salary_stucture.xml new file mode 100644 index 000000000..46d8b7285 --- /dev/null +++ b/hr_insurance/views/insurance_salary_stucture.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + INSUR + Insurance Amount + + code + result = -(inputs.INSUR.amount) + + + + + + INSUR + Insurance Amount + + + + + + + \ No newline at end of file diff --git a/hr_insurance/views/policy_management.xml b/hr_insurance/views/policy_management.xml new file mode 100644 index 000000000..1766e5e3c --- /dev/null +++ b/hr_insurance/views/policy_management.xml @@ -0,0 +1,59 @@ + + + + + Insurance Policy Details + insurance.policy + +
+ + + + + + + + + + + + + + + + + + +
+
+
+ + Insurance Policy Details + insurance.policy + + + + + + + + + Insurance Policy + insurance.policy + form + tree,form + +

+ You have'nt created any policy yet. +

+
+
+ + +
+
+