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
d985e9e4
Commit
d985e9e4
authored
Jan 23, 2025
by
Yvon Kerdoncuff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#7332 : rework makeups management in binom creation code + some makeups refactoring
parent
97e7bc61
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
74 deletions
+98
-74
admin.py
members/admin.py
+77
-56
models.py
members/models.py
+3
-12
fonctions.py
shifts/fonctions.py
+11
-5
models.py
shifts/models.py
+7
-1
No files found.
members/admin.py
View file @
d985e9e4
This diff is collapsed.
Click to expand it.
members/models.py
View file @
d985e9e4
...
...
@@ -1065,20 +1065,11 @@ class CagetteMember(models.Model):
return
res
def
get_member_selected_makeups
(
self
):
res
=
{}
c
=
[[
"partner_id"
,
"="
,
self
.
id
],
[
"is_makeup"
,
"="
,
True
],
[
"state"
,
"="
,
"open"
]]
f
=
[
'id'
]
res
=
self
.
o_api
.
search_read
(
"shift.registration"
,
c
,
f
)
return
res
def
get_makeup_registrations_ids_on_shift_template
(
self
,
shift_template_id
):
""" Get the makeup registrations that are on a shift template """
makeup_reg_ids
=
[]
c
=
[[
"partner_id"
,
"="
,
self
.
id
],
[
"is_makeup"
,
"="
,
True
],
[
"state"
,
"="
,
"open"
]]
f
=
[
'id'
,
'shift_id'
]
res_shift_ids
=
self
.
o_api
.
search_read
(
"shift.registration"
,
c
,
f
)
res_shift_ids
=
shifts
.
fonctions
.
get_scheduled_makeups
(
self
.
api
,
partner_ids
=
[
self
.
id
])
for
shift_reg
in
res_shift_ids
:
c
=
[[
"id"
,
"="
,
int
(
shift_reg
[
'shift_id'
][
0
])]]
f
=
[
'shift_template_id'
]
...
...
@@ -1369,6 +1360,7 @@ class CagetteMembers(models.Model):
@staticmethod
def
get_makeups_members
(
ids
=
[]):
# 0 : fetch members with makeups_to_do > 0
api
=
OdooAPI
()
cond
=
[[
'makeups_to_do'
,
'>'
,
0
]]
...
...
@@ -1405,8 +1397,7 @@ class CagetteMembers(models.Model):
def
add_makeups_to_come_to_member_data
(
api
,
res
):
if
res
:
for
idx
,
partner
in
enumerate
(
res
):
[
shift_data
,
is_ftop
]
=
shifts
.
fonctions
.
get_shift_partner
(
api
,
int
(
partner
[
'id'
]))
res
[
idx
][
'makeups_to_come'
]
=
sum
(
1
for
value
in
shift_data
if
value
[
'is_makeup'
])
res
[
idx
][
'makeups_to_come'
]
=
len
(
shifts
.
fonctions
.
get_scheduled_makeups
(
api
,
partner_ids
=
[
int
(
partner
[
'id'
])]))
@staticmethod
def
get_attached_members
():
...
...
shifts/fonctions.py
View file @
d985e9e4
...
...
@@ -9,9 +9,7 @@ def dateIsoUTC(myDate):
def
get_partners_with_makeups_to_come
(
api
):
"""Returns a dictionary with : keys = the partners ids having at least one makeup to come ; values = #makeups_to_come"""
fields
=
[
'partner_id'
]
cond
=
[[
'state'
,
'='
,
'open'
],
[
'date_begin'
,
'>'
,
datetime
.
datetime
.
now
()
.
isoformat
()],
[
'is_makeup'
,
'='
,
True
]]
shift_data
=
api
.
search_read
(
'shift.registration'
,
cond
,
fields
)
shift_data
=
get_scheduled_makeups
(
api
)
count_dic
=
{}
for
value
in
shift_data
:
if
value
[
'partner_id'
][
0
]
in
count_dic
:
...
...
@@ -47,4 +45,13 @@ def get_exempted_ids_from(api, partner_ids):
cond
=
[[
'id'
,
'in'
,
partner_ids
],
[
'cooperative_state'
,
'in'
,
[
'exempted'
]]]
fields
=
[
'id'
]
return
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
\ No newline at end of file
return
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
def
get_scheduled_makeups
(
api
,
partner_ids
=
None
):
c
=
[[
"is_makeup"
,
"="
,
True
],
[
"state"
,
"="
,
"open"
],
[
'date_begin'
,
'>'
,
datetime
.
datetime
.
now
()
.
isoformat
()]]
if
partner_ids
:
c
.
append
([
"partner_id"
,
"in"
,
partner_ids
])
f
=
[
'id'
,
'shift_id'
,
'partner_id'
]
res_shift_ids
=
api
.
search_read
(
"shift.registration"
,
c
,
f
)
return
res_shift_ids
shifts/models.py
View file @
d985e9e4
...
...
@@ -297,7 +297,13 @@ class CagetteShift(models.Model):
def
set_shift
(
self
,
data
):
"""Shift registration.
Decrement makeups_to_do if shift has to be a makeup.
Handle partner already registered on this shift case."""
Handle partner already registered on this shift case.
data should coutain :
- idPartner
- idShift
- shift_type
- is_makeup
"""
st_r_id
=
False
try
:
shift_type
=
"standard"
...
...
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