Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cgscop_timesheet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Le Filament
Confédération Générale des SCOP
cgscop_timesheet
Commits
11a04b2b
Commit
11a04b2b
authored
2 years ago
by
Benjamin - Le Filament
Browse files
Options
Downloads
Patches
Plain Diff
[fix] constraint only on timesheet analytic line
parent
2bc0f6fc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
models/hr_timesheet.py
+21
-20
21 additions, 20 deletions
models/hr_timesheet.py
with
21 additions
and
20 deletions
models/hr_timesheet.py
+
21
−
20
View file @
11a04b2b
...
...
@@ -157,27 +157,28 @@ class ScopHrTimesheet(models.Model):
@api.constrains
(
"
unit_amount
"
,
"
date
"
)
def
_check_hours
(
self
):
for
record
in
self
:
lines
=
self
.
search
(
[
(
"
date
"
,
"
=
"
,
record
.
date
),
(
"
employee_id
"
,
"
=
"
,
record
.
employee_id
.
id
),
]
)
total
=
sum
(
lines
.
mapped
(
"
unit_amount
"
))
if
(
not
self
.
env
.
company
.
day_working
and
total
>
self
.
env
.
company
.
day_duration
):
raise
ValidationError
(
_
(
"
Vous ne pouvez imputer plus de %sh sur la même journée.
\n
"
"
Journée du %s
"
)
%
(
self
.
env
.
company
.
day_duration
,
record
.
date
.
strftime
(
"
%d/%m/%Y
"
),
)
if
record
.
project_id
:
lines
=
self
.
search
(
[
(
"
date
"
,
"
=
"
,
record
.
date
),
(
"
employee_id
"
,
"
=
"
,
record
.
employee_id
.
id
),
]
)
total
=
sum
(
lines
.
mapped
(
"
unit_amount
"
))
if
(
not
self
.
env
.
company
.
day_working
and
total
>
self
.
env
.
company
.
day_duration
):
raise
ValidationError
(
_
(
"
Vous ne pouvez imputer plus de %sh sur la même journée.
\n
"
"
Journée du %s
"
)
%
(
self
.
env
.
company
.
day_duration
,
record
.
date
.
strftime
(
"
%d/%m/%Y
"
),
)
)
@api.constrains
(
"
date
"
)
def
_check_weekday
(
self
):
...
...
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