Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
7158b5e6
Commit
7158b5e6
authored
5 years ago
by
RomainLibert
Committed by
Yannick Tivisse
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[IMP] hr_holidays: Adapt module with new hr.employee.public model
parent
df69d5b3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
addons/hr_holidays/models/hr.py
+6
-7
6 additions, 7 deletions
addons/hr_holidays/models/hr.py
addons/hr_holidays/views/hr_views.xml
+46
-0
46 additions, 0 deletions
addons/hr_holidays/views/hr_views.xml
with
52 additions
and
7 deletions
addons/hr_holidays/models/hr.py
+
6
−
7
View file @
7158b5e6
...
...
@@ -4,8 +4,7 @@
import
datetime
from
dateutil.relativedelta
import
relativedelta
from
odoo
import
api
,
fields
,
models
,
_
from
odoo.exceptions
import
UserError
from
odoo
import
api
,
fields
,
models
from
odoo.tools.float_utils
import
float_round
...
...
@@ -61,8 +60,8 @@ class Department(models.Model):
department
.
total_employee
=
result
.
get
(
department
.
id
,
0
)
class
Employee
(
models
.
Model
):
_inherit
=
"
hr.employee
"
class
Hr
Employee
Base
(
models
.
Abstract
Model
):
_inherit
=
"
hr.employee
.base
"
def
_group_hr_user_domain
(
self
):
group
=
self
.
env
.
ref
(
'
hr_holidays.group_hr_holidays_team_leader
'
,
raise_if_not_found
=
False
)
...
...
@@ -173,7 +172,7 @@ class Employee(models.Model):
@api.onchange
(
'
parent_id
'
)
def
_onchange_parent_id
(
self
):
super
(
Employee
,
self
).
_onchange_parent_id
()
super
(
Hr
Employee
Base
,
self
).
_onchange_parent_id
()
previous_manager
=
self
.
_origin
.
parent_id
.
user_id
manager
=
self
.
parent_id
.
user_id
if
manager
and
manager
.
has_group
(
'
hr.group_hr_user
'
)
and
(
self
.
leave_manager_id
==
previous_manager
or
not
self
.
leave_manager_id
):
...
...
@@ -199,7 +198,7 @@ class Employee(models.Model):
return
[(
'
id
'
,
'
in
'
,
holidays
.
mapped
(
'
employee_id
'
).
ids
)]
def
write
(
self
,
values
):
res
=
super
(
Employee
,
self
).
write
(
values
)
res
=
super
(
Hr
Employee
Base
,
self
).
write
(
values
)
today_date
=
fields
.
Datetime
.
now
()
if
'
parent_id
'
in
values
or
'
department_id
'
in
values
:
hr_vals
=
{}
...
...
@@ -207,7 +206,7 @@ class Employee(models.Model):
hr_vals
[
'
manager_id
'
]
=
values
[
'
parent_id
'
]
if
values
.
get
(
'
department_id
'
)
is
not
None
:
hr_vals
[
'
department_id
'
]
=
values
[
'
department_id
'
]
holidays
=
self
.
env
[
'
hr.leave
'
].
search
([
'
|
'
,(
'
state
'
,
'
in
'
,
[
'
draft
'
,
'
confirm
'
]),(
'
date_from
'
,
'
>
'
,
today_date
),
(
'
employee_id
'
,
'
in
'
,
self
.
ids
)])
holidays
=
self
.
env
[
'
hr.leave
'
].
search
([
'
|
'
,
(
'
state
'
,
'
in
'
,
[
'
draft
'
,
'
confirm
'
]),
(
'
date_from
'
,
'
>
'
,
today_date
),
(
'
employee_id
'
,
'
in
'
,
self
.
ids
)])
holidays
.
write
(
hr_vals
)
allocations
=
self
.
env
[
'
hr.leave.allocation
'
].
search
([(
'
state
'
,
'
in
'
,
[
'
draft
'
,
'
confirm
'
]),
(
'
employee_id
'
,
'
in
'
,
self
.
ids
)])
allocations
.
write
(
hr_vals
)
...
...
This diff is collapsed.
Click to expand it.
addons/hr_holidays/views/hr_views.xml
+
46
−
0
View file @
7158b5e6
...
...
@@ -177,6 +177,52 @@
</field>
</record>
<record
id=
"hr_employee_public_form_view_inherit"
model=
"ir.ui.view"
>
<field
name=
"name"
>
hr.employee.public.leave.form.inherit
</field>
<field
name=
"model"
>
hr.employee.public
</field>
<field
name=
"inherit_id"
ref=
"hr.hr_employee_public_view_form"
/>
<field
name=
"arch"
type=
"xml"
>
<xpath
expr=
"//field[@name='coach_id']"
position=
"after"
>
<field
name=
"leave_manager_id"
/>
</xpath>
<xpath
expr=
"//div[@name='button_box']"
position=
"inside"
>
<field
name=
"current_leave_id"
invisible=
"1"
/>
<field
name=
"show_leaves"
invisible=
"1"
/>
<field
name=
"is_absent"
invisible=
"1"
/>
<button
name=
"%(hr_leave_action_new_request)d"
type=
"action"
class=
"oe_stat_button"
attrs=
"{'invisible': [('is_absent', '=', False)]}"
>
<div
role=
"img"
class=
"fa fa-fw fa-circle o_button_icon text-danger"
aria-label=
"Absent Until"
title=
"Absent Until"
/>
<div
class=
"o_field_widget o_stat_info"
>
<span
class=
"o_stat_value"
>
<field
name=
"leave_date_to"
/>
</span>
<span
class=
"o_stat_text"
>
Absent Until
</span>
</div>
</button>
<button
name=
"%(hr_leave_action_new_request)d"
type=
"action"
class=
"oe_stat_button"
icon=
"fa-calendar"
attrs=
"{'invisible': [('show_leaves','=', False)]}"
groups=
"base.group_user"
help=
"Remaining leaves"
>
<div
class=
"o_field_widget o_stat_info"
>
<span
class=
"o_stat_value"
>
<field
name=
"allocation_used_count"
digits=
"[42,1]"
/>
/
<field
name=
"allocation_count"
digits=
"[42,1]"
/>
</span>
<span
class=
"o_stat_text"
>
Time Off
</span>
</div>
</button>
</xpath>
</field>
</record>
<record
id=
"res_users_view_form"
model=
"ir.ui.view"
>
<field
name=
"name"
>
hr.user.preferences.view.form.leave.inherit
</field>
<field
name=
"model"
>
res.users
</field>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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