diff --git a/hr_salary_advance/README.md b/hr_salary_advance/README.md new file mode 100644 index 000000000..2e7e989c0 --- /dev/null +++ b/hr_salary_advance/README.md @@ -0,0 +1,35 @@ +OHRMS Advance Salary' +===================== + +Advance Salary In HR. + +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 + Sreejith P + +Maintainer +---------- + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com. diff --git a/hr_salary_advance/__init__.py b/hr_salary_advance/__init__.py new file mode 100644 index 000000000..fca0067a7 --- /dev/null +++ b/hr_salary_advance/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +import models + diff --git a/hr_salary_advance/__manifest__.py b/hr_salary_advance/__manifest__.py new file mode 100644 index 000000000..37d2ed92a --- /dev/null +++ b/hr_salary_advance/__manifest__.py @@ -0,0 +1,51 @@ +# -*- 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 Advance Salary', + 'version': '10.0.1.0.0', + 'summary': 'Advance Salary In HR', + 'description': """ + Helps you to manage Advance Salary Request 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_accountant', 'hr_contract', 'hr_loan', + ], + 'data': [ + 'security/ir.model.access.csv', + 'security/security.xml', + 'views/salary_structure.xml', + 'views/salary_advance.xml', + ], + 'demo': [], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} + diff --git a/hr_salary_advance/models/__init__.py b/hr_salary_advance/models/__init__.py new file mode 100644 index 000000000..db668a115 --- /dev/null +++ b/hr_salary_advance/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +import salary_advance +import salary_structure +import hr_advance_payslip + diff --git a/hr_salary_advance/models/hr_advance_payslip.py b/hr_salary_advance/models/hr_advance_payslip.py new file mode 100644 index 000000000..413ae5718 --- /dev/null +++ b/hr_salary_advance/models/hr_advance_payslip.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +from datetime import datetime +from odoo import models +from odoo.exceptions import except_orm + + +class SalaryRuleInput(models.Model): + _inherit = 'hr.payslip' + + def get_inputs(self, contract_ids, date_from, date_to): + """This Compute the other inputs to employee payslip. + """ + res = super(SalaryRuleInput, self).get_inputs(contract_ids, date_from, date_to) + print self, contract_ids, date_from, date_to + contract_obj = self.env['hr.contract'] + emp_id = contract_obj.browse(contract_ids[0]).employee_id + adv_salary = self.env['salary.advance'].search([('employee_id', '=', emp_id.id)]) + print emp_id, adv_salary + for adv_obj in adv_salary: + current_date = datetime.strptime(date_from, '%Y-%m-%d').date().month + date = adv_obj.date + existing_date = datetime.strptime(date, '%Y-%m-%d').date().month + if current_date == existing_date: + state = adv_obj.state + amount = adv_obj.advance + for result in res: + if state == 'approve' and amount != 0 and result.get('code') == 'SAR': + result['amount'] = amount + return res diff --git a/hr_salary_advance/models/salary_advance.py b/hr_salary_advance/models/salary_advance.py new file mode 100644 index 000000000..d0fc3b0e0 --- /dev/null +++ b/hr_salary_advance/models/salary_advance.py @@ -0,0 +1,186 @@ +# -*- coding: utf-8 -*- +import time +from datetime import datetime +from odoo import fields, models, api, _ +from odoo.exceptions import except_orm +from odoo import exceptions + + +class SalaryAdvancePayment(models.Model): + _name = "salary.advance" + _inherit = ['mail.thread', 'ir.needaction_mixin'] + + name = fields.Char(string='Name', readonly=True, select=True, default=lambda self: 'Adv/') + employee_id = fields.Many2one('hr.employee', string='Employee', required=True) + date = fields.Date(string='Date', required=True, default=lambda self: fields.Date.today()) + reason = fields.Text(string='Reason') + currency_id = fields.Many2one('res.currency', string='Currency', required=True, + default=lambda self: self.env.user.company_id.currency_id) + company_id = fields.Many2one('res.company', string='Company', required=True, + default=lambda self: self.env.user.company_id) + advance = fields.Float(string='Advance', required=True) + payment_method = fields.Many2one('account.journal', string='Payment Method') + exceed_condition = fields.Boolean(string='Exceed than maximum', + help="The Advance is greater than the maximum percentage in salary structure") + department = fields.Many2one('hr.department', string='Department') + state = fields.Selection([('draft', 'Draft'), + ('submit', 'Submitted'), + ('waiting_approval', 'Waiting Approval From Accounts'), + ('approve', 'Approved'), + ('cancel', 'Cancelled'), + ('reject', 'Rejected')], string='Status', default='draft', track_visibility='onchange') + debit = fields.Many2one('account.account', string='Debit Account') + credit = fields.Many2one('account.account', string='Credit Account') + journal = fields.Many2one('account.journal', string='Journal') + employee_contract_id = fields.Many2one('hr.contract', string='Contract') + + def onchange_employee_id(self, employee_id): + if employee_id: + employee_obj = self.env['hr.employee'].browse(employee_id) + department_id = employee_obj.department_id.id + domain = [('employee_id', '=', employee_id)] + return {'value': {'department': department_id}, 'domain': { + 'employee_contract_id': domain, + }} + + @api.onchange('company_id') + def onchange_company_id(self): + company = self.company_id + domain = [('company_id.id', '=', company.id)] + result = { + 'domain': { + 'journal': domain, + }, + + } + return result + + @api.one + def submit_to_manager(self): + self.state = 'submit' + + @api.one + def cancel(self): + self.state = 'cancel' + + @api.one + def reject(self): + self.state = 'reject' + + @api.model + def create(self, vals): + vals['name'] = self.env['ir.sequence'].get('salary.advance.seq') or ' ' + res_id = super(SalaryAdvancePayment, self).create(vals) + return res_id + + @api.one + def approve_request(self): + """This Approve the employee salary advance request. + """ + emp_obj = self.env['hr.employee'] + address = emp_obj.browse([self.employee_id.id]).address_home_id + if not address.id: + raise except_orm('Error!', 'Define home address for employee') + salary_advance_search = self.search([('employee_id', '=', self.employee_id.id), ('id', '!=', self.id), + ('state', '=', 'approve')]) + current_month = datetime.strptime(self.date, '%Y-%m-%d').date().month + for each_advance in salary_advance_search: + existing_month = datetime.strptime(each_advance.date, '%Y-%m-%d').date().month + if current_month == existing_month: + raise except_orm('Error!', 'Advance can be requested once in a month') + if not self.employee_contract_id: + raise except_orm('Error!', 'Define a contract for the employee') + struct_id = self.employee_contract_id.struct_id + if not struct_id.max_percent or not struct_id.advance_date: + raise except_orm('Error!', 'Max percentage or advance days are not provided in Contract') + adv = self.advance + amt = (self.employee_contract_id.struct_id.max_percent * self.employee_contract_id.wage) / 100 + if adv > amt and not self.exceed_condition: + raise except_orm('Error!', 'Advance amount is greater than allotted') + + if not self.advance: + raise except_orm('Warning', 'You must Enter the Salary Advance amount') + payslip_obj = self.env['hr.payslip'].search([('employee_id', '=', self.employee_id.id), + ('state', '=', 'done'), ('date_from', '<=', self.date), + ('date_to', '>=', self.date)]) + if payslip_obj: + raise except_orm('Warning', "This month salary already calculated") + + for slip in self.env['hr.payslip'].search([('employee_id', '=', self.employee_id.id)]): + slip_moth = datetime.strptime(slip.date_from, '%Y-%m-%d').date().month + if current_month == slip_moth + 1: + slip_day = datetime.strptime(slip.date_from, '%Y-%m-%d').date().day + current_day = datetime.strptime(self.date, '%Y-%m-%d').date().day + if current_day - slip_day < struct_id.advance_date: + raise exceptions.Warning( + _('Request can be done after "%s" Days From prevoius month salary') % struct_id.advance_date) + self.state = 'waiting_approval' + + @api.one + def approve_request_acc_dept(self): + """This Approve the employee salary advance request from accounting department. + """ + salary_advance_search = self.search([('employee_id', '=', self.employee_id.id), ('id', '!=', self.id), + ('state', '=', 'approve')]) + current_month = datetime.strptime(self.date, '%Y-%m-%d').date().month + for each_advance in salary_advance_search: + existing_month = datetime.strptime(each_advance.date, '%Y-%m-%d').date().month + print current_month, existing_month + if current_month == existing_month: + raise except_orm('Error!', 'Advance can be requested once in a month') + if not self.debit or not self.credit or not self.journal: + raise except_orm('Warning', "You must enter Debit & Credit account and journal to approve ") + if not self.advance: + raise except_orm('Warning', 'You must Enter the Salary Advance amount') + + move_obj = self.env['account.move'] + timenow = time.strftime('%Y-%m-%d') + line_ids = [] + debit_sum = 0.0 + credit_sum = 0.0 + for request in self: + amount = request.advance + request_name = request.employee_id.name + reference = request.name + journal_id = request.journal.id + move = { + 'narration': 'Salary Advance Of ' + request_name, + 'ref': reference, + 'journal_id': journal_id, + 'date': timenow, + 'state': 'posted', + } + + debit_account_id = request.debit.id + credit_account_id = request.credit.id + + if debit_account_id: + debit_line = (0, 0, { + 'name': request_name, + 'account_id': debit_account_id, + 'journal_id': journal_id, + 'date': timenow, + 'debit': amount > 0.0 and amount or 0.0, + 'credit': amount < 0.0 and -amount or 0.0, + 'currency_id': self.currency_id.id, + }) + line_ids.append(debit_line) + debit_sum += debit_line[2]['debit'] - debit_line[2]['credit'] + + if credit_account_id: + credit_line = (0, 0, { + 'name': request_name, + 'account_id': credit_account_id, + 'journal_id': journal_id, + 'date': timenow, + 'debit': amount < 0.0 and -amount or 0.0, + 'credit': amount > 0.0 and amount or 0.0, + 'currency_id': self.currency_id.id, + }) + line_ids.append(credit_line) + credit_sum += credit_line[2]['credit'] - credit_line[2]['debit'] + + move.update({'line_ids': line_ids}) + move_id = move_obj.create(move) + self.state = 'approve' + return True diff --git a/hr_salary_advance/models/salary_structure.py b/hr_salary_advance/models/salary_structure.py new file mode 100644 index 000000000..d432d0fc8 --- /dev/null +++ b/hr_salary_advance/models/salary_structure.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- + +from odoo import fields, models + + +class SalaryStructure(models.Model): + _inherit = 'hr.payroll.structure' + + max_percent = fields.Integer(string='Max.Salary Advance Percentage') + advance_date = fields.Integer(string='Salary Advance-After days') + diff --git a/hr_salary_advance/security/ir.model.access.csv b/hr_salary_advance/security/ir.model.access.csv new file mode 100644 index 000000000..5343aaebc --- /dev/null +++ b/hr_salary_advance/security/ir.model.access.csv @@ -0,0 +1,5 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_salary_advance_user,salary.advance,model_salary_advance,base.group_user,1,1,1,0 +access_salary_advance_officer,salary.advance,model_salary_advance,hr.group_hr_user,1,1,1,1 +access_salary_advance_manager,salary.advance,model_salary_advance,hr.group_hr_manager,1,1,1,1 +access_account_manager,salary.advance,model_salary_advance,account.group_account_manager,1,1,1,1 diff --git a/hr_salary_advance/security/security.xml b/hr_salary_advance/security/security.xml new file mode 100644 index 000000000..fba5dc7f0 --- /dev/null +++ b/hr_salary_advance/security/security.xml @@ -0,0 +1,35 @@ + + + + + + Advance Request Multi Company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + + Salary Advance + + + + + + + + + + Salary Advance Rule For Employee + [('employee_id.user_id','=',user.id)] + + + + + + + + + + + \ No newline at end of file diff --git a/hr_salary_advance/static/description/HRMS-BUTTON.png b/hr_salary_advance/static/description/HRMS-BUTTON.png new file mode 100644 index 000000000..0f1b65bea Binary files /dev/null and b/hr_salary_advance/static/description/HRMS-BUTTON.png differ diff --git a/hr_salary_advance/static/description/advance_request_approval.png b/hr_salary_advance/static/description/advance_request_approval.png new file mode 100644 index 000000000..955d137ba Binary files /dev/null and b/hr_salary_advance/static/description/advance_request_approval.png differ diff --git a/hr_salary_advance/static/description/banner.jpg b/hr_salary_advance/static/description/banner.jpg new file mode 100644 index 000000000..127ea73a8 Binary files /dev/null and b/hr_salary_advance/static/description/banner.jpg differ diff --git a/hr_salary_advance/static/description/cybro-service.png b/hr_salary_advance/static/description/cybro-service.png new file mode 100644 index 000000000..252929a86 Binary files /dev/null and b/hr_salary_advance/static/description/cybro-service.png differ diff --git a/hr_salary_advance/static/description/icon.png b/hr_salary_advance/static/description/icon.png new file mode 100644 index 000000000..2dbd13de8 Binary files /dev/null and b/hr_salary_advance/static/description/icon.png differ diff --git a/hr_salary_advance/static/description/index.html b/hr_salary_advance/static/description/index.html new file mode 100644 index 000000000..98444388c --- /dev/null +++ b/hr_salary_advance/static/description/index.html @@ -0,0 +1,133 @@ +
+
+

OpenHRMS

+

Most advanced open source HR management software

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

HR Salary Advance

+

Manage salary advance request of employees

+

Cybrosys Technologies

+
+
+

Features:

+
+ Employee can request for advance salary.
+ Set advance salary percentage limit in salary structure.
+ Set salary advance days in salary structure.
+
+
+
+ +
+
+
+
+

Overview

+

+ HR Salary Advance is a component of Open HRMS suit. HR Salary Advance + module helps the user to manage salary advance requests from employees. You can configure advance salary rules, + set advance salary limit, minimum number of days, and provide advance salary to employees +

+
+
+
+
+ +
+
+
+

Configuration

+

Add salary advance Rules in Salary Structure and provide the max.advance percentage and advance days

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

Advance Request

+

Employee can create Advance request

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

Salary Advance request approval From Hr & Accounts Department

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

Employee Payslip

+

When we create payslip salary advance will be deducted from the salary

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

Our Odoo Services

+
+
+ + +
+

Need Any Help?

+ +
+ diff --git a/hr_salary_advance/static/description/salary_advance_deduction.png b/hr_salary_advance/static/description/salary_advance_deduction.png new file mode 100644 index 000000000..d0fe8c6d1 Binary files /dev/null and b/hr_salary_advance/static/description/salary_advance_deduction.png differ diff --git a/hr_salary_advance/static/description/salary_advance_rule.png b/hr_salary_advance/static/description/salary_advance_rule.png new file mode 100644 index 000000000..93f502d31 Binary files /dev/null and b/hr_salary_advance/static/description/salary_advance_rule.png differ diff --git a/hr_salary_advance/static/description/salary_request.png b/hr_salary_advance/static/description/salary_request.png new file mode 100644 index 000000000..6d1f5859c Binary files /dev/null and b/hr_salary_advance/static/description/salary_request.png differ diff --git a/hr_salary_advance/views/salary_advance.xml b/hr_salary_advance/views/salary_advance.xml new file mode 100644 index 000000000..3511231a0 --- /dev/null +++ b/hr_salary_advance/views/salary_advance.xml @@ -0,0 +1,146 @@ + + + + + + salary.advance.form + salary.advance + +
+
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + +
+
+
+
+ + + salary.advance.tree + salary.advance + + + + + + + + + + + + salary.advance.select + salary.advance + + + + + + + + + + + + + + + + + + + + + Salary Advance + ir.actions.act_window + salary.advance + form + tree,form + + {'search_default_my_requests_filter':1} + [('employee_id.user_id', '=', uid)] + +

+ Create Requests. +

+
+
+ + + Salary Advance + ir.actions.act_window + salary.advance + form + tree,form + + {'search_default_approved':1} + [('employee_id.user_id', '=', uid)] + +

+ Create Requests. +

+
+
+ + + Salary Advance + ir.actions.act_window + salary.advance + form + tree,form + + {'search_default_submitted': 1} + + +

+ Create Requests. +

+
+
+ + + Salary Advance Request + salary.advance.seq + SAR + 4 + 1 + 1 + standard + + + + + + + +
+
\ No newline at end of file diff --git a/hr_salary_advance/views/salary_structure.xml b/hr_salary_advance/views/salary_structure.xml new file mode 100644 index 000000000..808ac50e9 --- /dev/null +++ b/hr_salary_advance/views/salary_structure.xml @@ -0,0 +1,33 @@ + + + + + + SAR + Advance Salary + + code + result = inputs.SAR and - (inputs.SAR.amount) + + + + + + SAR + Salary Advance + + + + + salary.structure.form + hr.payroll.structure + + + + + + + + + +