diff --git a/hr_loan/README.md b/hr_loan/README.md new file mode 100644 index 000000000..2419a37ea --- /dev/null +++ b/hr_loan/README.md @@ -0,0 +1,35 @@ +OHRMS Loan Management +===================== + +Manage Loan Requests. + + +Installation +============ +- www.odoo.com/documentation/10.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/hr_loan/__init__.py b/hr_loan/__init__.py new file mode 100644 index 000000000..268881c69 --- /dev/null +++ b/hr_loan/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +import models + diff --git a/hr_loan/__manifest__.py b/hr_loan/__manifest__.py new file mode 100644 index 000000000..56a940248 --- /dev/null +++ b/hr_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': 'OHRMS Loan Management', + 'version': '10.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': [ + 'hr_payroll', 'hr', 'account', + ], + 'data': [ + 'security/ir.model.access.csv', + 'security/security.xml', + 'views/hr_loan_sequence.xml', + 'data/hr_payroll_data.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/hr_loan/data/hr_payroll_data.xml b/hr_loan/data/hr_payroll_data.xml new file mode 100644 index 000000000..a49ecf484 --- /dev/null +++ b/hr_loan/data/hr_payroll_data.xml @@ -0,0 +1,21 @@ + + + + + + Loan + + LO + + none + code + result = -payslip.total_amount_paid + + + + LO + Loan + + + + \ No newline at end of file diff --git a/hr_loan/models/__init__.py b/hr_loan/models/__init__.py new file mode 100644 index 000000000..aacd08ad3 --- /dev/null +++ b/hr_loan/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +import hr_loan +import hr_payroll + diff --git a/hr_loan/models/hr_loan.py b/hr_loan/models/hr_loan.py new file mode 100644 index 000000000..f29e2b397 --- /dev/null +++ b/hr_loan/models/hr_loan.py @@ -0,0 +1,173 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api +from datetime import datetime +from dateutil.relativedelta import relativedelta + + +class HrLoan(models.Model): + _name = 'hr.loan' + _inherit = ['mail.thread', 'ir.needaction_mixin'] + _description = "HR Loan Request" + + @api.one + def _compute_amount(self): + total_paid_amount = 0.00 + for loan in self: + for line in loan.loan_line_ids: + if line.paid: + total_paid_amount += line.paid_amount + balance_amount = loan.loan_amount - total_paid_amount + self.total_amount = loan.loan_amount + self.balance_amount = balance_amount + self.total_paid_amount = total_paid_amount + + @api.one + def _get_old_loan(self): + """This compute employees old loans due amount. + """ + old_amount = 0.00 + for loan in self.search([('employee_id', '=', self.employee_id.id), ('state', '=', 'approve')]): + if loan.id != self.id: + old_amount += loan.balance_amount + self.loan_old_amount = old_amount + + name = fields.Char(string="Loan Name", default="/", readonly=True) + date = fields.Date(string="Date Request", default=fields.Date.today(), readonly=True) + employee_id = fields.Many2one('hr.employee', string="Employee", required=True) + parent_id = fields.Many2one('hr.employee', related="employee_id.parent_id", string="Manager") + department_id = fields.Many2one('hr.department', related="employee_id.department_id", readonly=True, + string="Department") + job_id = fields.Many2one('hr.job', related="employee_id.job_id", readonly=True, string="Job Position") + emp_salary = fields.Float(string="Employee Salary", related="employee_id.contract_id.wage", readonly=True) + loan_old_amount = fields.Float(string="Old Loan Amount Not Paid", compute='_get_old_loan') + loan_amount = fields.Float(string="Loan Amount", required=True) + total_amount = fields.Float(string="Total Amount", readonly=True, compute='_compute_amount') + balance_amount = fields.Float(string="Balance Amount", compute='_compute_amount') + total_paid_amount = fields.Float(string="Total Paid Amount", compute='_compute_amount') + installment = fields.Integer(string="No Of Installments", default=1) + payment_start_date = fields.Date(string="Start Date of Payment", required=True, default=fields.Date.today()) + loan_line_ids = fields.One2many('hr.loan.line', 'loan_id', string="Loan Line", index=True) + move_id = fields.Many2one('account.move', string="Entry Journal", readonly=True) + emp_account_id = fields.Many2one('account.account', string="Employee 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) + state = fields.Selection([ + ('draft', 'Draft'), + ('waiting_approval_1', 'Waiting Approval From Hr'), + ('waiting_approval_2', 'Waiting Approval From Accounts'), + ('approve', 'Approved'), + ('refuse', 'Refused'), + ], string="State", default='draft', track_visibility='onchange', copy=False, ) + + @api.model + def create(self, values): + values['name'] = self.env['ir.sequence'].get('hr.loan.req') or ' ' + res = super(HrLoan, self).create(values) + return res + + @api.multi + def action_refuse(self): + return self.write({'state': 'refuse'}) + + @api.multi + def action_set_to_draft(self): + return self.write({'state': 'draft'}) + + @api.multi + def submit(self): + self.write({'state': 'waiting_approval_1'}) + + @api.multi + def onchange_employee_id(self, employee_id=False): + old_amount = 0.00 + if employee_id: + for loan in self.search([('employee_id', '=', employee_id), ('state', '=', 'approve')]): + if loan.id != self.id: + old_amount += loan.balance_amount + return { + 'value': { + 'loan_old_amount': old_amount} + } + + @api.multi + def action_approve(self): + self.write({'state': 'approve'}) + + @api.multi + def compute_loan_line(self): + """This automatically create the installment the employee need to pay to + company based on payment start date and the no of installments. + """ + loan_line = self.env['hr.loan.line'] + loan_line.search([('loan_id', '=', self.id)]).unlink() + for loan in self: + date_start_str = datetime.strptime(loan.payment_start_date, '%Y-%m-%d') + counter = 1 + amount_per_time = loan.loan_amount / loan.installment + for i in range(1, loan.installment + 1): + line_id = loan_line.create({ + 'paid_date': date_start_str, + 'paid_amount': amount_per_time, + 'employee_id': loan.employee_id.id, + 'loan_id': loan.id}) + counter += 1 + date_start_str = date_start_str + relativedelta(months=1) + + return True + + @api.multi + def button_reset_balance_total(self): + """This function recompute the balance. + """ + total_paid_amount = 0.00 + for loan in self: + for line in loan.loan_line_ids: + if line.paid: + total_paid_amount += line.paid_amount + balance_amount = loan.loan_amount - total_paid_amount + self.write({'total_paid_amount': total_paid_amount, 'balance_amount': balance_amount}) + + +class HrLoanLine(models.Model): + _name = "hr.loan.line" + _description = "HR Loan Request Line" + + paid_date = fields.Date(string="Payment Date", required=True) + employee_id = fields.Many2one('hr.employee', string="Employee") + paid_amount = fields.Float(string="Paid Amount", required=True) + paid = fields.Boolean(string="Paid") + notes = fields.Text(string="Notes") + loan_id = fields.Many2one('hr.loan', string="Loan Ref.", ondelete='cascade') + payroll_id = fields.Many2one('hr.payslip', string="Payslip Ref.") + + @api.one + def action_paid_amount(self): + return self.write({'paid': True}) + + +class HrEmployee(models.Model): + _inherit = "hr.employee" + + @api.one + def _compute_loans(self): + """This compute the loan amount and total loans count of an employee. + """ + count = 0 + loan_remain_amount = 0.00 + loan_ids = self.env['hr.loan'].search([('employee_id', '=', self.id)]) + for loan in loan_ids: + loan_remain_amount += loan.balance_amount + count += 1 + self.loan_count = count + self.loan_amount = loan_remain_amount + + loan_amount = fields.Float(string="loan Amount", compute='_compute_loans') + loan_count = fields.Integer(string="Loan Count", compute='_compute_loans') + + diff --git a/hr_loan/models/hr_payroll.py b/hr_loan/models/hr_payroll.py new file mode 100644 index 000000000..853eadd20 --- /dev/null +++ b/hr_loan/models/hr_payroll.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +from odoo import models, fields, api + + +class HrPayslip(models.Model): + _inherit = 'hr.payslip' + + @api.one + def compute_total_paid_loan(self): + """This compute the total paid amount of Loan. + """ + total = 0.00 + for line in self.loan_ids: + if line.paid: + total += line.paid_amount + self.total_amount_paid = total + + loan_ids = fields.One2many('hr.loan.line', 'payroll_id', string="Loans") + total_amount_paid = fields.Float(string="Total Loan Amount", compute='compute_total_paid_loan') + + @api.multi + def get_loan(self): + """This gives the installment lines of an employee where the state is not in paid. + """ + array = [] + loan_ids = self.env['hr.loan.line'].search([('employee_id', '=', self.employee_id.id), ('paid', '=', False)]) + for loan in loan_ids: + if loan.loan_id.state == 'approve': + array.append(loan.id) + self.loan_ids = array + return array + + @api.multi + def action_payslip_done(self): + array = [] + for line in self.loan_ids: + if line.paid: + array.append(line.id) + else: + line.payroll_id = False + self.loan_ids = array + return super(HrPayslip, self).action_payslip_done() diff --git a/hr_loan/security/ir.model.access.csv b/hr_loan/security/ir.model.access.csv new file mode 100644 index 000000000..9b79840d8 --- /dev/null +++ b/hr_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,model_hr_loan,base.group_user,1,1,1,0 +access_hr_loan_line_user,hr.loan.line,model_hr_loan_line,base.group_user,1,1,0,0 +access_hr_loan_officer,hr.loan,model_hr_loan,hr.group_hr_user,1,1,1,1 +access_hr_loan_line_officer,hr.loan.line,model_hr_loan_line,hr.group_hr_user,1,1,1,1 +access_account_move_uinvoice_officer,account.move,account.model_account_move,hr.group_hr_user,1,1,1,1 +access_account_journal_uinvoice_officer,account.journal,account.model_account_journal,hr.group_hr_user,1,1,1,1 +acces_account_move_line_officer,account.move.line,account.model_account_move_line,hr.group_hr_user,1,1,1,1 +acces_ account_account_type_officer, account.account.type,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/hr_loan/security/security.xml b/hr_loan/security/security.xml new file mode 100644 index 000000000..5a99058e7 --- /dev/null +++ b/hr_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/hr_loan/static/description/HRMS-BUTTON.png b/hr_loan/static/description/HRMS-BUTTON.png new file mode 100644 index 000000000..0f1b65bea Binary files /dev/null and b/hr_loan/static/description/HRMS-BUTTON.png differ diff --git a/hr_loan/static/description/accounting_validation.png b/hr_loan/static/description/accounting_validation.png new file mode 100644 index 000000000..1f8537f24 Binary files /dev/null and b/hr_loan/static/description/accounting_validation.png differ diff --git a/hr_loan/static/description/banner.jpg b/hr_loan/static/description/banner.jpg new file mode 100644 index 000000000..ac30fc219 Binary files /dev/null and b/hr_loan/static/description/banner.jpg differ diff --git a/hr_loan/static/description/cybro-service.png b/hr_loan/static/description/cybro-service.png new file mode 100644 index 000000000..252929a86 Binary files /dev/null and b/hr_loan/static/description/cybro-service.png differ diff --git a/hr_loan/static/description/icon.png b/hr_loan/static/description/icon.png new file mode 100644 index 000000000..e90809a0f Binary files /dev/null and b/hr_loan/static/description/icon.png differ diff --git a/hr_loan/static/description/index.html b/hr_loan/static/description/index.html new file mode 100644 index 000000000..aac0eb64e --- /dev/null +++ b/hr_loan/static/description/index.html @@ -0,0 +1,163 @@ +
+
+
+

OpenHRMS

+

Most advanced open source HR management software

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

HR Loan

+

Manage Loan request of employees

+

Cybrosys Technologies

+
+
+

Features:

+
+ Employee can create loan request.
+ Double layer approval, from Accounting & HR Department.
+ Loan amount is deducted from the salary.
+
+
+
+ +
+
+
+
+

Overview

+

+ HR Loan is a component of Open HRMS suit. + HR 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 "HR 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 will be listed there, + we can manually select the installments that have to be deducted from the salary

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

Loan Amount Deduction

+

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

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

Our Odoo Services

+
+
+ + +
+

Need Any Help?

+ +
diff --git a/hr_loan/static/description/loan_amount_deduction.png b/hr_loan/static/description/loan_amount_deduction.png new file mode 100644 index 000000000..b1896e2b7 Binary files /dev/null and b/hr_loan/static/description/loan_amount_deduction.png differ diff --git a/hr_loan/static/description/loan_approval.png b/hr_loan/static/description/loan_approval.png new file mode 100644 index 000000000..d34b799e9 Binary files /dev/null and b/hr_loan/static/description/loan_approval.png differ diff --git a/hr_loan/static/description/loan_request.png b/hr_loan/static/description/loan_request.png new file mode 100644 index 000000000..191d47adc Binary files /dev/null and b/hr_loan/static/description/loan_request.png differ diff --git a/hr_loan/static/description/loan_rule.png b/hr_loan/static/description/loan_rule.png new file mode 100644 index 000000000..3b3f78c7f Binary files /dev/null and b/hr_loan/static/description/loan_rule.png differ diff --git a/hr_loan/static/description/payslip.png b/hr_loan/static/description/payslip.png new file mode 100644 index 000000000..e58613b86 Binary files /dev/null and b/hr_loan/static/description/payslip.png differ diff --git a/hr_loan/views/hr_loan.xml b/hr_loan/views/hr_loan.xml new file mode 100644 index 000000000..47414fd4c --- /dev/null +++ b/hr_loan/views/hr_loan.xml @@ -0,0 +1,187 @@ + + + + + + hr.loan.tree + hr.loan + + + + + + + + + + + + + + hr.loan.form + hr.loan + +
+
+
+ + +
+
+ +
+
+ + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/hr_loan/views/hr_loan_sequence.xml b/hr_loan/views/hr_loan_sequence.xml new file mode 100644 index 000000000..78e9d6d60 --- /dev/null +++ b/hr_loan/views/hr_loan_sequence.xml @@ -0,0 +1,14 @@ + + + + + Loan Request + hr.loan.req + Loan NO + 4 + 1 + 1 + standard + + + \ No newline at end of file diff --git a/hr_loan/views/hr_payroll.xml b/hr_loan/views/hr_payroll.xml new file mode 100644 index 000000000..522420f92 --- /dev/null +++ b/hr_loan/views/hr_payroll.xml @@ -0,0 +1,28 @@ + + + + hr.payslip.inherit.form1 + hr.payslip + + + + + +