Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
odoo
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
0
Merge Requests
0
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
odoo
Commits
ccfc19f7
Commit
ccfc19f7
authored
Oct 07, 2022
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent shift registration if member is exempted at shift date
parent
fd231727
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
shift_template.py
...ette_addons/lacagette_membership/models/shift_template.py
+19
-2
No files found.
lacagette_addons/lacagette_membership/models/shift_template.py
View file @
ccfc19f7
...
@@ -13,6 +13,21 @@ class ShiftTemplate(models.Model):
...
@@ -13,6 +13,21 @@ class ShiftTemplate(models.Model):
_inherit
=
'shift.template'
_inherit
=
'shift.template'
def
_will_member_be_still_exempted_at_date
(
self
,
partner
,
rec_date
):
answer
=
False
if
partner
.
cooperative_state
==
"exempted"
:
#_logger.debug("%s is exempted now, but what about at %s", str(partner.id), str(rec_date))
rec_date
=
datetime
.
strptime
(
rec_date
,
'
%
Y-
%
m-
%
d'
)
for
l
in
partner
.
leave_ids
:
#_logger.debug("leave start end : %s %s", str(l.start_date), str(l.stop_date))
if
(
rec_date
>=
datetime
.
strptime
(
l
.
start_date
,
'
%
Y-
%
m-
%
d'
)
and
rec_date
<=
datetime
.
strptime
(
l
.
stop_date
,
'
%
Y-
%
m-
%
d'
)):
answer
=
True
#_logger.debug("Partner will be still exempted")
return
answer
@api.model
@api.model
def
ng_create_shifts_from_template
(
self
,
instance
=
None
,
after
=
False
,
before
=
False
):
def
ng_create_shifts_from_template
(
self
,
instance
=
None
,
after
=
False
,
before
=
False
):
conf
=
self
.
env
[
'ir.config_parameter'
]
conf
=
self
.
env
[
'ir.config_parameter'
]
...
@@ -87,6 +102,8 @@ class ShiftTemplate(models.Model):
...
@@ -87,6 +102,8 @@ class ShiftTemplate(models.Model):
for
attendee
in
ticket
.
registration_ids
:
for
attendee
in
ticket
.
registration_ids
:
state
,
strl_id
=
attendee
.
_get_state
(
rec_date
)
state
,
strl_id
=
attendee
.
_get_state
(
rec_date
)
if
state
:
if
state
:
# only register if attendee is not exempted when the event will occur
if
self
.
_will_member_be_still_exempted_at_date
(
attendee
.
partner_id
,
rec_date
)
is
False
:
vals
=
{
vals
=
{
'partner_id'
:
attendee
.
partner_id
.
id
,
'partner_id'
:
attendee
.
partner_id
.
id
,
'user_ids'
:
[(
6
,
0
,
template
.
user_ids
.
ids
)],
'user_ids'
:
[(
6
,
0
,
template
.
user_ids
.
ids
)],
...
@@ -115,9 +132,9 @@ class ShiftTemplate(models.Model):
...
@@ -115,9 +132,9 @@ class ShiftTemplate(models.Model):
(
'week_list'
,
'='
,
today
.
strftime
(
'
%
a'
)
.
upper
()[
0
:
2
]),
(
'week_list'
,
'='
,
today
.
strftime
(
'
%
a'
)
.
upper
()[
0
:
2
]),
(
'last_shift_date'
,
'<='
,
datetime
.
strftime
(
futur
,
"
%
Y-
%
m-
%
d"
))]
(
'last_shift_date'
,
'<='
,
datetime
.
strftime
(
futur
,
"
%
Y-
%
m-
%
d"
))]
templates
=
self
.
env
[
'shift.template'
]
.
search
(
filters
)
templates
=
self
.
env
[
'shift.template'
]
.
search
(
filters
)
#
templates = self.env['shift.template'].search([('id', '=', 60
)])
#
templates = self.env['shift.template'].search([('id', '=', 123
)])
for
template
in
templates
:
for
template
in
templates
:
#
_logger.info
("Shift template = %s", str(template))
#
_logger.debug
("Shift template = %s", str(template))
self
.
ng_create_shifts_from_template
(
instance
=
template
,
self
.
ng_create_shifts_from_template
(
instance
=
template
,
before
=
fields
.
Datetime
.
to_string
(
before
=
fields
.
Datetime
.
to_string
(
datetime
.
today
()
+
timedelta
(
days
=
shift_creation_days
)))
datetime
.
today
()
+
timedelta
(
days
=
shift_creation_days
)))
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