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
562b349f
Commit
562b349f
authored
Apr 02, 2021
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add LaCagette shifts to custom shifts data thru API calls
parent
28ab4fb6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
0 deletions
+64
-0
__init__.py
lacagette_addons/lacagette_shifts/__init__.py
+4
-0
__openerp__.py
lacagette_addons/lacagette_shifts/__openerp__.py
+28
-0
__init__.py
lacagette_addons/lacagette_shifts/models/__init__.py
+2
-0
lacagette_shifts.py
lacagette_addons/lacagette_shifts/models/lacagette_shifts.py
+30
-0
No files found.
lacagette_addons/lacagette_shifts/__init__.py
0 → 100644
View file @
562b349f
# -*- coding: utf-8 -*-
from
.
import
models
lacagette_addons/lacagette_shifts/__openerp__.py
0 → 100644
View file @
562b349f
# -*- coding: utf-8 -*-
{
'name'
:
"La Cagette - Shifts"
,
'summary'
:
"""
Specific actions related to Shifts"""
,
'description'
:
"""
Actions currently implemented:
- Retrieve all shifts, counting for each of them only active registrations
"""
,
'author'
:
"damien.moulard"
,
'website'
:
"https://lacagette-coop.fr"
,
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
# for the full list
'category'
:
'Uncategorized'
,
'version'
:
'0.0.1'
,
# any module necessary for this one to work correctly
'depends'
:
[
'base'
],
# always loaded
'data'
:
[
],
'installable'
:
True
,
}
lacagette_addons/lacagette_shifts/models/__init__.py
0 → 100644
View file @
562b349f
# -*- coding: utf-8 -*-
from
.
import
lacagette_shifts
lacagette_addons/lacagette_shifts/models/lacagette_shifts.py
0 → 100644
View file @
562b349f
# -*- coding: utf-8 -*-
from
openerp
import
_
,
api
,
models
,
fields
class
LaCagetteShifts
(
models
.
Model
):
_name
=
"lacagette_shifts"
@api.model
def
get_active_shifts
(
self
):
""" Get shifts, counting active registrations to each of them"""
# Get registrations which:
# - belong to an active shift
# - are in an accepted state
# - begin before now
# - don't have an end date OR end after now
# Group by shift and count
sql
=
"""SELECT str.shift_template_id, COUNT(str.shift_template_id) AS seats_active_registration
FROM shift_template st
LEFT JOIN shift_template_registration str ON str.shift_template_id = st.id
LEFT JOIN shift_template_registration_line strl ON strl.registration_id = str.id
WHERE active IS TRUE
AND str.state IN ('draft', 'open', 'done', 'replacing')
AND strl.date_begin < NOW()
AND (strl.date_end IS NULL OR strl.date_end >= NOW())
GROUP BY str.shift_template_id"""
self
.
env
.
cr
.
execute
(
sql
)
res
=
self
.
env
.
cr
.
dictfetchall
()
return
(
res
)
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