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
a41d5985
Commit
a41d5985
authored
Jul 06, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EP: make sure only 1 shift can be deleted after both partners are present
parent
f9104641
Pipeline
#2300
passed with stage
in 1 minute 24 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
5 deletions
+28
-5
models.py
members/models.py
+28
-5
No files found.
members/models.py
View file @
a41d5985
...
...
@@ -1400,8 +1400,15 @@ class CagetteServices(models.Model):
"""Equivalent to click present in presence form."""
api
=
OdooAPI
()
f
=
{
'state'
:
'done'
}
if
(
typeAction
!=
"normal"
and
typeAction
!=
""
):
f
[
'associate_registered'
]
=
typeAction
if
typeAction
==
"both"
:
f
[
'should_increment_extra_shift_done'
]
=
True
else
:
f
[
'should_increment_extra_shift_done'
]
=
False
late_mode
=
getattr
(
settings
,
'ENTRANCE_WITH_LATE_MODE'
,
False
)
if
late_mode
is
True
:
# services = CagetteServices.get_services_at_time('14:28',0, with_members=False)
...
...
@@ -1445,9 +1452,13 @@ class CagetteServices(models.Model):
"related_shift_state"
:
'confirm'
,
"state"
:
'open'
}
reg_id
=
api
.
create
(
'shift.registration'
,
fields
)
f
=
{
'state'
:
'done'
}
if
(
typeAction
!=
"normal"
and
typeAction
!=
""
):
f
[
'associate_registered'
]
=
typeAction
if
typeAction
==
"both"
:
f
[
'should_increment_extra_shift_done'
]
=
True
return
api
.
update
(
'shift.registration'
,
[
int
(
reg_id
)],
f
)
@staticmethod
...
...
@@ -1467,17 +1478,29 @@ class CagetteServices(models.Model):
# Let's start by adding an extra shift to associated member who came together
cond
=
[[
'date_begin'
,
'>='
,
date_24h_before
.
isoformat
()],
[
'date_begin'
,
'<='
,
end_date
.
isoformat
()],
[
'date_closed'
,
'='
,
False
],
[
'state'
,
'='
,
'done'
],
[
'associate_registered'
,
'='
,
'both'
]]
fields
=
[
'state'
,
'partner_id'
,
'date_begin'
]
[
'state'
,
'='
,
'done'
],
[
'associate_registered'
,
'='
,
'both'
],
[
'should_increment_extra_shift_done'
,
'='
,
True
]]
fields
=
[
'id'
,
'state'
,
'partner_id'
,
'date_begin'
]
res
=
api
.
search_read
(
'shift.registration'
,
cond
,
fields
)
print
(
res
)
extra_shift_done_incremented_srids
=
[]
# shift registration ids
for
r
in
res
:
cond
=
[[
'id'
,
'='
,
r
[
'partner_id'
][
0
]]]
fields
=
[
'id'
,
'extra_shift_done'
]
res
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
f
=
{
'extra_shift_done'
:
res
[
0
][
'extra_shift_done'
]
+
1
}
res_partner
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
f
=
{
'extra_shift_done'
:
res_partner
[
0
][
'extra_shift_done'
]
+
1
}
api
.
update
(
'res.partner'
,
[
r
[
'partner_id'
][
0
]],
f
)
extra_shift_done_incremented_srids
.
append
(
int
(
r
[
'id'
]))
# Make sure the counter isn't incremented twice
f
=
{
'should_increment_extra_shift_done'
:
False
}
api
.
update
(
'shift.registration'
,
extra_shift_done_incremented_srids
,
f
)
absence_status
=
'excused'
res_c
=
api
.
search_read
(
'ir.config_parameter'
,
[[
'key'
,
'='
,
'lacagette_membership.absence_status'
]],
...
...
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