Browse Source

[UDT] Functions Updated

pull/78/head
Sreejith 7 years ago
parent
commit
9098420c3e
  1. 4
      ohrms_loan/README.md
  2. 6
      ohrms_loan/RELEASE_NOTES.md
  3. 10
      ohrms_loan/__manifest__.py
  4. 7
      ohrms_loan/data/salary_rule_loan.xml
  5. 12
      ohrms_loan/doc/RELEASE_NOTES.md
  6. 146
      ohrms_loan/models/hr_loan.py
  7. 28
      ohrms_loan/models/hr_payroll.py
  8. 16
      ohrms_loan/security/ir.model.access.csv
  9. BIN
      ohrms_loan/static/description/accounting_validation.png
  10. BIN
      ohrms_loan/static/description/advance_request_approval.png
  11. BIN
      ohrms_loan/static/description/banner.jpg
  12. BIN
      ohrms_loan/static/description/cybro_logo.png
  13. 15
      ohrms_loan/static/description/index.html
  14. BIN
      ohrms_loan/static/description/loan_amount_deduction.png
  15. BIN
      ohrms_loan/static/description/loan_approval.png
  16. BIN
      ohrms_loan/static/description/loan_request.png
  17. BIN
      ohrms_loan/static/description/loan_rule.png
  18. BIN
      ohrms_loan/static/description/payslip.png
  19. 81
      ohrms_loan/views/hr_loan.xml
  20. 4
      ohrms_loan/views/hr_loan_seq.xml
  21. 15
      ohrms_loan/views/hr_payroll.xml
  22. 4
      ohrms_loan_accounting/README.md
  23. 6
      ohrms_loan_accounting/RELEASE_NOTES.md
  24. 12
      ohrms_loan_accounting/__manifest__.py
  25. 11
      ohrms_loan_accounting/doc/RELEASE_NOTES.md
  26. 155
      ohrms_loan_accounting/models/hr_loan_acc.py
  27. BIN
      ohrms_loan_accounting/static/description/accounting_validation.png
  28. BIN
      ohrms_loan_accounting/static/description/advance_request_approval.png
  29. BIN
      ohrms_loan_accounting/static/description/banner.jpg
  30. BIN
      ohrms_loan_accounting/static/description/cybro_logo.png
  31. 19
      ohrms_loan_accounting/static/description/index.html
  32. BIN
      ohrms_loan_accounting/static/description/loan_amount_deduction.png
  33. BIN
      ohrms_loan_accounting/static/description/loan_approval.png
  34. BIN
      ohrms_loan_accounting/static/description/loan_request.png
  35. BIN
      ohrms_loan_accounting/static/description/loan_rule.png
  36. BIN
      ohrms_loan_accounting/static/description/payslip.png
  37. 12
      ohrms_loan_accounting/views/hr_loan_acc.xml

4
ohrms_loan/README.md

@ -1,5 +1,5 @@
OHRMS Loan Management
=====================
Open HRMS Loan Management
=========================
Manage Loan Requests.

6
ohrms_loan/RELEASE_NOTES.md

@ -1,6 +0,0 @@
## Module ohrms_loan
#### 30.03.2018
#### Version 10.0.1.0.0
##### ADD
- Initial commit for OpenHrms Project

10
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',
],

7
ohrms_loan/data/hr_payroll_data.xml → ohrms_loan/data/salary_rule_loan.xml

@ -9,13 +9,8 @@
<field name="category_id" ref="hr_payroll.DED"/>
<field name="condition_select">none</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">result = -payslip.total_amount_paid</field>
<field name="amount_python_compute">result = -payslip.total_paid</field>
</record>
<record id="hr_rule_input_loan" model="hr.rule.input">
<field name="code">LO</field>
<field name="name">Loan</field>
<field name="input_id" ref="hr_rule_loan"/>
</record>
</data>
</odoo>

12
ohrms_loan/doc/RELEASE_NOTES.md

@ -0,0 +1,12 @@
## Module <ohrms_loan>
#### 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

146
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')

28
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()

16
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

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_hr_loan_user hr.loan hr.loan.group_user model_hr_loan base.group_user 1 1 1 0
3 access_hr_loan_line_user hr.loan.line hr.loan.line.group_user model_hr_loan_line base.group_user 1 1 0 0
4 access_hr_loan_officer hr.loan hr.loan.group_hr_user model_hr_loan hr.group_hr_user 1 1 1 1
5 access_hr_loan_line_officer hr.loan.line hr.loan.line.group_hr_user model_hr_loan_line hr.group_hr_user 1 1 1 1
6 access_account_move_uinvoice_officer account.move account.move.group_hr_user account.model_account_move hr.group_hr_user 1 1 1 1
7 access_account_journal_uinvoice_officer account.journal account.journal.group_hr_user account.model_account_journal hr.group_hr_user 1 1 1 1
8 acces_account_move_line_officer account.move.line account.move.line.group_hr_user account.model_account_move_line hr.group_hr_user 1 1 1 1
9 acces_ account_account_type_officer account.account.type account.account.type.group_hr_user account.model_account_account_type hr.group_hr_user 1 1 1 1
10 access_hr_loan_manager hr.loan model_hr_loan hr.group_hr_manager 1 1 1 1
11 access_hr_loan_line_manager hr.loan.line model_hr_loan_line hr.group_hr_manager 1 1 1 1
12 access_account_move_uinvoice_manager account.move account.model_account_move hr.group_hr_manager 1 1 1 1

BIN
ohrms_loan/static/description/accounting_validation.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 119 KiB

BIN
ohrms_loan/static/description/advance_request_approval.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

BIN
ohrms_loan/static/description/banner.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 117 KiB

BIN
ohrms_loan/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

15
ohrms_loan/static/description/index.html

@ -1,11 +1,9 @@
<section class="oe_container bg-gray-lighter" xmlns="http://www.w3.org/1999/html">
<div class="oe_row">
<div class="oe_span">
<h2 class="oe_slogan">OpenHRMS</h2>
<h2 class="oe_slogan">Open HRMS</h2>
<h3 class="oe_slogan">Most advanced open source HR management software</h3>
</div>
</div>
</section>
@ -16,7 +14,6 @@
<a href="https://www.openhrms.com/#request-demo">
<img src="HRMS-BUTTON.png">
</a>
<div class="oe_demo_footer oe_centeralign">Online Demo</div>
</div>
</div>
@ -25,7 +22,7 @@
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">HR Loan</h2>
<h2 class="oe_slogan">Open HRMS Loan</h2>
<h3 class="oe_slogan">Manage Loan request of employees</h3>
<h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a></h4>
</div>
@ -45,8 +42,8 @@
<div class="oe_picture">
<h3 class="oe_slogan">Overview</h3>
<p class="oe_mt32">
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.
</p>
</div>
</div>
@ -59,7 +56,7 @@
<h3 class="oe_slogan">Configuration</h3>
</div>
<div class="" style="text-align: center;">
<p>Install the Module "HR Loan Accounting" in order to enable Accounting Entries.
<p>Install the Module "Open HRMS Loan Accounting" in order to enable Accounting Entries.
Enable the option "Loan Approval From Accounting Department" In accounting settings</p>
<div class="oe_span12">
<div class="oe_demo oe_picture oe_screenshot">
@ -126,7 +123,7 @@
<div class="" style="text-align: center;">
<h3 class="oe_slogan">Loan Amount Deduction</h3>
<p>When we check the Loan request again,
the deducted installments will be changed to paid state.</p>
the deducted installments will be changed to paid.</p>
<div class="oe_span12">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;" src="loan_amount_deduction.png">

BIN
ohrms_loan/static/description/loan_amount_deduction.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 111 KiB

BIN
ohrms_loan/static/description/loan_approval.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 125 KiB

BIN
ohrms_loan/static/description/loan_request.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 50 KiB

BIN
ohrms_loan/static/description/loan_rule.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 103 KiB

BIN
ohrms_loan/static/description/payslip.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 96 KiB

81
ohrms_loan/views/hr_loan.xml

@ -2,7 +2,7 @@
<odoo>
<!--Loan Tree view-->
<record id="tree_hr_loan_view" model="ir.ui.view">
<record id="hr_loan_tree_view" model="ir.ui.view">
<field name="name">hr.loan.tree</field>
<field name="model">hr.loan</field>
<field name="arch" type="xml">
@ -17,76 +17,57 @@
</record>
<!--Loan Form view-->
<record id="view_hr_loan_form" model="ir.ui.view">
<record id="hr_loan_form_view" model="ir.ui.view">
<field name="name">hr.loan.form</field>
<field name="model">hr.loan</field>
<field name="arch" type="xml">
<form string="Loan Request">
<header>
<button name="submit" type="object" string="Submit" states="draft" class="oe_highlight"/>
<button name="action_submit" type="object" string="Submit" states="draft" class="oe_highlight"/>
<button name="action_cancel" type="object" string="Cancel" states="waiting_approval_1" />
<button name="action_approve" type="object" string="Approve" states="waiting_approval_1" class="oe_highlight" groups="hr.group_hr_manager,hr.group_hr_user"/>
<button name="action_double_approve" type="object" string="Approve" states="waiting_approval_2" class="oe_highlight" groups="account.group_account_user,account.group_account_manager"/>
<button name="action_refuse" type="object" string="Refuse" states="draft,waiting_approval_1,waiting_approval_2" class="oe_highlight" groups="hr.group_hr_manager,hr.group_hr_user"/>
<field name="state" widget="statusbar" statusbar_visible="draft,waiting_approval_1,waiting_approval_2,approve" />
<field name="state" widget="statusbar" statusbar_visible="draft,waiting_approval_1,waiting_approval_2,approve,cancel" />
</header>
<sheet>
<div class="oe_button_box" name="button_box">
</div>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1>
<field name="name" class="oe_inline"/>
<field name="name" readonly="1"/>
</h1>
</div>
<group col="4">
<field name="employee_id" on_change="onchange_employee_id(employee_id)" attrs="{'readonly':[('state','=','approve')]}"/>
<field name="employee_id" attrs="{'readonly':[('state','=','approve')]}"/>
<field name="date"/>
<div colspan="4">
<group>
<field name="department_id"/>
<field name="job_id"/>
<field name="emp_salary"/>
<field name="loan_old_amount"/>
</group>
</div>
<field name="department_id"/>
<field name="job_position"/>
<field name="loan_amount" attrs="{'readonly':[('state','=','approve')]}"/>
<field name="installment" attrs="{'readonly':[('state','=','approve')]}"/>
<field name="payment_date" attrs="{'readonly':[('state','=','approve')]}"/>
<field name="emp_account_id" attrs="{'invisible':[('state', 'in',('draft','waiting_approval_1'))]}"/>
<field name="treasury_account_id" attrs="{'invisible':[('state', 'in',('draft','waiting_approval_1'))]}"/>
<field name="journal_id" attrs="{'invisible':[('state', 'in',('draft','waiting_approval_1'))]}"/>
<field name="loan_amount" attrs="{'readonly':[('state','=','approve')]}"/>
<field name="installment" attrs="{'readonly':[('state','=','approve')]}"/>
<field name="payment_start_date" attrs="{'readonly':[('state','=','approve')]}"/>
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_company"/>
</group>
<notebook>
<page string="Installments">
<group>
<field name="move_id" invisible="1"/>
</group>
<field name="loan_line_ids">
<tree string="Loan Line" editable="bottom">
<field name="paid_date"/>
<field name="paid_amount"/>
<field name="paid" readonly="1"/>
<field name="notes"/>
<button name="action_paid_amount" icon="fa-arrows-v" string="Pay Amount" type="object" attrs="{'invisible':[('paid','=',True)]}"
groups="hr.group_hr_manager,hr.group_hr_user"/>
<field name="loan_lines">
<tree string="Installments" editable="bottom">
<field name="date"/>
<field name="amount"/>
<field name="paid" readonly="1" invisible="1"/>
</tree>
</field>
<group class="oe_subtotal_footer oe_right">
<group class="oe_subtotal_footer oe_right" colspan="2" >
<field name="total_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<div>
<label for="total_paid_amount"/>
<button name="button_reset_balance_total" states="draft"
string="(update)" class="oe_link oe_edit_only"
type="object" help="Recompute Balance" groups="hr.group_hr_manager,hr.group_hr_user"/>
</div>
<field name="total_paid_amount" nolabel="1" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="total_paid_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="balance_amount" class="oe_subtotal_footer_separator" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
<field name="currency_id" options="{'no_create': True}" groups="base.group_multi_company"/>
</group>
<button type="object" name="compute_loan_line" string="Compute" colspan="2" attrs="{'invisible':[('state','=','approve')]}"
<button type="object" name="compute_installment" string="Compute Installment" colspan="2" attrs="{'invisible':[('state','=','approve')]}"
groups="hr.group_hr_manager,hr.group_hr_user" class="oe_stat_button"
icon="fa-clock-o"/>
<div class="oe_clear"/>
@ -128,9 +109,11 @@
<field name="res_model">hr.loan</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_loan_request_search_form"/>
<field name="help" type="html">
<p>
Create new loan request.
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new Loan request.
</p><p>
Use this menu to create loan requests.
</p>
</field>
</record>
@ -155,7 +138,7 @@
<field name="view_mode">tree,form</field>
<field name="context">{'search_default_employee_id': [active_id], 'default_employee_id': active_id}</field>
<field name="domain">[('employee_id','=',active_id)]</field>
<field name="view_id" eval="tree_hr_loan_view"/>
<field name="view_id" eval="hr_loan_tree_view"/>
</record>
@ -165,14 +148,6 @@
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='active_group']" position="before">
<group string="Loans">
<label for="loan_amount"/>
<div>
<field name="loan_amount" class="oe_inline"/>
</div>
</group>
</xpath>
<xpath expr="//div[@name='button_box']" position="inside">
<button name="%(act_hr_employee_loan_request)d"
type="action"

4
ohrms_loan/views/hr_loan_sequence.xml → ohrms_loan/views/hr_loan_seq.xml

@ -3,8 +3,8 @@
<data noupdate='1'>
<record id="ir_seq_hr_loan" model="ir.sequence">
<field name="name">Loan Request</field>
<field name="code">hr.loan.req</field>
<field name="prefix">Loan NO </field>
<field name="code">hr.loan.seq</field>
<field name="prefix">LO/</field>
<field name="padding">4</field>
<field name="number_increment">1</field>
<field name="number_next_actual">1</field>

15
ohrms_loan/views/hr_payroll.xml

@ -7,19 +7,20 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='input_line_ids']" position="after">
<separator string="Loans"/>
<group string="Loans">
<button name="get_loan" string="Update Loans" type="object" groups="hr_payroll.group_hr_payroll_manager"/>
<field name="loan_ids">
<group>
<group>
<button name="get_loan" string="Update Loans" type="object" groups="hr_payroll.group_hr_payroll_manager"/>
</group>
<field name="loan_ids" nolabel="1">
<tree string="Loans" editable="bottom">
<field name="loan_id"/>
<field name="paid_date"/>
<field name="paid_amount"/>
<field name="date"/>
<field name="amount"/>
<field name="paid" groups="hr_payroll.group_hr_payroll_manager"/>
<field name="notes"/>
</tree>
</field>
<group class="oe_subtotal_footer oe_right">
<field name="total_amount_paid"/>
<field name="total_paid"/>
</group>
</group>
</xpath>

4
ohrms_loan_accounting/README.md

@ -1,5 +1,5 @@
OHRMS Loan Management
=====================
Open HRMS Loan Accounting
=========================
Manage Loan Requests.

6
ohrms_loan_accounting/RELEASE_NOTES.md

@ -1,6 +0,0 @@
## Module ohrms_loan_accounting
#### 30.03.2018
#### Version 10.0.1.0.0
##### ADD
- Initial commit for OpenHrms Project

12
ohrms_loan_accounting/__manifest__.py

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
###################################################################################
# A part of OpenHRMS Project <https://www.openhrms.com>
# A part of Open HRMS Project <https://www.openhrms.com>
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2018-TODAY Cybrosys Technologies (<https://www.cybrosys.com>).
@ -21,19 +21,19 @@
#
###################################################################################
{
'name': 'OHRMS Loan Accounting',
'version': '10.0.1.0.0',
'summary': 'HR Loan Accounting',
'name': 'Open HRMS Loan Accounting',
'version': '10.0.2.0.0',
'summary': 'Open HRMS Loan Accounting',
'description': """
Create accounting entries for loan requests.
""",
'category': 'Generic Modules/Human Resources',
'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', 'ohrms_loan',
'base','hr_payroll', 'hr', 'account', 'ohrms_loan',
],
'data': [
'views/hr_loan_config.xml',

11
ohrms_loan_accounting/doc/RELEASE_NOTES.md

@ -0,0 +1,11 @@
## Module <ohrms_loan_accounting>
#### 09.04.2018
#### Version 10.0.2.0.0
##### CHG
- function changed.
#### 30.03.2018
#### Version 10.0.1.0.0
##### ADD
- Initial commit for Open HRMS Project

155
ohrms_loan_accounting/models/hr_loan_acc.py

@ -15,12 +15,12 @@ class HrLoanAcc(models.Model):
contract_obj = self.env['hr.contract'].search([('employee_id', '=', self.employee_id.id)])
if not contract_obj:
raise except_orm('Warning', 'You must Define a contract for employee')
if not self.loan_line_ids:
raise except_orm('Warning', 'You must compute Loan Request before Approved')
if not self.loan_lines:
raise except_orm('Warning', 'You must compute installment before Approved')
if loan_approve:
self.write({'state': 'waiting_approval_2'})
else:
raise except_orm('Warning', 'Enable the option for loan approval from accounting department')
raise except_orm('Warning', 'Enable the option for loan approval in accounting settings')
@api.multi
def action_double_approve(self):
@ -28,60 +28,46 @@ class HrLoanAcc(models.Model):
"""
if not self.emp_account_id or not self.treasury_account_id or not self.journal_id:
raise except_orm('Warning', "You must enter employee account & Treasury account and journal to approve ")
if not self.loan_line_ids:
if not self.loan_lines:
raise except_orm('Warning', 'You must compute Loan Request before Approved')
move_obj = self.env['account.move']
timenow = time.strftime('%Y-%m-%d')
line_ids = []
debit_sum = 0.0
credit_sum = 0.0
for loan in self:
amount = loan.loan_amount
loan_name = loan.employee_id.name
reference = loan.name
journal_id = loan.journal_id.id
move = {
debit_account_id = loan.treasury_account_id.id
credit_account_id = loan.emp_account_id.id
debit_vals = {
'name': loan_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,
'loan_id': loan.id,
}
credit_vals = {
'name': loan_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,
'loan_id': loan.id,
}
vals = {
'name': 'Loan For' + ' ' + loan_name,
'narration': loan_name,
'ref': reference,
'journal_id': journal_id,
'date': timenow,
'state': 'posted',
'line_ids': [(0, 0, debit_vals), (0, 0, credit_vals)]
}
debit_account_id = loan.treasury_account_id.id
credit_account_id = loan.emp_account_id.id
if debit_account_id:
debit_line = (0, 0, {
'name': loan_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,
'loan_id': loan.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': loan_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,
'loan_id': loan.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.move_id = move_id.id
self.write({'state': 'approve'})
return self.write({'move_id': move_id.id})
move = self.env['account.move'].create(vals)
move.post()
self.write({'state': 'approve'})
return True
class AccountMoveLine(models.Model):
@ -97,68 +83,63 @@ class HrLoanLineAcc(models.Model):
def action_paid_amount(self):
"""This create the account move line for payment of each installment.
"""
result = super(HrLoanLineAcc, self).action_paid_amount()
move_obj = self.env['account.move']
timenow = time.strftime('%Y-%m-%d')
line_ids = []
debit_sum = 0.0
credit_sum = 0.0
for line in self:
if line.loan_id.state != 'approve':
raise except_orm('Warning', "Loan Request must be approved")
amount = line.paid_amount
amount = line.amount
loan_name = line.employee_id.name
print "loan_name",loan_name
reference = line.loan_id.name
journal_id = line.loan_id.journal_id.id
move = {
debit_account_id = line.loan_id.emp_account_id.id
credit_account_id = line.loan_id.treasury_account_id.id
debit_vals = {
'name': loan_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,
'loan_id': line.loan_id.id,
}
credit_vals = {
'name': loan_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,
'loan_id': line.loan_id.id,
}
vals = {
'name': 'Loan For' + ' ' + loan_name,
'narration': loan_name,
'ref': reference,
'journal_id': journal_id,
'date': timenow,
'state': 'posted',
'line_ids': [(0, 0, debit_vals), (0, 0, credit_vals)]
}
debit_account_id = line.loan_id.emp_account_id.id
credit_account_id = line.loan_id.treasury_account_id.id
if debit_account_id:
debit_line = (0, 0, {
'name': loan_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,
'loan_id': line.loan_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': loan_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,
'loan_id': line.loan_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)
return result
move = self.env['account.move'].create(vals)
move.post()
return True
class HrPayslipAcc(models.Model):
_inherit = 'hr.payslip'
@api.multi
def compute_sheet(self):
res = super(HrPayslipAcc, self).compute_sheet()
if len(self.loan_ids) == 0:
loan_count = self.env['hr.loan'].search_count([('employee_id', '=', self.employee_id.id), ('state', '=', 'approve'),
('balance_amount', '!=', 0)])
if loan_count:
raise except_orm('Error!', 'Please Update the Loans')
else:
return res
else:
return res
@api.multi
def action_payslip_done(self):
rules = []

BIN
ohrms_loan_accounting/static/description/accounting_validation.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 119 KiB

BIN
ohrms_loan_accounting/static/description/advance_request_approval.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

BIN
ohrms_loan_accounting/static/description/banner.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 131 KiB

BIN
ohrms_loan_accounting/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

19
ohrms_loan_accounting/static/description/index.html

@ -1,7 +1,11 @@
<section class="oe_container">
<section class="oe_container bg-gray-lighter" xmlns="http://www.w3.org/1999/html">
<div class="oe_row">
<h2 class="oe_slogan">OpenHRMS</h2>
<div class="oe_span">
<h2 class="oe_slogan">Open HRMS</h2>
<h3 class="oe_slogan">Most advanced open source HR management software</h3>
</div>
</div>
</section>
@ -12,7 +16,6 @@
<a href="https://www.openhrms.com/#request-demo">
<img src="HRMS-BUTTON.png">
</a>
<div class="oe_demo_footer oe_centeralign">Online Demo</div>
</div>
</div>
@ -21,7 +24,7 @@
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">HR Loan</h2>
<h2 class="oe_slogan">Open HRMS Loan Accounting</h2>
<h3 class="oe_slogan">Manage Loan request of employees</h3>
<h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a></h4>
</div>
@ -41,8 +44,8 @@
<div class="oe_picture">
<h3 class="oe_slogan">Overview</h3>
<p class="oe_mt32">
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.
</p>
</div>
</div>
@ -55,7 +58,7 @@
<h3 class="oe_slogan">Configuration</h3>
</div>
<div class="" style="text-align: center;">
<p>Install the Module "HR Loan Accounting" in order to enable Accounting Entries.
<p>Install the Module "Open HRMS Loan Accounting" in order to enable Accounting Entries.
Enable the option "Loan Approval From Accounting Department" In accounting settings</p>
<div class="oe_span12">
<div class="oe_demo oe_picture oe_screenshot">
@ -122,7 +125,7 @@
<div class="" style="text-align: center;">
<h3 class="oe_slogan">Loan Amount Deduction</h3>
<p>When we check the Loan request again,
the deducted installments will be changed to paid state.</p>
the deducted installments will be changed to paid.</p>
<div class="oe_span12">
<div class="oe_demo oe_picture oe_screenshot">
<img style="border:10px solid white;" src="loan_amount_deduction.png">

BIN
ohrms_loan_accounting/static/description/loan_amount_deduction.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 111 KiB

BIN
ohrms_loan_accounting/static/description/loan_approval.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 125 KiB

BIN
ohrms_loan_accounting/static/description/loan_request.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 50 KiB

BIN
ohrms_loan_accounting/static/description/loan_rule.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 103 KiB

BIN
ohrms_loan_accounting/static/description/payslip.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 96 KiB

12
ohrms_loan_accounting/views/hr_loan_acc.xml

@ -1,20 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="act_hr_loan_request" model="ir.actions.act_window">
<field name="name">Loans</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.move.line</field>
<field name="src_model">hr.loan</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'search_default_loan_id': [active_id], 'default_loan_id': active_id}</field>
<field name="domain">[('loan_id','=',active_id)]</field>
</record>
<record id="hr_loan_inherited" model="ir.ui.view">
<field name="name">HR LOAN</field>
<field name="model">hr.loan</field>
<field name="inherit_id" ref="ohrms_loan.view_hr_loan_form"/>
<field name="inherit_id" ref="ohrms_loan.hr_loan_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='emp_account_id']" position="attributes">
<attribute name="invisible">0</attribute>

Loading…
Cancel
Save