diff --git a/ohrms_loan/README.md b/ohrms_loan/README.md index 2419a37ea..e292e7dce 100644 --- a/ohrms_loan/README.md +++ b/ohrms_loan/README.md @@ -1,5 +1,5 @@ -OHRMS Loan Management -===================== +Open HRMS Loan Management +========================= Manage Loan Requests. diff --git a/ohrms_loan/RELEASE_NOTES.md b/ohrms_loan/RELEASE_NOTES.md deleted file mode 100644 index eeea19ca6..000000000 --- a/ohrms_loan/RELEASE_NOTES.md +++ /dev/null @@ -1,6 +0,0 @@ -## Module ohrms_loan - -#### 30.03.2018 -#### Version 10.0.1.0.0 -##### ADD -- Initial commit for OpenHrms Project diff --git a/ohrms_loan/__manifest__.py b/ohrms_loan/__manifest__.py index 56a940248..76478a147 100644 --- a/ohrms_loan/__manifest__.py +++ b/ohrms_loan/__manifest__.py @@ -21,8 +21,8 @@ # ################################################################################### { - 'name': 'OHRMS Loan Management', - 'version': '10.0.1.0.0', + 'name': 'Open HRMS Loan Management', + 'version': '10.0.2.0.0', 'summary': 'Manage Loan Requests', 'description': """ Helps you to manage Loan Requests of your company's staff. @@ -33,13 +33,13 @@ 'maintainer': 'Cybrosys Techno Solutions', 'website': "https://www.openhrms.com", 'depends': [ - 'hr_payroll', 'hr', 'account', + 'base', '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_seq.xml', + 'data/salary_rule_loan.xml', 'views/hr_loan.xml', 'views/hr_payroll.xml', ], diff --git a/ohrms_loan/data/hr_payroll_data.xml b/ohrms_loan/data/salary_rule_loan.xml similarity index 58% rename from ohrms_loan/data/hr_payroll_data.xml rename to ohrms_loan/data/salary_rule_loan.xml index a49ecf484..0e3ed6004 100644 --- a/ohrms_loan/data/hr_payroll_data.xml +++ b/ohrms_loan/data/salary_rule_loan.xml @@ -9,13 +9,8 @@ none code - result = -payslip.total_amount_paid + result = -payslip.total_paid - - LO - Loan - - - \ No newline at end of file + diff --git a/ohrms_loan/doc/RELEASE_NOTES.md b/ohrms_loan/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..e137010ca --- /dev/null +++ b/ohrms_loan/doc/RELEASE_NOTES.md @@ -0,0 +1,12 @@ +## Module + +#### 09.04.2018 +#### Version 10.0.2.0.0 +##### CHG +- file name changed. +- fields removed. + +#### 30.03.2018 +#### Version 10.0.1.0.0 +##### ADD +- Initial commit for Open HRMS Project diff --git a/ohrms_loan/models/hr_loan.py b/ohrms_loan/models/hr_loan.py index f29e2b397..bdf266210 100644 --- a/ohrms_loan/models/hr_loan.py +++ b/ohrms_loan/models/hr_loan.py @@ -3,53 +3,35 @@ 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', 'ir.needaction_mixin'] - _description = "HR Loan Request" + _description = "Loan Request" @api.one - def _compute_amount(self): - total_paid_amount = 0.00 + def _compute_loan_amount(self): + total_paid = 0.0 for loan in self: - for line in loan.loan_line_ids: + for line in loan.loan_lines: if line.paid: - total_paid_amount += line.paid_amount - balance_amount = loan.loan_amount - total_paid_amount + 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_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 + self.total_paid_amount = total_paid name = fields.Char(string="Loan Name", default="/", readonly=True) - date = fields.Date(string="Date Request", default=fields.Date.today(), readonly=True) + date = fields.Date(string="Date", 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") + 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, @@ -57,117 +39,87 @@ class HrLoan(models.Model): 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', 'Waiting Approval From Hr'), - ('waiting_approval_2', 'Waiting Approval From Accounts'), + ('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): - values['name'] = self.env['ir.sequence'].get('hr.loan.req') or ' ' - res = super(HrLoan, self).create(values) - return res + 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_set_to_draft(self): - return self.write({'state': 'draft'}) - - @api.multi - def submit(self): + def action_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} - } + def action_cancel(self): + self.write({'state': 'cancel'}) @api.multi def action_approve(self): self.write({'state': 'approve'}) @api.multi - def compute_loan_line(self): + 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. """ - 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 + date_start = datetime.strptime(loan.payment_date, '%Y-%m-%d') + amount = 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, + self.env['hr.loan.line'].create({ + 'date': date_start, + 'amount': amount, 'employee_id': loan.employee_id.id, 'loan_id': loan.id}) - counter += 1 - date_start_str = date_start_str + relativedelta(months=1) - + date_start = date_start + 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): +class InstallmentLine(models.Model): _name = "hr.loan.line" - _description = "HR Loan Request Line" + _description = "Installment Line" - paid_date = fields.Date(string="Payment Date", required=True) + 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) + amount = fields.Float(string="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}) + 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_loans(self): + def _compute_employee_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') + 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 index 853eadd20..4aca27237 100644 --- a/ohrms_loan/models/hr_payroll.py +++ b/ohrms_loan/models/hr_payroll.py @@ -6,37 +6,37 @@ class HrPayslip(models.Model): _inherit = 'hr.payslip' @api.one - def compute_total_paid_loan(self): + def compute_total_paid(self): """This compute the total paid amount of Loan. """ - total = 0.00 + total = 0.0 for line in self.loan_ids: if line.paid: - total += line.paid_amount - self.total_amount_paid = total + total += line.amount + self.total_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') + loan_ids = fields.One2many('hr.loan.line', 'payslip_id', string="Loans") + total_paid = fields.Float(string="Total Loan Amount", compute='compute_total_paid') @api.multi def get_loan(self): """This gives the installment lines of an employee where the state is not in paid. """ - array = [] + loan_list = [] 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 + loan_list.append(loan.id) + self.loan_ids = loan_list + return loan_list @api.multi def action_payslip_done(self): - array = [] + loan_list = [] for line in self.loan_ids: if line.paid: - array.append(line.id) + loan_list.append(line.id) else: - line.payroll_id = False - self.loan_ids = array + line.payslip_id = False + self.loan_ids = loan_list 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 index 9b79840d8..e5b282ebc 100644 --- a/ohrms_loan/security/ir.model.access.csv +++ b/ohrms_loan/security/ir.model.access.csv @@ -1,12 +1,12 @@ 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_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 diff --git a/ohrms_loan/static/description/accounting_validation.png b/ohrms_loan/static/description/accounting_validation.png index 1f8537f24..134310d78 100644 Binary files a/ohrms_loan/static/description/accounting_validation.png and b/ohrms_loan/static/description/accounting_validation.png differ diff --git a/ohrms_loan/static/description/advance_request_approval.png b/ohrms_loan/static/description/advance_request_approval.png new file mode 100644 index 000000000..30d1cc6e4 Binary files /dev/null and b/ohrms_loan/static/description/advance_request_approval.png differ diff --git a/ohrms_loan/static/description/banner.jpg b/ohrms_loan/static/description/banner.jpg index ac30fc219..4be55a5aa 100644 Binary files a/ohrms_loan/static/description/banner.jpg and b/ohrms_loan/static/description/banner.jpg 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/index.html b/ohrms_loan/static/description/index.html index aac0eb64e..2d97d75ab 100644 --- a/ohrms_loan/static/description/index.html +++ b/ohrms_loan/static/description/index.html @@ -1,11 +1,9 @@
-

OpenHRMS

+

Open HRMS

Most advanced open source HR management software

- -
@@ -16,7 +14,6 @@ - @@ -25,7 +22,7 @@
-

HR Loan

+

Open HRMS Loan

Manage Loan request of employees

Cybrosys Technologies

@@ -45,8 +42,8 @@

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. + 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.

@@ -59,7 +56,7 @@

Configuration

-

Install the Module "HR Loan Accounting" in order to enable Accounting Entries. +

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

@@ -126,7 +123,7 @@

Loan Amount Deduction

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

+ the deducted installments will be changed to paid.

diff --git a/ohrms_loan/static/description/loan_amount_deduction.png b/ohrms_loan/static/description/loan_amount_deduction.png index b1896e2b7..a6cdded26 100644 Binary files a/ohrms_loan/static/description/loan_amount_deduction.png 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 index d34b799e9..ceeb2d817 100644 Binary files a/ohrms_loan/static/description/loan_approval.png 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 index 191d47adc..6d3157db4 100644 Binary files a/ohrms_loan/static/description/loan_request.png 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 index 3b3f78c7f..330b72cef 100644 Binary files a/ohrms_loan/static/description/loan_rule.png 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 index e58613b86..0bcf1637e 100644 Binary files a/ohrms_loan/static/description/payslip.png 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 index 47414fd4c..9ee1a8647 100644 --- a/ohrms_loan/views/hr_loan.xml +++ b/ohrms_loan/views/hr_loan.xml @@ -2,7 +2,7 @@ - + hr.loan.tree hr.loan @@ -17,76 +17,57 @@ - + hr.loan.form hr.loan
-
-
-
- + -
- - - - - - -
+ + + + + - - - + +
- - - - - - - - - -
- + - - -
@@ -21,7 +24,7 @@
-

HR Loan

+

Open HRMS Loan Accounting

Manage Loan request of employees

Cybrosys Technologies

@@ -41,8 +44,8 @@

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. + 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.

@@ -55,7 +58,7 @@

Configuration

-

Install the Module "HR Loan Accounting" in order to enable Accounting Entries. +

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

@@ -122,7 +125,7 @@

Loan Amount Deduction

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

+ the deducted installments will be changed to paid.

diff --git a/ohrms_loan_accounting/static/description/loan_amount_deduction.png b/ohrms_loan_accounting/static/description/loan_amount_deduction.png index b1896e2b7..a6cdded26 100644 Binary files a/ohrms_loan_accounting/static/description/loan_amount_deduction.png and b/ohrms_loan_accounting/static/description/loan_amount_deduction.png differ diff --git a/ohrms_loan_accounting/static/description/loan_approval.png b/ohrms_loan_accounting/static/description/loan_approval.png index d34b799e9..ceeb2d817 100644 Binary files a/ohrms_loan_accounting/static/description/loan_approval.png and b/ohrms_loan_accounting/static/description/loan_approval.png differ diff --git a/ohrms_loan_accounting/static/description/loan_request.png b/ohrms_loan_accounting/static/description/loan_request.png index 191d47adc..6d3157db4 100644 Binary files a/ohrms_loan_accounting/static/description/loan_request.png and b/ohrms_loan_accounting/static/description/loan_request.png differ diff --git a/ohrms_loan_accounting/static/description/loan_rule.png b/ohrms_loan_accounting/static/description/loan_rule.png index 3b3f78c7f..330b72cef 100644 Binary files a/ohrms_loan_accounting/static/description/loan_rule.png and b/ohrms_loan_accounting/static/description/loan_rule.png differ diff --git a/ohrms_loan_accounting/static/description/payslip.png b/ohrms_loan_accounting/static/description/payslip.png index e58613b86..0bcf1637e 100644 Binary files a/ohrms_loan_accounting/static/description/payslip.png and b/ohrms_loan_accounting/static/description/payslip.png differ diff --git a/ohrms_loan_accounting/views/hr_loan_acc.xml b/ohrms_loan_accounting/views/hr_loan_acc.xml index 52eb6123f..665e431a8 100644 --- a/ohrms_loan_accounting/views/hr_loan_acc.xml +++ b/ohrms_loan_accounting/views/hr_loan_acc.xml @@ -1,20 +1,10 @@ - - Loans - ir.actions.act_window - account.move.line - hr.loan - form - tree,form - {'search_default_loan_id': [active_id], 'default_loan_id': active_id} - [('loan_id','=',active_id)] - HR LOAN hr.loan - + 0