Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
third-party
Commits
e02051af
Commit
e02051af
authored
Feb 06, 2025
by
Yvon Kerdoncuff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log / triggers error where there are potentially negative makeups_to_do values that are set
parent
26fb019c
Pipeline
#4116
canceled with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
4 deletions
+26
-4
admin.py
members/admin.py
+11
-0
models.py
members/models.py
+5
-0
models.py
shifts/models.py
+10
-4
No files found.
members/admin.py
View file @
e02051af
...
...
@@ -788,6 +788,17 @@ def create_pair(request):
child_makeups
=
child
[
'makeups_to_do'
]
parent_makeups
=
parent
[
'makeups_to_do'
]
if
child_makeups
<
0
or
parent_makeups
<
0
:
coop_logger
.
error
(
"Erreur : le suppléant (
%
s) ou le titulaire (
%
s) a un compteur de rattrapages négatif."
,
child_makeups
,
parent_makeups
)
return
JsonResponse
(
{
"message"
:
"Erreur : le suppléant ou le titulaire a un compteur de rattrapages négatif."
},
status
=
409
)
child_scheduled_makeups
=
shifts
.
fonctions
.
get_scheduled_makeups
(
api
,
partner_ids
=
[
child_id
])
parent_scheduled_makeups_length
=
len
(
shifts
.
fonctions
.
get_scheduled_makeups
(
api
,
partner_ids
=
[
parent_id
]))
...
...
members/models.py
View file @
e02051af
...
...
@@ -1125,6 +1125,11 @@ class CagetteMember(models.Model):
def
update_member_makeups
(
self
,
member_data
):
api
=
OdooAPI
()
makeups_to_do
=
int
(
member_data
[
"target_makeups_nb"
])
if
makeups_to_do
<
0
:
coop_logger
.
error
(
"Erreur : dans update_member_makeups, target makeups_to_do =
%
s."
,
makeups_to_do
)
f
=
{
'makeups_to_do'
:
makeups_to_do
}
res_item
=
api
.
update
(
'res.partner'
,
[
self
.
id
],
f
)
res
=
{
...
...
shifts/models.py
View file @
e02051af
...
...
@@ -223,14 +223,20 @@ class CagetteShift(models.Model):
try
:
# Ok if makeups_to_do go under 0, until unselect_makeup is called,
# (this is needed when set_shift is called from change_shift)
# This is the only place where we are allowed to set a negative count of makeups_to_do,
# only when we unselect_makeup later.
makeups_to_do_target
=
self
.
get_member_makeups_to_do
(
partner_id
)
-
1
res_decrement
=
self
.
o_api
.
update
(
'res.partner'
,
[
partner_id
],
{
"makeups_to_do"
:
self
.
get_member_makeups_to_do
(
partner_id
)
-
1
}
{
"makeups_to_do"
:
makeups_to_do_target
}
)
# Usually not needed because another odoo method that automaticaly triggers status recompute is
# often called after a makeup change, manual update IS REQUIRED here.
self
.
o_api
.
execute
(
'res.partner'
,
'recompute_member_states'
,
[
partner_id
])
if
makeups_to_do_target
<
0
:
coop_logger
.
debug
(
"Setting a negative makeups_to_do value in set_shift prior to call unselect_makeup."
)
else
:
# Usually not needed because another odoo method that automaticaly triggers status recompute is
# often called after a makeup change, manual update IS REQUIRED here.
self
.
o_api
.
execute
(
'res.partner'
,
'recompute_member_states'
,
[
partner_id
])
except
Exception
as
e
:
coop_logger
.
error
(
"Decrement makeups to do and recompute member states :
%
s,
%
s"
,
str
(
e
),
str
(
data
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment