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
b56f67f4
Commit
b56f67f4
authored
Nov 16, 2021
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shifts generation modifications (requests and cron)
parent
5bf8985b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
ir_cron.xml
lacagette_addons/lacagette_membership/data/ir_cron.xml
+1
-1
shift_template.py
...ette_addons/lacagette_membership/models/shift_template.py
+12
-2
No files found.
lacagette_addons/lacagette_membership/data/ir_cron.xml
View file @
b56f67f4
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
<field
name=
"name"
>
Generate shifts (La Cagette version)
</field>
<field
name=
"name"
>
Generate shifts (La Cagette version)
</field>
<field
name=
"user_id"
ref=
"base.user_root"
/>
<field
name=
"user_id"
ref=
"base.user_root"
/>
<field
name=
"interval_number"
>
1
</field>
<field
name=
"interval_number"
>
1
</field>
<field
name=
"interval_type"
>
week
s
</field>
<field
name=
"interval_type"
>
day
s
</field>
<field
name=
"numbercall"
>
-1
</field>
<field
name=
"numbercall"
>
-1
</field>
<field
name=
"doall"
eval=
"False"
/>
<field
name=
"doall"
eval=
"False"
/>
<field
name=
"model"
eval=
"'lacagette.shift.template'"
/>
<field
name=
"model"
eval=
"'lacagette.shift.template'"
/>
...
...
lacagette_addons/lacagette_membership/models/shift_template.py
View file @
b56f67f4
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
from
openerp
import
_
,
api
,
models
,
fields
from
openerp
import
_
,
api
,
models
,
fields
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
dateutil.relativedelta
import
relativedelta
from
dateutil.relativedelta
import
relativedelta
import
locale
import
logging
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
_logger
=
logging
.
getLogger
(
__name__
)
...
@@ -105,11 +106,19 @@ class ShiftTemplate(models.Model):
...
@@ -105,11 +106,19 @@ class ShiftTemplate(models.Model):
@api.model
@api.model
def
run_shift_creation
(
self
):
def
run_shift_creation
(
self
):
# This method is called by the cron task
# This method is called by the cron task
locale
.
setlocale
(
locale
.
LC_TIME
,
'en_US.UTF-8'
)
conf
=
self
.
env
[
'ir.config_parameter'
]
conf
=
self
.
env
[
'ir.config_parameter'
]
shift_creation_days
=
int
(
conf
.
get_param
(
"lacagette_membership.shift_creation_days"
))
shift_creation_days
=
int
(
conf
.
get_param
(
"lacagette_membership.shift_creation_days"
))
#templates = self.env['shift.template'].search([('recurrency', '=', True)])
today
=
datetime
.
today
()
templates
=
self
.
env
[
'shift.template'
]
.
search
([(
'id'
,
'='
,
60
)])
futur
=
today
+
timedelta
(
days
=
shift_creation_days
)
filters
=
[(
'recurrency'
,
'='
,
True
),
(
'week_list'
,
'='
,
today
.
strftime
(
'
%
a'
)
.
upper
()[
0
:
2
]),
(
'last_shift_date'
,
'<='
,
datetime
.
strftime
(
futur
,
"
%
Y-
%
m-
%
d"
))]
templates
=
self
.
env
[
'shift.template'
]
.
search
(
filters
)
# templates = self.env['shift.template'].search([('id', '=', 60)])
for
template
in
templates
:
for
template
in
templates
:
# _logger.info("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
)))
\ No newline at end of file
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