Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
hr
hr_employee_loans
Commits
8031529f
Commit
8031529f
authored
3 years ago
by
Brian Misael López
Browse files
Options
Downloads
Patches
Plain Diff
dues month field
parent
e3791e4e
Branches
rr-167
Branches containing commit
1 merge request
!8
dues month field
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
__manifest__.py
+1
-0
__manifest__.py
models/hr_employee_loans.py
+19
-11
models/hr_employee_loans.py
models/hr_employee_loans_line.py
+1
-0
models/hr_employee_loans_line.py
security/security_rules.xml
+21
-0
security/security_rules.xml
views/hr_employee_loans_line_view.xml
+2
-0
views/hr_employee_loans_line_view.xml
views/hr_employee_loans_view.xml
+1
-0
views/hr_employee_loans_view.xml
with
45 additions
and
11 deletions
__manifest__.py
+
1
−
0
View file @
8031529f
...
...
@@ -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
,
...
...
This diff is collapsed.
Click to expand it.
models/hr_employee_loans.py
+
19
−
11
View file @
8031529f
...
...
@@ -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
'
})
...
...
This diff is collapsed.
Click to expand it.
models/hr_employee_loans_line.py
+
1
−
0
View file @
8031529f
...
...
@@ -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
'
,
...
...
This diff is collapsed.
Click to expand it.
security/security_rules.xml
0 → 100644
+
21
−
0
View file @
8031529f
<?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>
This diff is collapsed.
Click to expand it.
views/hr_employee_loans_line_view.xml
+
2
−
0
View file @
8031529f
...
...
@@ -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"
...
...
This diff is collapsed.
Click to expand it.
views/hr_employee_loans_view.xml
+
1
−
0
View file @
8031529f
...
...
@@ -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"
/>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets