Commit 8031529f authored by Brian Misael López's avatar Brian Misael López
Browse files

dues month field

parent e3791e4e
Branches rr-167
1 merge request!8dues month field
Showing with 45 additions and 11 deletions
......@@ -36,6 +36,7 @@
'report/report_employee_loan.xml',
'report/report_employee_template.xml',
'security/ir.model.access.csv',
'security/security_rules.xml',
],
'application': False,
'installable': True,
......
......@@ -31,6 +31,7 @@ class HREmployeeLoans(models.Model):
readonly=True, states={'draft': [('readonly', False)]})
balance_loan = fields.Monetary('Loan Balance', compute='_balance_loan', currency_field='currency_id', store=True,
readonly=True)
dues_month = fields.Date()
state = fields.Selection([
('draft', 'Draft'),
('approve', 'Approve'),
......@@ -127,6 +128,7 @@ class HREmployeeLoans(models.Model):
'fee_import': fee,
'start_date': date_range[0],
'end_date': date_range[1],
'dues_month': date_from,
})
date_from += relativedelta(months=1)
if loan.total_import > total:
......@@ -143,10 +145,16 @@ class HREmployeeLoans(models.Model):
@api.multi
def set_draft(self):
some_done = []
for loan in self:
for rec in loan.employee_loan_ids:
if rec.state == 'done':
some_done.append(rec.state)
if not some_done:
for i in range(loan.refund_fees_qty):
self.employee_loan_ids.unlink()
return self.write({'state': 'draft'})
return self.write({'state': 'draft'})
raise UserError(_('Found a loan fee with state == done, it can´t be deleted. Please do a new loan'))
@api.multi
def set_approve(self):
......@@ -169,16 +177,16 @@ class HREmployeeLoans(models.Model):
for loan in loans:
loan_lines.append(loan.employee_loan_ids.filtered(lambda
r: r.start_date <= fields.Date.today() and r.end_date >= fields.Date.today() and r.state == 'draft'))
for line in loan_lines:
if line.fee_import:
self.env['hr.payroll.extra.concept'].create({
'employee_id': line.employee_loan_id.employee_id.id,
'salary_rule_id': loan_salary_rule_id,
'start_date': line.start_date,
'end_date': line.end_date,
'quantity': line.fee_import,
})
line.write({'state': 'done'})
for line in loan_lines:
if line.fee_import:
self.env['hr.payroll.extra.concept'].create({
'employee_id': line.employee_loan_id.employee_id.id,
'salary_rule_id': loan_salary_rule_id,
'start_date': line.start_date,
'end_date': line.end_date,
'quantity': line.fee_import,
})
line.write({'state': 'done'})
if all(line.state == 'done' for line in loan.employee_loan_ids):
loan.write({'state': 'done'})
......
......@@ -19,6 +19,7 @@ class HREmployeeLoansLine(models.Model):
], string='State', default='draft', required=True)
start_date = fields.Date('Start date', required=True)
end_date = fields.Date('End date', required=True)
dues_month = fields.Date(string='Dues Month', invisible=True)
_sql_constraints = [
('constraint_fee_number',
......
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="account_assets_loans_groups" model="ir.module.category">
<field name="name">Loans Management</field>
<field name="description">Category for loans</field>
<field name="sequence">14</field>
</record>
<record id="group_loans_employee" model="res.groups">
<field name="name">Employee</field>
<field name="category_id" ref="account_assets_loans_groups"/>
</record>
<record id="group_loans_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="account_assets_loans_groups"/>
<field name="implied_ids" eval="[(4, ref('group_loans_employee'))]"/>
</record>
</odoo>
......@@ -50,10 +50,12 @@
<field name="fee_number" string="Fee number"/>
<field name="start_date" invisible="1"/>
<field name="end_date" invisible="1"/>
<field name="dues_month" invisible="1"/>
<field name="fee_month"/>
<field name="fee_year"/>
<field name="fee_import"/>
<field name="state"/>
<field name="employee_loan_id"/>
<group expand="0" string="Group By">
<filter name="group_by_year"
string="Year"
......
......@@ -35,6 +35,7 @@
<sheet>
<group>
<group>
<field name="dues_month" invisible="True"/>
<field name="employee_id"/>
<field name="loan_reason"/>
<field name="loan_date"/>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment