diff --git a/ohrms_loan/README.md b/ohrms_loan/README.md new file mode 100644 index 000000000..cece9af9c --- /dev/null +++ b/ohrms_loan/README.md @@ -0,0 +1,35 @@ +Open HRMS Loan Management +========================= + +Manage Loan Requests. + + +Installation +============ +- www.odoo.com/documentation/11.0/setup/install.html +- Install our custom addon + +License +======= +GNU AFFERO GENERAL PUBLIC LICENSE, Version 3 (AGPLv3) +(http://www.gnu.org/licenses/agpl.html) + +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 +------ + +Developers: Anusha P P + +Maintainer +---------- + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com. diff --git a/ohrms_loan/__init__.py b/ohrms_loan/__init__.py new file mode 100644 index 000000000..601ffa6a9 --- /dev/null +++ b/ohrms_loan/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +from . import models + diff --git a/ohrms_loan/__manifest__.py b/ohrms_loan/__manifest__.py new file mode 100644 index 000000000..9d56c2975 --- /dev/null +++ b/ohrms_loan/__manifest__.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +################################################################################### +# A part of OpenHRMS Project +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2018-TODAY Cybrosys Technologies (). +# Author: Anusha P P () +# +# 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': 'Open HRMS Loan Management', + 'version': '11.0.1.0.0', + 'summary': 'Manage Loan Requests', + 'description': """ + Helps you to manage Loan Requests of your company's staff. + """, + 'category': 'Human Resources', + 'author': "Cybrosys Techno Solutions", + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.openhrms.com", + 'depends': [ + 'base', 'hr_payroll', 'hr', 'account', + ], + 'data': [ + 'security/ir.model.access.csv', + 'security/security.xml', + 'views/hr_loan_seq.xml', + 'data/salary_rule_loan.xml', + 'views/hr_loan.xml', + 'views/hr_payroll.xml', + ], + 'demo': [], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/ohrms_loan/data/salary_rule_loan.xml b/ohrms_loan/data/salary_rule_loan.xml new file mode 100644 index 000000000..0697a81cd --- /dev/null +++ b/ohrms_loan/data/salary_rule_loan.xml @@ -0,0 +1,23 @@ + + + + + + + LO + Loan + + code + result = inputs.LO and - (inputs.LO.amount) + + + + + + LO + Loan + + + + + diff --git a/ohrms_loan/doc/RELEASE_NOTES.md b/ohrms_loan/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..6f664534a --- /dev/null +++ b/ohrms_loan/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 21.04.2018 +#### Version 11.0.1.0.0 +##### ADD +- Initial commit for Open HRMS Project diff --git a/ohrms_loan/models/__init__.py b/ohrms_loan/models/__init__.py new file mode 100644 index 000000000..c4e2501a2 --- /dev/null +++ b/ohrms_loan/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +from . import hr_loan +from . import hr_payroll + diff --git a/ohrms_loan/models/hr_loan.py b/ohrms_loan/models/hr_loan.py new file mode 100644 index 000000000..48dda7830 --- /dev/null +++ b/ohrms_loan/models/hr_loan.py @@ -0,0 +1,129 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api +from datetime import datetime +from dateutil.relativedelta import relativedelta +from odoo.exceptions import except_orm + + +class HrLoan(models.Model): + _name = 'hr.loan' + _inherit = ['mail.thread', 'mail.activity.mixin'] + _description = "Loan Request" + + @api.one + def _compute_loan_amount(self): + total_paid = 0.0 + for loan in self: + for line in loan.loan_lines: + if line.paid: + total_paid += line.amount + balance_amount = loan.loan_amount - total_paid + self.total_amount = loan.loan_amount + self.balance_amount = balance_amount + self.total_paid_amount = total_paid + + name = fields.Char(string="Loan Name", default="/", readonly=True) + date = fields.Date(string="Date", default=fields.Date.today(), readonly=True) + employee_id = fields.Many2one('hr.employee', string="Employee", required=True) + department_id = fields.Many2one('hr.department', related="employee_id.department_id", readonly=True, + string="Department") + installment = fields.Integer(string="No Of Installments", default=1) + payment_date = fields.Date(string="Payment Start Date", required=True, default=fields.Date.today()) + loan_lines = fields.One2many('hr.loan.line', 'loan_id', string="Loan Line", index=True) + emp_account_id = fields.Many2one('account.account', string="Loan Account") + treasury_account_id = fields.Many2one('account.account', string="Treasury Account") + journal_id = fields.Many2one('account.journal', string="Journal") + company_id = fields.Many2one('res.company', 'Company', readonly=True, + default=lambda self: self.env.user.company_id, + states={'draft': [('readonly', False)]}) + currency_id = fields.Many2one('res.currency', string='Currency', required=True, + default=lambda self: self.env.user.company_id.currency_id) + job_position = fields.Many2one('hr.job', related="employee_id.job_id", readonly=True, string="Job Position") + loan_amount = fields.Float(string="Loan Amount", required=True) + total_amount = fields.Float(string="Total Amount", readonly=True, compute='_compute_loan_amount') + balance_amount = fields.Float(string="Balance Amount", compute='_compute_loan_amount') + total_paid_amount = fields.Float(string="Total Paid Amount", compute='_compute_loan_amount') + + state = fields.Selection([ + ('draft', 'Draft'), + ('waiting_approval_1', 'Submitted'), + ('waiting_approval_2', 'Waiting Approval'), + ('approve', 'Approved'), + ('refuse', 'Refused'), + ('cancel', 'Canceled'), + ], string="State", default='draft', track_visibility='onchange', copy=False, ) + + @api.model + def create(self, values): + loan_count = self.env['hr.loan'].search_count([('employee_id', '=', values['employee_id']), ('state', '=', 'approve'), + ('balance_amount', '!=', 0)]) + if loan_count: + raise except_orm('Error!', 'The employee has already a pending installment') + else: + values['name'] = self.env['ir.sequence'].get('hr.loan.seq') or ' ' + res = super(HrLoan, self).create(values) + return res + + @api.multi + def action_refuse(self): + return self.write({'state': 'refuse'}) + + @api.multi + def action_submit(self): + self.write({'state': 'waiting_approval_1'}) + + @api.multi + def action_cancel(self): + self.write({'state': 'cancel'}) + + @api.multi + def action_approve(self): + for data in self: + if not data.loan_lines: + raise except_orm('Error!', 'Please Compute installment') + else: + self.write({'state': 'approve'}) + + @api.multi + def compute_installment(self): + """This automatically create the installment the employee need to pay to + company based on payment start date and the no of installments. + """ + for loan in self: + date_start = datetime.strptime(loan.payment_date, '%Y-%m-%d') + amount = loan.loan_amount / loan.installment + for i in range(1, loan.installment + 1): + self.env['hr.loan.line'].create({ + 'date': date_start, + 'amount': amount, + 'employee_id': loan.employee_id.id, + 'loan_id': loan.id}) + date_start = date_start + relativedelta(months=1) + return True + + +class InstallmentLine(models.Model): + _name = "hr.loan.line" + _description = "Installment Line" + + date = fields.Date(string="Payment Date", required=True) + employee_id = fields.Many2one('hr.employee', string="Employee") + amount = fields.Float(string="Amount", required=True) + paid = fields.Boolean(string="Paid") + loan_id = fields.Many2one('hr.loan', string="Loan Ref.") + payslip_id = fields.Many2one('hr.payslip', string="Payslip Ref.") + + +class HrEmployee(models.Model): + _inherit = "hr.employee" + + @api.one + def _compute_employee_loans(self): + """This compute the loan amount and total loans count of an employee. + """ + self.loan_count = self.env['hr.loan'].search_count([('employee_id', '=', self.id)]) + + loan_count = fields.Integer(string="Loan Count", compute='_compute_employee_loans') + + diff --git a/ohrms_loan/models/hr_payroll.py b/ohrms_loan/models/hr_payroll.py new file mode 100644 index 000000000..655f6d7a9 --- /dev/null +++ b/ohrms_loan/models/hr_payroll.py @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- +import time +import babel +from odoo import models, fields, api, tools, _ +from datetime import datetime + + +class HrPayslipInput(models.Model): + _inherit = 'hr.payslip.input' + + loan_line_id = fields.Many2one('hr.loan.line', string="Loan Installment") + + +class HrPayslip(models.Model): + _inherit = 'hr.payslip' + + @api.onchange('employee_id', 'date_from', 'date_to') + def onchange_employee(self): + if (not self.employee_id) or (not self.date_from) or (not self.date_to): + return + + employee = self.employee_id + date_from = self.date_from + date_to = self.date_to + contract_ids = [] + + ttyme = datetime.fromtimestamp(time.mktime(time.strptime(date_from, "%Y-%m-%d"))) + locale = self.env.context.get('lang') or 'en_US' + self.name = _('Salary Slip of %s for %s') % ( + employee.name, tools.ustr(babel.dates.format_date(date=ttyme, format='MMMM-y', locale=locale))) + self.company_id = employee.company_id + + if not self.env.context.get('contract') or not self.contract_id: + contract_ids = self.get_contract(employee, date_from, date_to) + if not contract_ids: + return + self.contract_id = self.env['hr.contract'].browse(contract_ids[0]) + + if not self.contract_id.struct_id: + return + self.struct_id = self.contract_id.struct_id + + # computation of the salary input + contracts = self.env['hr.contract'].browse(contract_ids) + worked_days_line_ids = self.get_worked_day_lines(contracts, date_from, date_to) + worked_days_lines = self.worked_days_line_ids.browse([]) + for r in worked_days_line_ids: + worked_days_lines += worked_days_lines.new(r) + self.worked_days_line_ids = worked_days_lines + if contracts: + input_line_ids = self.get_inputs(contracts, date_from, date_to) + input_lines = self.input_line_ids.browse([]) + print input_line_ids, "input_line_ids" + for r in input_line_ids: + input_lines += input_lines.new(r) + self.input_line_ids = input_lines + return + + def get_inputs(self, contract_ids, date_from, date_to): + """This Compute the other inputs to employee payslip. + """ + res = super(HrPayslip, self).get_inputs(contract_ids, date_from, date_to) + contract_obj = self.env['hr.contract'] + emp_id = contract_obj.browse(contract_ids[0].id).employee_id + lon_obj = self.env['hr.loan'].search([('employee_id', '=', emp_id.id), ('state', '=', 'approve')]) + for loan in lon_obj: + for loan_line in loan.loan_lines: + if date_from <= loan_line.date <= date_to and not loan_line.paid: + for result in res: + if result.get('code') == 'LO': + result['amount'] = loan_line.amount + result['loan_line_id'] = loan_line.id + return res + + @api.multi + def action_payslip_done(self): + for line in self.input_line_ids: + if line.loan_line_id: + line.loan_line_id.paid = True + return super(HrPayslip, self).action_payslip_done() diff --git a/ohrms_loan/security/ir.model.access.csv b/ohrms_loan/security/ir.model.access.csv new file mode 100644 index 000000000..e5b282ebc --- /dev/null +++ b/ohrms_loan/security/ir.model.access.csv @@ -0,0 +1,17 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_hr_loan_user,hr.loan.group_user,model_hr_loan,base.group_user,1,1,1,0 +access_hr_loan_line_user,hr.loan.line.group_user,model_hr_loan_line,base.group_user,1,1,0,0 +access_hr_loan_officer,hr.loan.group_hr_user,model_hr_loan,hr.group_hr_user,1,1,1,1 +access_hr_loan_line_officer,hr.loan.line.group_hr_user,model_hr_loan_line,hr.group_hr_user,1,1,1,1 +access_account_move_uinvoice_officer,account.move.group_hr_user,account.model_account_move,hr.group_hr_user,1,1,1,1 +access_account_journal_uinvoice_officer,account.journal.group_hr_user,account.model_account_journal,hr.group_hr_user,1,1,1,1 +acces_account_move_line_officer,account.move.line.group_hr_user,account.model_account_move_line,hr.group_hr_user,1,1,1,1 +acces_ account_account_type_officer, account.account.type.group_hr_user,account.model_account_account_type,hr.group_hr_user,1,1,1,1 +access_hr_loan_manager,hr.loan,model_hr_loan,hr.group_hr_manager,1,1,1,1 +access_hr_loan_line_manager,hr.loan.line,model_hr_loan_line,hr.group_hr_manager,1,1,1,1 +access_account_move_uinvoice_manager,account.move,account.model_account_move,hr.group_hr_manager,1,1,1,1 +access_account_journal_uinvoice_manager,account.journal,account.model_account_journal,hr.group_hr_manager,1,1,1,1 +acces_account_move_line_manager,account.move.line,account.model_account_move_line,hr.group_hr_manager,1,1,1,1 +acces_ account_account_type_manager, account.account.type,account.model_account_account_type,hr.group_hr_manager,1,1,1,1 +access_hr_loan_accountant,hr.loan,model_hr_loan,account.group_account_user,1,1,1,0 +access_hr_loan_line_accountant,hr.loan.line,model_hr_loan_line,account.group_account_user,1,1,1,0 \ No newline at end of file diff --git a/ohrms_loan/security/security.xml b/ohrms_loan/security/security.xml new file mode 100644 index 000000000..5a99058e7 --- /dev/null +++ b/ohrms_loan/security/security.xml @@ -0,0 +1,35 @@ + + + + + Loan Request Multi Company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + + Loan Forms 4 + + + + + + + + + + + Loan Forms + [('employee_id.user_id','=',user.id)] + + + + + + + + + + + \ No newline at end of file diff --git a/ohrms_loan/static/description/HRMS-BUTTON.png b/ohrms_loan/static/description/HRMS-BUTTON.png new file mode 100644 index 000000000..0f1b65bea Binary files /dev/null and b/ohrms_loan/static/description/HRMS-BUTTON.png differ diff --git a/ohrms_loan/static/description/accounting_validation.png b/ohrms_loan/static/description/accounting_validation.png new file mode 100644 index 000000000..134310d78 Binary files /dev/null and b/ohrms_loan/static/description/accounting_validation.png differ diff --git a/ohrms_loan/static/description/banner.jpg b/ohrms_loan/static/description/banner.jpg new file mode 100644 index 000000000..4be55a5aa Binary files /dev/null and b/ohrms_loan/static/description/banner.jpg differ diff --git a/ohrms_loan/static/description/cybro-service.png b/ohrms_loan/static/description/cybro-service.png new file mode 100644 index 000000000..252929a86 Binary files /dev/null and b/ohrms_loan/static/description/cybro-service.png differ diff --git a/ohrms_loan/static/description/cybro_logo.png b/ohrms_loan/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/ohrms_loan/static/description/cybro_logo.png differ diff --git a/ohrms_loan/static/description/icon.png b/ohrms_loan/static/description/icon.png new file mode 100644 index 000000000..e90809a0f Binary files /dev/null and b/ohrms_loan/static/description/icon.png differ diff --git a/ohrms_loan/static/description/index.html b/ohrms_loan/static/description/index.html new file mode 100644 index 000000000..a1889f566 --- /dev/null +++ b/ohrms_loan/static/description/index.html @@ -0,0 +1,169 @@ +
+
+
+

Open HRMS

+

Most advanced open source HR management software

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

Open HRMS Loan

+

Manage Loan request of employees

+

Cybrosys Technologies

+
+
+

Features:

+
+ Employee can create loan request.
+ Double layer approval, from Accounting & HR Department.
+ Current month installment is automatically listed in payslip.
+ Loan amount is deducted from the salary.
+
+
+
+ +
+
+
+
+

Overview

+

+ Open HRMS Loan is a component of Open HRMS suit. + Open HRMS Loan module helps the user to configure different loan policies, assign approval authority, conduct the verification process and sanction loan for employees. +

+
+
+
+
+ +
+
+
+

Configuration

+
+
+

Install the Module "Open HRMS Loan Accounting" in order to enable Accounting Entries. + Enable the option "Loan Approval From Accounting Department" In accounting settings

+
+
+ +
+
+
+
+

Add the deduction rule for loan in Salary Structure

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

Loan Request

+

Employee can create loan request

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

Loan Approval

+

Once the HR department has given the Approval, the accounts department take the decision

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

Employee Payslip

+

When we create the payslip, all the pending installments of the month will be listed there. +

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

Loan Amount Deduction

+

When we check the Loan request again, + the deducted installments will be changed to paid.

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

Our Odoo Services

+
+
+ + +
+

Need Any Help?

+ +
diff --git a/ohrms_loan/static/description/loan_amount_deduction.png b/ohrms_loan/static/description/loan_amount_deduction.png new file mode 100644 index 000000000..a6cdded26 Binary files /dev/null and b/ohrms_loan/static/description/loan_amount_deduction.png differ diff --git a/ohrms_loan/static/description/loan_approval.png b/ohrms_loan/static/description/loan_approval.png new file mode 100644 index 000000000..ceeb2d817 Binary files /dev/null and b/ohrms_loan/static/description/loan_approval.png differ diff --git a/ohrms_loan/static/description/loan_request.png b/ohrms_loan/static/description/loan_request.png new file mode 100644 index 000000000..6d3157db4 Binary files /dev/null and b/ohrms_loan/static/description/loan_request.png differ diff --git a/ohrms_loan/static/description/loan_rule.png b/ohrms_loan/static/description/loan_rule.png new file mode 100644 index 000000000..330b72cef Binary files /dev/null and b/ohrms_loan/static/description/loan_rule.png differ diff --git a/ohrms_loan/static/description/payslip.png b/ohrms_loan/static/description/payslip.png new file mode 100644 index 000000000..772d7d1f6 Binary files /dev/null and b/ohrms_loan/static/description/payslip.png differ diff --git a/ohrms_loan/views/hr_loan.xml b/ohrms_loan/views/hr_loan.xml new file mode 100644 index 000000000..5e6448ece --- /dev/null +++ b/ohrms_loan/views/hr_loan.xml @@ -0,0 +1,162 @@ + + + + + + hr.loan.tree + hr.loan + + + + + + + + + + + + + + hr.loan.form + hr.loan + +
+
+
+ + +
+
+
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/ohrms_loan/views/hr_loan_seq.xml b/ohrms_loan/views/hr_loan_seq.xml new file mode 100644 index 000000000..b4a33e38e --- /dev/null +++ b/ohrms_loan/views/hr_loan_seq.xml @@ -0,0 +1,14 @@ + + + + + Loan Request + hr.loan.seq + LO/ + 4 + 1 + 1 + standard + + + \ No newline at end of file diff --git a/ohrms_loan/views/hr_payroll.xml b/ohrms_loan/views/hr_payroll.xml new file mode 100644 index 000000000..79d177c69 --- /dev/null +++ b/ohrms_loan/views/hr_payroll.xml @@ -0,0 +1,13 @@ + + + + hr.payslip.inherit.form1 + hr.payslip + + + + + + + + \ No newline at end of file