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
02ee410b
Commit
02ee410b
authored
Jan 09, 2025
by
Yvon Kerdoncuff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#7425 : never increment makeups from third-party as this is handled by odoo
parent
813db0c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
64 deletions
+40
-64
admin.py
members/admin.py
+38
-56
models.py
members/models.py
+2
-8
No files found.
members/admin.py
View file @
02ee410b
...
@@ -394,6 +394,22 @@ def update_members_makeups(request):
...
@@ -394,6 +394,22 @@ def update_members_makeups(request):
if
is_connected_user
is
True
:
if
is_connected_user
is
True
:
members_data
=
json
.
loads
(
request
.
body
.
decode
())
members_data
=
json
.
loads
(
request
.
body
.
decode
())
# Make sure update would not unsubscribe member
cs
=
CagetteShift
()
unsubscription_limit
=
api
.
get_system_param
(
'lacagette_membership.points_limit_to_get_unsubscribed'
)
for
member_data
in
members_data
:
cm
=
CagetteMember
(
int
(
member_data
[
"member_id"
]))
target_makeups_nb
=
int
(
member_data
[
"target_makeups_nb"
])
if
target_makeups_nb
<
0
:
# Prevent setting a negative number of makeups_to_do https://redmine.coopdev.fr/issues/6090
# This could happen when bdm has two screens open and clicks on minus btn on a coop line
# with exactly 1 makeup_to_do on both screens
error
=
[]
error
[
"error"
]
=
"L'opération de rattrapage a été annulée car le nombre de rattrapage cible est négatif."
return
JsonResponse
(
error
,
status
=
400
)
makeup_change_count
=
target_makeups_nb
-
cs
.
get_member_makeups_to_do
(
cm
.
id
)
members_data
[
member_data
[
"member_id"
]][
"points_diff"
]
=
-
makeup_change_count
res
[
"res"
]
=
[]
res
[
"res"
]
=
[]
update_members_makeups_core
(
members_data
,
res
)
update_members_makeups_core
(
members_data
,
res
)
response
=
JsonResponse
(
res
)
response
=
JsonResponse
(
res
)
...
@@ -407,50 +423,21 @@ def update_members_makeups_core(members_data, res):
...
@@ -407,50 +423,21 @@ def update_members_makeups_core(members_data, res):
for
member_data
in
members_data
:
for
member_data
in
members_data
:
cm
=
CagetteMember
(
int
(
member_data
[
"member_id"
]))
cm
=
CagetteMember
(
int
(
member_data
[
"member_id"
]))
res
[
"res"
]
.
append
(
cm
.
update_member_makeups
(
member_data
))
# If points are added, we need to manage makeups count change here,
# otherwise this is handled automatically by odoo when points are changed
# Update member standard points, for standard members only
if
member_data
[
"points_diff"
]
>
0
:
if
member_data
[
"member_shift_type"
]
==
"standard"
:
res
[
"res"
]
.
append
(
cm
.
update_member_makeups
(
member_data
))
# Set points to minus the number of makeups to do + the makeups to come (limited to -2)
cs
=
CagetteShift
()
[
shift_data
,
is_ftop
]
=
cs
.
get_shift_partner
(
int
(
member_data
[
"member_id"
]))
target_points
=
-
int
(
member_data
[
"target_makeups_nb"
])
-
sum
(
1
for
value
in
shift_data
if
value
[
'is_makeup'
])
if
(
target_points
<
-
2
):
target_points
=
-
2
member_points
=
cm
.
get_member_points
(
"standard"
)
points_diff
=
abs
(
member_points
-
target_points
)
# Don't update if no change
if
points_diff
==
0
:
res
[
"res"
][
-
1
][
'standard_points'
]
=
member_points
continue
if
member_points
>
target_points
:
points_update
=
-
points_diff
else
:
points_update
=
points_diff
data
=
{
'name'
:
"Admin BDM - "
+
member_data
[
"description"
],
'shift_id'
:
False
,
'type'
:
member_data
[
"member_shift_type"
],
'partner_id'
:
int
(
member_data
[
"member_id"
]),
'point_qty'
:
points_update
}
cm
.
update_member_points
(
data
)
data
=
{
#There are some odoo process happening here that could change the actual number of points
'name'
:
"Admin BDM - "
+
member_data
[
"description"
],
#so we want to fetch it again to send it back
'shift_id'
:
False
,
res
[
"res"
][
-
1
][
'standard_points'
]
=
cm
.
get_member_points
(
"standard"
)
'type'
:
member_data
[
"member_shift_type"
],
# Better to call run_process_target_status now, otherwise partner remains
'partner_id'
:
int
(
member_data
[
"member_id"
]),
# in alert until routine is called (every 5 minutes). It is a bit weird for users and
'point_qty'
:
member_data
[
'points_diff'
]
# allocation of rattrapages before the routine is executed will not trigger change to delay state !
}
# (the parner would have to go back to espace membre and click on "j'affecte mes rattrapage"
cm
.
update_member_points
(
data
)
# even though it shows 'J'ai 0 rattrapages à effecter' for the delay state change to be eventually triggered)
api
=
OdooAPI
()
api
.
execute
(
'res.partner'
,
'run_process_target_status'
,
[])
res
[
"res"
][
-
1
][
'standard_points'
]
=
cm
.
get_member_points
(
"standard"
)
def
regenerate_member_delay
(
request
):
def
regenerate_member_delay
(
request
):
""" From BDM admin, close existing extension if exists & recreate for 6 months """
""" From BDM admin, close existing extension if exists & recreate for 6 months """
...
@@ -554,23 +541,15 @@ def delete_shift_template_registration(request):
...
@@ -554,23 +541,15 @@ def delete_shift_template_registration(request):
try
:
try
:
data
=
json
.
loads
(
request
.
body
.
decode
())
data
=
json
.
loads
(
request
.
body
.
decode
())
partner_id
=
int
(
data
[
"partner_id"
])
partner_id
=
int
(
data
[
"partner_id"
])
shift_template_id
=
int
(
data
[
"shift_template_id"
])
makeups_to_do
=
int
(
data
[
"makeups_to_do"
])
permanent_unsuscribe
=
data
[
"permanent_unsuscribe"
]
permanent_unsuscribe
=
data
[
"permanent_unsuscribe"
]
cm
=
CagetteMember
(
partner_id
)
# Knowing that the total number of makeups will always be 2 or less,
# old code here would only increment the number of makeups...
# Get partner nb of future makeup shifts
# which is not needed as makeup increment is now handled
partner_makeups
=
cm
.
get_member_selected_makeups
()
# by odoo.
target_makeup
=
makeups_to_do
+
len
(
partner_makeups
)
if
target_makeup
>
2
:
target_makeup
=
2
# Update partner makeups to do
res
[
"update_makeups"
]
=
cm
.
update_member_makeups
({
'target_makeups_nb'
:
target_makeup
})
# Delete all shift registrations & shift template registration
# Delete all shift registrations & shift template registration
cm
=
CagetteMember
(
partner_id
)
res
[
"unsubscribe_member"
]
=
cm
.
unsubscribe_member
()
res
[
"unsubscribe_member"
]
=
cm
.
unsubscribe_member
()
if
permanent_unsuscribe
is
True
:
if
permanent_unsuscribe
is
True
:
...
@@ -676,12 +655,15 @@ def shift_subscription(request):
...
@@ -676,12 +655,15 @@ def shift_subscription(request):
def
lower_makeup_count_to_zero_if_moving_from_std_to_ftop
(
partner_id
,
res
):
def
lower_makeup_count_to_zero_if_moving_from_std_to_ftop
(
partner_id
,
res
):
cs
=
CagetteShift
()
cm
=
CagetteMember
(
partner_id
)
members_data
=
[]
members_data
=
[]
members_data
.
append
({
members_data
.
append
({
'member_id'
:
partner_id
,
'member_id'
:
partner_id
,
'member_shift_type'
:
'standard'
,
'member_shift_type'
:
'standard'
,
'target_makeups_nb'
:
0
,
'target_makeups_nb'
:
0
,
'description'
:
'reset automatique du compteur rattrapages suite changement créneau standard vers non standard'
'description'
:
'reset automatique du compteur rattrapages suite changement créneau standard vers non standard'
,
'points_diff'
:
cs
.
get_member_makeups_to_do
(
cm
.
id
)
})
})
res
[
"res"
]
=
[]
res
[
"res"
]
=
[]
update_members_makeups_core
(
members_data
,
res
)
update_members_makeups_core
(
members_data
,
res
)
...
...
members/models.py
View file @
02ee410b
...
@@ -1054,14 +1054,8 @@ class CagetteMember(models.Model):
...
@@ -1054,14 +1054,8 @@ class CagetteMember(models.Model):
def
update_member_makeups
(
self
,
member_data
):
def
update_member_makeups
(
self
,
member_data
):
api
=
OdooAPI
()
api
=
OdooAPI
()
res
=
{}
makeups_to_do
=
int
(
member_data
[
"target_makeups_nb"
])
f
=
{
'makeups_to_do'
:
makeups_to_do
}
# Prevent setting a negative number of makeups_to_do
# https://redmine.coopdev.fr/issues/6090
# This could happen when bdm has two screens open and clicks on minus btn on a coop line
# with exactly 1 makeup_to_do on both screens
makeups_to_do
=
max
(
0
,
int
(
member_data
[
"target_makeups_nb"
]))
f
=
{
'makeups_to_do'
:
makeups_to_do
}
res_item
=
api
.
update
(
'res.partner'
,
[
self
.
id
],
f
)
res_item
=
api
.
update
(
'res.partner'
,
[
self
.
id
],
f
)
res
=
{
res
=
{
'mid'
:
self
.
id
,
'mid'
:
self
.
id
,
...
...
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