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
b8ea7bbc
Commit
b8ea7bbc
authored
Nov 25, 2021
by
François C.
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'evolution_bdm' into dev_cooperatic
parents
a5b7181d
0ebfe020
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
740 additions
and
2 deletions
+740
-2
fr.po
intercoop_addons/coop_membership/i18n/fr.po
+1
-1
fr.po
intercoop_addons/coop_shift/i18n/fr.po
+1
-1
README.rst
lacagette_addons/lacagette_membership/README.rst
+23
-0
__init__.py
lacagette_addons/lacagette_membership/__init__.py
+4
-0
__openerp__.py
lacagette_addons/lacagette_membership/__openerp__.py
+33
-0
ir_config_parameter_data.xml
...ns/lacagette_membership/data/ir_config_parameter_data.xml
+35
-0
ir_cron.xml
lacagette_addons/lacagette_membership/data/ir_cron.xml
+61
-0
fr.po
lacagette_addons/lacagette_membership/i18n/fr.po
+23
-0
__init__.py
lacagette_addons/lacagette_membership/models/__init__.py
+9
-0
member_state_change.py
...addons/lacagette_membership/models/member_state_change.py
+21
-0
res_partner.py
lacagette_addons/lacagette_membership/models/res_partner.py
+169
-0
shift_counter_event.py
...addons/lacagette_membership/models/shift_counter_event.py
+48
-0
shift_registration.py
..._addons/lacagette_membership/models/shift_registration.py
+33
-0
shift_shift.py
lacagette_addons/lacagette_membership/models/shift_shift.py
+28
-0
shift_template.py
...ette_addons/lacagette_membership/models/shift_template.py
+125
-0
shift_template_registration_line.py
...tte_membership/models/shift_template_registration_line.py
+36
-0
ir.model.access.csv
..._addons/lacagette_membership/security/ir.model.access.csv
+4
-0
backend.css
...te_addons/lacagette_membership/static/src/css/backend.css
+5
-0
backend.js
...ette_addons/lacagette_membership/static/src/js/backend.js
+50
-0
templates.xml
..._addons/lacagette_membership/static/src/xml/templates.xml
+14
-0
res_partner.xml
lacagette_addons/lacagette_membership/views/res_partner.xml
+17
-0
No files found.
intercoop_addons/coop_membership/i18n/fr.po
View file @
b8ea7bbc
...
@@ -660,7 +660,7 @@ msgstr "Remplacé"
...
@@ -660,7 +660,7 @@ msgstr "Remplacé"
#: code:addons/coop_membership/models/shift_shift.py:81
#: code:addons/coop_membership/models/shift_shift.py:81
#, python-format
#, python-format
msgid "Shift Cloture"
msgid "Shift Cloture"
msgstr "Clô
l
turer le service"
msgstr "Clôturer le service"
#. module: coop_membership
#. module: coop_membership
#: model:ir.ui.view,arch_db:coop_membership.view_shift_form_inherit
#: model:ir.ui.view,arch_db:coop_membership.view_shift_form_inherit
...
...
intercoop_addons/coop_shift/i18n/fr.po
View file @
b8ea7bbc
...
@@ -2297,7 +2297,7 @@ msgstr "Service"
...
@@ -2297,7 +2297,7 @@ msgstr "Service"
#: code:addons/coop_shift/model/shift_shift.py:434
#: code:addons/coop_shift/model/shift_shift.py:434
#, python-format
#, python-format
msgid "Shift Cloture"
msgid "Shift Cloture"
msgstr "Clô
l
turer le service"
msgstr "Clôturer le service"
#. module: coop_shift
#. module: coop_shift
#: model:ir.actions.act_window,name:coop_shift.action_res_partner_point_counter_view_ftop
#: model:ir.actions.act_window,name:coop_shift.action_res_partner_point_counter_view_ftop
...
...
lacagette_addons/lacagette_membership/README.rst
0 → 100644
View file @
b8ea7bbc
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3
=========================
La Cagette specific rules
=========================
All shift template are FTOP type.
Every cooperative members is subscribing a FTOP shift template.
Every 28 days (4 weeks), every shift template subscriber losts 1 point.
If a cooperative member is not present to a due shift, she or he losts 1 point and has 2 makeups to do.
Every cooperative member move its regular shift to an other day.
When the coop. member counter reaches -2 points, the cooperative status is set to 'Suspended'.
When the coop. member counter reaches -3 points, the cooperatice status is set to 'Unsubscribed'
lacagette_addons/lacagette_membership/__init__.py
0 → 100644
View file @
b8ea7bbc
# -*- coding: utf-8 -*-
from
.
import
models
\ No newline at end of file
lacagette_addons/lacagette_membership/__openerp__.py
0 → 100644
View file @
b8ea7bbc
# -*- coding: utf-8 -*-
{
'name'
:
"La Cagette - Membership"
,
'summary'
:
"""
Tuning membership rules"""
,
'description'
:
"""
Specific rules are beeing implemented
lacagette_membership.absence_status can be excused or absent
"""
,
'author'
:
"fracolo/cooperatic"
,
'website'
:
"https://lacagette-coop.fr"
,
#
'category'
:
'Uncategorized'
,
'version'
:
'0.0.6'
,
# any module necessary for this one to work correctly
'depends'
:
[
'base'
,
'coop_membership'
,
'coop_shift'
],
# always loaded
'data'
:
[
'security/ir.model.access.csv'
,
'data/ir_cron.xml'
,
'data/ir_config_parameter_data.xml'
,
'static/src/xml/templates.xml'
,
'views/res_partner.xml'
,
],
'installable'
:
True
,
}
lacagette_addons/lacagette_membership/data/ir_config_parameter_data.xml
0 → 100644
View file @
b8ea7bbc
<?xml version="1.0"?>
<odoo
noupdate=
"1"
>
<record
id=
"points_limit_to_get_suspended"
model=
"ir.config_parameter"
>
<field
name=
"key"
>
lacagette_membership.points_limit_to_get_suspended
</field>
<field
name=
"value"
>
-2
</field>
</record>
<record
id=
"points_limit_to_get_unsubscribed"
model=
"ir.config_parameter"
>
<field
name=
"key"
>
lacagette_membership.points_limit_to_get_unsubscribed
</field>
<field
name=
"value"
>
-3
</field>
</record>
<record
id=
"makeups_to_do_after_unsubscribed"
model=
"ir.config_parameter"
>
<field
name=
"key"
>
lacagette_membership.makeups_to_do_after_unsubscribed
</field>
<field
name=
"value"
>
2
</field>
</record>
<record
id=
"absence_status"
model=
"ir.config_parameter"
>
<field
name=
"key"
>
lacagette_membership.absence_status
</field>
<field
name=
"value"
>
excused
</field>
</record>
<record
id=
"extension_duration"
model=
"ir.config_parameter"
>
<field
name=
"key"
>
lacagette_membership.extension_duration
</field>
<field
name=
"value"
>
6 months
</field>
</record>
<record
id=
"max_successive_extensions"
model=
"ir.config_parameter"
>
<field
name=
"key"
>
lacagette_membership.max_successive_extensions
</field>
<field
name=
"value"
>
1
</field>
</record>
<record
id=
"committees_shift_id"
model=
"ir.config_parameter"
>
<field
name=
"key"
>
lacagette_membership.committees_shift_id
</field>
<field
name=
"value"
>
0
</field>
</record>
<record
id=
"shift_creation_days"
model=
"ir.config_parameter"
>
<field
name=
"key"
>
lacagette_membership.shift_creation_days
</field>
<field
name=
"value"
>
180
</field>
</record>
</odoo>
lacagette_addons/lacagette_membership/data/ir_cron.xml
0 → 100644
View file @
b8ea7bbc
<?xml version="1.0"?>
<!--
Copyright (C) 2021 - Today Cooperatic
Author : fracolo
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo
noupdate=
"1"
>
<record
forcecreate=
"True"
id=
"cron_close_unnecessary_extensions"
model=
"ir.cron"
>
<field
name=
"name"
>
Close unnecessary Extensions
</field>
<field
name=
"user_id"
ref=
"base.user_root"
/>
<field
name=
"interval_number"
>
1
</field>
<field
name=
"interval_type"
>
days
</field>
<field
name=
"numbercall"
>
-1
</field>
<field
name=
"doall"
eval=
"True"
/>
<field
name=
"model"
eval=
"'res.partner'"
/>
<field
name=
"function"
eval=
"'run_close_unnecessary_opened_extensions'"
/>
<field
name=
"args"
eval=
"'()'"
/>
<field
name=
"active"
eval=
"False"
/>
<field
name=
"priority"
>
2
</field>
</record>
<record
forcecreate=
"True"
id=
"cron_process_target_status"
model=
"ir.cron"
>
<field
name=
"name"
>
Process coop target status
</field>
<field
name=
"user_id"
ref=
"base.user_root"
/>
<field
name=
"interval_number"
>
5
</field>
<field
name=
"interval_type"
>
minutes
</field>
<field
name=
"numbercall"
>
-1
</field>
<field
name=
"doall"
eval=
"True"
/>
<field
name=
"model"
eval=
"'res.partner'"
/>
<field
name=
"function"
eval=
"'run_process_target_status'"
/>
<field
name=
"args"
eval=
"'()'"
/>
<field
name=
"active"
eval=
"False"
/>
<field
name=
"priority"
>
1
</field>
</record>
<record
forcecreate=
"True"
id=
"cron_close_ftop_shifts"
model=
"ir.cron"
>
<field
name=
"name"
>
Daily close FTOP shifts
</field>
<field
name=
"user_id"
ref=
"base.user_root"
/>
<field
name=
"interval_number"
>
1
</field>
<field
name=
"interval_type"
>
days
</field>
<field
name=
"numbercall"
>
-1
</field>
<field
name=
"doall"
eval=
"True"
/>
<field
name=
"model"
eval=
"'shift.shift'"
/>
<field
name=
"function"
eval=
"'run_close_today_ftop_shifts'"
/>
<field
name=
"args"
eval=
"'()'"
/>
<field
name=
"active"
eval=
"False"
/>
<field
name=
"priority"
>
1
</field>
</record>
<record
forcecreate=
"True"
id=
"cron_shifts_generation"
model=
"ir.cron"
>
<field
name=
"name"
>
Generate shifts (La Cagette version)
</field>
<field
name=
"user_id"
ref=
"base.user_root"
/>
<field
name=
"interval_number"
>
1
</field>
<field
name=
"interval_type"
>
days
</field>
<field
name=
"numbercall"
>
-1
</field>
<field
name=
"doall"
eval=
"False"
/>
<field
name=
"model"
eval=
"'lacagette.shift.template'"
/>
<field
name=
"function"
eval=
"'run_shift_creation'"
/>
<field
name=
"args"
eval=
"'()'"
/>
<field
name=
"active"
eval=
"False"
/>
<field
name=
"priority"
>
1
</field>
</record>
</odoo>
\ No newline at end of file
lacagette_addons/lacagette_membership/i18n/fr.po
0 → 100644
View file @
b8ea7bbc
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * lacagette_membership
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo 9.0\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: lacagette_membership
#: selection:res.partner,cooperative_state:0
msgid "Gone"
msgstr "Parti.e"
#. module: lacagette_membership
#: selection:res.partner,cooperative_state:0
msgid "Associated"
msgstr "En binôme"
\ No newline at end of file
lacagette_addons/lacagette_membership/models/__init__.py
0 → 100644
View file @
b8ea7bbc
# -*- coding: utf-8 -*-
from
.
import
res_partner
from
.
import
shift_registration
from
.
import
shift_counter_event
from
.
import
shift_shift
from
.
import
member_state_change
from
.
import
shift_template
from
.
import
shift_template_registration_line
lacagette_addons/lacagette_membership/models/member_state_change.py
0 → 100644
View file @
b8ea7bbc
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html
from
openerp
import
fields
,
models
class
MembersStateChange
(
models
.
Model
):
_name
=
"member.state.change"
member_id
=
fields
.
Many2one
(
comodel_name
=
'res.partner'
,
ondelete
=
'cascade'
,
index
=
True
)
state
=
fields
.
Char
(
'state'
,
size
=
15
)
lacagette_addons/lacagette_membership/models/res_partner.py
0 → 100644
View file @
b8ea7bbc
# -*- coding: utf-8 -*-
from
openerp
import
_
,
api
,
models
,
fields
import
datetime
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
TARGET_STATUS_SELECTION
=
[
(
'unsubscribed'
,
'Unsubscribed'
),
(
'suspended'
,
'Suspended'
)
]
EXTRA_COOPERATIVE_STATE_SELECTION
=
[
(
'not_concerned'
,
'Not Concerned'
),
(
'unsubscribed'
,
'Unsubscribed'
),
(
'exempted'
,
'Exempted'
),
(
'vacation'
,
'On Vacation'
),
(
'up_to_date'
,
'Up to date'
),
(
'alert'
,
'Alert'
),
(
'suspended'
,
'Suspended'
),
(
'delay'
,
'Delay'
),
(
'blocked'
,
'Blocked'
),
(
'unpayed'
,
'Unpayed'
),
(
'gone'
,
'Gone'
),
(
'associated'
,
'Associated'
)
]
class
ResPartner
(
models
.
Model
):
_inherit
=
'res.partner'
# Columns Section
makeups_to_do
=
fields
.
Integer
(
"Number of make-ups to done"
,
default
=
0
)
target_status
=
fields
.
Selection
(
selection
=
TARGET_STATUS_SELECTION
,
default
=
''
)
cooperative_state
=
fields
.
Selection
(
selection
=
EXTRA_COOPERATIVE_STATE_SELECTION
,
default
=
'not_concerned'
)
@api.model
def
run_process_target_status
(
self
):
"""Method called by cron task"""
# final_ftop_point, target_status
conf
=
self
.
env
[
'ir.config_parameter'
]
makeups_todo_after_unsubscribed
=
conf
.
get_param
(
"lacagette_membership.makeups_to_do_after_unsubscribed"
)
result
=
'done'
for
p
in
self
.
env
[
'res.partner'
]
\
.
search
([(
'target_status'
,
'!='
,
""
)]):
try
:
new_values
=
{
'target_status'
:
""
,
"date_alert_stop"
:
False
}
final_points
=
p
.
final_ftop_point
if
p
.
shift_type
==
"ftop"
else
p
.
final_standard_point
if
final_points
<
0
:
new_values
[
'cooperative_state'
]
=
p
.
target_status
if
new_values
[
'cooperative_state'
]
==
"unsubscribed"
:
new_values
[
'makeups_to_do'
]
=
makeups_todo_after_unsubscribed
new_values
[
'final_'
+
p
.
shift_type
+
'_point'
]
=
-
2
if
p
.
shift_type
==
'standard'
:
new_values
[
'display_std_points'
]
=
-
2
else
:
new_values
[
'display_ftop_points'
]
=
-
2
"""
unlink model: "shift.template.registration"
to delete all future shifts linked to this coop.
"""
now
=
datetime
.
datetime
.
now
()
.
isoformat
()
for
streg
in
self
.
env
[
'shift.template.registration'
]
\
.
search
([(
'partner_id'
,
'='
,
p
.
id
)]):
streg
.
unlink
()
for
sreg
in
self
.
env
[
'shift.registration'
]
\
.
search
([(
'partner_id'
,
'='
,
p
.
id
),
(
'date_begin'
,
'>'
,
now
)]):
sreg
.
unlink
()
# Close extensions
for
ext
in
self
.
env
[
'shift.extension'
]
\
.
search
([(
'partner_id'
,
'='
,
p
.
id
),
(
'date_start'
,
'<='
,
now
),
(
'date_stop'
,
'>='
,
now
)]):
ext
.
update
({
'date_stop'
:
now
})
mail_template
=
self
.
env
.
ref
(
'coop_membership.unsubscribe_email'
)
if
mail_template
:
mail_template
.
send_mail
(
p
.
id
)
p
.
update
(
new_values
)
except
Exception
as
e
:
_logger
.
error
(
"run_process_target_status :
%
s"
,
str
(
e
))
result
=
'error'
return
result
#@api.onchange('cooperativestate') : could be used only if it is called from client
@api.model
def
run_close_unnecessary_opened_extensions
(
self
):
"""Method called by cron task"""
sql
=
"""
SELECT s.id
FROM shift_extension as s
WHERE s.date_stop > now()
AND partner_id IN (SELECT id FROM res_partner WHERE cooperative_state in ('up_to_date', 'unsubscribed'))
"""
self
.
env
.
cr
.
execute
(
sql
)
extension_ids
=
self
.
env
.
cr
.
fetchall
()
if
len
(
extension_ids
)
>
0
:
extension_model
=
self
.
env
[
'shift.extension'
]
today
=
datetime
.
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d"
)
for
ext
in
extension_model
.
search
([(
'id'
,
'in'
,
extension_ids
)]):
ext
.
update
({
'date_stop'
:
today
})
@api.multi
def
can_have_extension
(
self
):
"""Return if the member can ask for an extension"""
answer
=
True
conf
=
self
.
env
[
'ir.config_parameter'
]
max_nb
=
int
(
conf
.
get_param
(
"lacagette_membership.max_successive_extensions"
))
if
max_nb
==
1
:
args
=
[(
'member_id'
,
'='
,
self
.
id
)]
states
=
self
.
env
[
'member.state.change'
]
\
.
search
(
args
,
order
=
'write_date DESC'
,
limit
=
2
)
"""
member.state.change may have no record for the current member
"""
if
len
(
states
)
>
0
:
if
(
len
(
states
)
==
1
and
states
[
0
][
'state'
]
==
'delay'
or
len
(
states
)
==
2
and
states
[
1
][
'state'
]
==
'delay'
):
answer
=
False
else
:
# need to load data
member
=
self
.
env
[
'res.partner'
]
.
search
([(
'id'
,
'='
,
self
.
id
)])[
0
]
# should exist an other way to do it , but haven't found it
if
member
.
cooperative_state
!=
"up_to_date"
:
answer
=
False
else
:
# TODO : Must have a look to previous extensions
pass
return
answer
def
set_special_state
(
self
,
cr
,
uid
,
partner
,
context
=
None
):
return
self
.
write
(
cr
,
uid
,
[
partner
[
'id'
]],
{
'cooperative_state'
:
partner
[
'state'
]}
,
context
=
context
)
def
_write_state_change
(
self
,
state
):
data
=
{
'member_id'
:
self
.
id
,
'state'
:
state
}
self
.
env
[
'member.state.change'
]
.
create
(
data
)
@api.multi
def
update
(
self
,
vals
):
_logger
.
info
(
"valeurs reçues pour update partner =
%
s"
,
str
(
vals
))
state_to_record
=
""
if
'cooperative_state'
in
vals
:
state_to_record
=
vals
[
'cooperative_state'
]
elif
'current_cooperative_state'
in
vals
:
state_to_record
=
vals
[
'current_cooperative_state'
]
del
vals
[
'current_cooperative_state'
]
if
len
(
state_to_record
)
>
0
:
self
.
_write_state_change
(
state_to_record
)
return
super
(
ResPartner
,
self
)
.
update
(
vals
)
@api.multi
def
write
(
self
,
vals
):
_logger
.
info
(
"valeurs reçues pour write partner =
%
s"
,
str
(
vals
))
if
'cooperative_state'
in
vals
:
self
.
_write_state_change
(
vals
[
'cooperative_state'
])
return
super
(
ResPartner
,
self
)
.
write
(
vals
)
lacagette_addons/lacagette_membership/models/shift_counter_event.py
0 → 100644
View file @
b8ea7bbc
# -*- coding: utf-8 -*-
from
openerp
import
_
,
api
,
models
,
fields
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
class
ShiftCounterEvent
(
models
.
Model
):
_inherit
=
'shift.counter.event'
def
_update_partner_target_status
(
self
,
vals
):
"""actions if point_qty is negative"""
conf
=
self
.
env
[
'ir.config_parameter'
]
suspension_limit
=
int
(
conf
.
get_param
(
"lacagette_membership.points_limit_to_get_suspended"
))
unsubscribe_limit
=
int
(
conf
.
get_param
(
"lacagette_membership.points_limit_to_get_unsubscribed"
))
if
vals
[
'point_qty'
]
<
0
:
res_partner
=
self
.
env
[
'res.partner'
]
.
search
([(
'id'
,
'='
,
vals
[
'partner_id'
])])
if
res_partner
:
p
=
res_partner
[
0
]
points_before_removing_points
=
p
.
final_ftop_point
if
p
.
shift_type
==
"ftop"
else
p
.
final_standard_point
points_after_removal
=
points_before_removing_points
+
vals
[
'point_qty'
]
_logger
.
info
(
"points_after_removal =
%
s, current_state =
%
s"
,
str
(
points_after_removal
),
p
.
cooperative_state
)
if
points_after_removal
<=
suspension_limit
or
points_after_removal
<=
unsubscribe_limit
:
target_status
=
None
if
(
points_after_removal
<=
suspension_limit
and
p
.
cooperative_state
!=
'delay'
):
target_status
=
'suspended'
if
points_after_removal
<=
unsubscribe_limit
:
target_status
=
'unsubscribed'
if
target_status
is
not
None
:
p
.
update
({
'target_status'
:
target_status
,
'current_cooperative_state'
:
p
.
cooperative_state
})
@api.model
def
write
(
self
,
vals
):
res
=
super
(
ShiftCounterEvent
,
self
)
.
write
(
vals
)
_logger
.
info
(
"Vals reçues =
%
s"
,
str
(
vals
))
self
.
_update_partner_target_status
(
vals
)
return
res
@api.model
def
create
(
self
,
vals
):
self
.
_update_partner_target_status
(
vals
)
_logger
.
info
(
"Vals reçues creation =
%
s"
,
str
(
vals
))
return
super
(
ShiftCounterEvent
,
self
)
.
create
(
vals
)
lacagette_addons/lacagette_membership/models/shift_registration.py
0 → 100644
View file @
b8ea7bbc
# -*- coding: utf-8 -*-
from
openerp
import
_
,
api
,
models
,
fields
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
class
ShiftRegistration
(
models
.
Model
):
_inherit
=
'shift.registration'
is_late
=
fields
.
Boolean
(
"Was the registration validated within grace period ?"
,
default
=
False
)
is_makeup
=
fields
.
Boolean
(
"Is this registration a consequence of a makeup to do"
,
default
=
False
)
@api.multi
def
write
(
self
,
vals
):
conf
=
self
.
env
[
'ir.config_parameter'
]
absence_status
=
conf
.
get_param
(
"lacagette_membership.absence_status"
)
if
'state'
in
vals
and
vals
[
'state'
]
==
absence_status
:
if
self
.
ids
:
# it is the case when called from "absence cron job" run in external third-party
to_add
=
2
if
absence_status
==
'absent'
else
1
for
s
in
self
.
env
[
'shift.registration'
]
\
.
search
([(
'id'
,
'in'
,
self
.
ids
)]):
new_makeups_to_do
=
s
.
partner_id
.
makeups_to_do
+
to_add
s
.
partner_id
.
update
({
'makeups_to_do'
:
new_makeups_to_do
})
return
super
(
ShiftRegistration
,
self
)
.
write
(
vals
)
\ No newline at end of file
lacagette_addons/lacagette_membership/models/shift_shift.py
0 → 100644
View file @
b8ea7bbc
# -*- coding: utf-8 -*-
from
openerp
import
_
,
api
,
models
,
fields
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
class
ShiftShift
(
models
.
Model
):
_inherit
=
'shift.shift'
@api.model
def
run_close_today_ftop_shifts
(
self
):
"""Method called by cron task"""
sql
=
"""
SELECT id
FROM shift_shift
WHERE TO_CHAR(date_begin, 'YYYY-MM-DD') = TO_CHAR(now(), 'YYYY-MM-DD')
AND active = true AND state = 'confirm'
"""
self
.
env
.
cr
.
execute
(
sql
)
shift_ids
=
self
.
env
.
cr
.
fetchall
()
if
len
(
shift_ids
)
>
0
:
for
s
in
self
.
env
[
'shift.shift'
]
.
search
([(
'id'
,
'in'
,
shift_ids
)]):
s
.
button_makeupok
()
s
.
button_done
()
# _logger.info('Traité avec action makeupok et done sur shift ' + str(s.id))
\ No newline at end of file
lacagette_addons/lacagette_membership/models/shift_template.py
0 → 100644
View file @
b8ea7bbc
# -*- coding: utf-8 -*-
from
openerp
import
_
,
api
,
models
,
fields
from
datetime
import
datetime
,
timedelta
from
dateutil.relativedelta
import
relativedelta
import
locale
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
class
ShiftTemplate
(
models
.
Model
):
_name
=
"lacagette.shift.template"
_inherit
=
'shift.template'
@api.model
def
ng_create_shifts_from_template
(
self
,
instance
=
None
,
after
=
False
,
before
=
False
):
conf
=
self
.
env
[
'ir.config_parameter'
]
shift_creation_days
=
int
(
conf
.
get_param
(
"lacagette_membership.shift_creation_days"
))
if
not
before
:
before
=
fields
.
Datetime
.
to_string
(
datetime
.
today
()
+
timedelta
(
days
=
shift_creation_days
))
for
template
in
instance
:
if
len
(
str
(
template
.
rrule
)
.
strip
())
==
0
:
continue
# It's not a recurring template
after
=
template
.
last_shift_date
rec_dates
=
template
.
get_recurrent_dates
(
after
=
after
,
before
=
before
)
for
rec_date
in
rec_dates
:
start_date_object_tz
=
datetime
.
strptime
(
template
.
start_datetime_tz
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
date_begin
=
datetime
.
strftime
(
rec_date
+
timedelta
(
hours
=
(
start_date_object_tz
.
hour
))
+
timedelta
(
minutes
=
(
start_date_object_tz
.
minute
)),
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
if
date_begin
.
split
(
" "
)[
0
]
<=
template
.
last_shift_date
:
continue
end_date_object_tz
=
datetime
.
strptime
(
template
.
end_datetime_tz
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
diff_day
=
end_date_object_tz
.
day
-
start_date_object_tz
.
day
diff_month
=
end_date_object_tz
.
month
-
\
start_date_object_tz
.
month
diff_year
=
end_date_object_tz
.
year
-
start_date_object_tz
.
year
date_end
=
datetime
.
strftime
(
rec_date
+
timedelta
(
hours
=
(
end_date_object_tz
.
hour
))
+
timedelta
(
minutes
=
(
end_date_object_tz
.
minute
))
+
relativedelta
(
days
=
diff_day
)
+
relativedelta
(
months
=
diff_month
)
+
relativedelta
(
years
=
diff_year
),
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
rec_date
=
datetime
.
strftime
(
rec_date
,
"
%
Y-
%
m-
%
d"
)
vals
=
{
'shift_template_id'
:
template
.
id
,
'name'
:
template
.
name
,
'user_ids'
:
[(
6
,
0
,
template
.
user_ids
.
ids
)],
'company_id'
:
template
.
company_id
.
id
,
'seats_max'
:
template
.
seats_max
,
'seats_availability'
:
template
.
seats_availability
,
'seats_min'
:
template
.
seats_min
,
'date_begin_tz'
:
date_begin
,
'date_end_tz'
:
date_end
,
'state'
:
'draft'
,
'reply_to'
:
template
.
reply_to
,
'address_id'
:
template
.
address_id
.
id
,
'description'
:
template
.
description
,
'shift_type_id'
:
template
.
shift_type_id
.
id
,
'week_number'
:
template
.
week_number
,
'week_list'
:
template
.
week_list
,
'shift_ticket_ids'
:
None
,
}
shift_id
=
self
.
env
[
'shift.shift'
]
.
create
(
vals
)
for
ticket
in
template
.
shift_ticket_ids
:
vals
=
{
'name'
:
ticket
.
name
,
'shift_id'
:
shift_id
.
id
,
'product_id'
:
ticket
.
product_id
.
id
,
'price'
:
ticket
.
price
,
'deadline'
:
ticket
.
deadline
,
'seats_availability'
:
ticket
.
seats_availability
,
'seats_max'
:
ticket
.
seats_max
,
}
if
ticket
.
product_id
.
shift_type_id
.
is_ftop
:
vals
[
'seats_availability'
]
=
'limited'
vals
[
'seats_max'
]
=
0
ticket_id
=
self
.
env
[
'shift.ticket'
]
.
create
(
vals
)
for
attendee
in
ticket
.
registration_ids
:
state
,
strl_id
=
attendee
.
_get_state
(
rec_date
)
if
state
:
vals
=
{
'partner_id'
:
attendee
.
partner_id
.
id
,
'user_ids'
:
[(
6
,
0
,
template
.
user_ids
.
ids
)],
'state'
:
state
,
'email'
:
attendee
.
email
,
'phone'
:
attendee
.
phone
,
'name'
:
attendee
.
name
,
'shift_id'
:
shift_id
.
id
,
'shift_ticket_id'
:
ticket_id
.
id
,
'tmpl_reg_line_id'
:
strl_id
,
'template_created'
:
True
,
}
self
.
env
[
'shift.registration'
]
.
with_context
(
from_shift_template
=
True
)
.
create
(
vals
)
@api.model
def
run_shift_creation
(
self
):
# This method is called by the cron task
locale
.
setlocale
(
locale
.
LC_TIME
,
'en_US.UTF-8'
)
conf
=
self
.
env
[
'ir.config_parameter'
]
shift_creation_days
=
int
(
conf
.
get_param
(
"lacagette_membership.shift_creation_days"
))
today
=
datetime
.
today
()
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
:
# _logger.info("Shift template = %s", str(template))
self
.
ng_create_shifts_from_template
(
instance
=
template
,
before
=
fields
.
Datetime
.
to_string
(
datetime
.
today
()
+
timedelta
(
days
=
shift_creation_days
)))
\ No newline at end of file
lacagette_addons/lacagette_membership/models/shift_template_registration_line.py
0 → 100644
View file @
b8ea7bbc
# -*- coding: utf-8 -*-
from
openerp
import
api
,
models
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
class
ShiftTemplateRegistrationLine
(
models
.
Model
):
_inherit
=
'shift.template.registration.line'
@api.model
def
create
(
self
,
vals
):
super_res
=
super
(
ShiftTemplateRegistrationLine
,
self
.
with_context
(
dict
(
self
.
env
.
context
,
**
{
'creation_in_progress'
:
True
})))
.
create
(
vals
)
#_logger.info("valeurs reçues pour create shift.template.registration.line = %s", str(vals))
if
'partner_id'
in
vals
and
'shift_ticket_id'
in
vals
:
conf
=
self
.
env
[
'ir.config_parameter'
]
suspension_limit
=
int
(
conf
.
get_param
(
"lacagette_membership.points_limit_to_get_suspended"
))
unsubscribe_limit
=
int
(
conf
.
get_param
(
"lacagette_membership.points_limit_to_get_unsubscribed"
))
member
=
self
.
env
[
'res.partner'
]
.
search
([(
'id'
,
'='
,
vals
[
'partner_id'
])])
shift_ticket
=
self
.
env
[
'shift.ticket'
]
.
search
([(
'id'
,
'='
,
vals
[
'shift_ticket_id'
])])
if
member
and
shift_ticket
:
member
=
member
[
0
]
shift_ticket
=
shift_ticket
[
0
]
if
shift_ticket
.
name
==
"ABCD"
:
points
=
member
.
final_standard_point
else
:
points
=
member
.
final_ftop_point
if
points
<=
suspension_limit
or
points
<=
unsubscribe_limit
:
coop_state
=
'suspended'
if
points
<=
unsubscribe_limit
:
coop_state
=
'unsubscribed'
member
.
update
({
'cooperative_state'
:
coop_state
})
_logger
.
info
(
"new cooperative_state =
%
s for
%
s"
,
coop_state
,
str
(
member
.
id
))
return
super_res
lacagette_addons/lacagette_membership/security/ir.model.access.csv
0 → 100644
View file @
b8ea7bbc
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
,,,,,,,
,,,,,,,
access_model_member_state_change,access_model_member_state_change,model_member_state_change,coop_shift.group_shift_user,1,1,1,1
lacagette_addons/lacagette_membership/static/src/css/backend.css
0 → 100644
View file @
b8ea7bbc
#coop_state_selection
{
font-size
:
medium
;
height
:
26px
;
}
\ No newline at end of file
lacagette_addons/lacagette_membership/static/src/js/backend.js
0 → 100644
View file @
b8ea7bbc
odoo
.
define
(
'lacagette_membership.backend'
,
function
(
require
){
"use strict"
;
var
core
=
require
(
'web.core'
);
var
FormView
=
require
(
'web.FormView'
);
var
Model
=
require
(
'web.DataModel'
);
var
framework
=
require
(
'web.framework'
);
var
_t
=
core
.
_t
;
var
partner_id
=
null
;
var
last_call
=
0
;
FormView
.
include
({
load_record
:
function
()
{
var
self
=
this
;
return
this
.
_super
.
apply
(
this
,
arguments
)
.
then
(
function
()
{
partner_id
=
self
.
get_fields_values
().
id
;
});
}
});
$
(
document
).
on
(
'change'
,
'#coop_state_selection'
,
function
(){
var
d
=
new
Date
()
var
elapsed_since_last_call
=
d
.
getTime
()
-
last_call
let
new_state
=
$
(
this
).
val
()
if
(
elapsed_since_last_call
>
5000
)
{
last_call
=
d
.
getTime
()
let
fields
=
{
id
:
partner_id
,
state
:
new_state
}
framework
.
blockUI
();
new
Model
(
'res.partner'
).
call
(
'set_special_state'
,[
fields
]).
then
(
function
(
rData
){
window
.
location
.
reload
()
},
function
(
err
,
event
){
event
.
preventDefault
();
var
error_body
=
_t
(
'Your Internet connection is probably down.'
);
if
(
err
.
data
)
{
var
except
=
err
.
data
;
error_body
=
except
.
arguments
&&
except
.
arguments
[
0
]
||
except
.
message
||
error_body
;
}
alert
(
error_body
)
});
}
});
});
lacagette_addons/lacagette_membership/static/src/xml/templates.xml
0 → 100644
View file @
b8ea7bbc
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template
id=
"assets"
name=
"lacagette_membership assets"
inherit_id=
"web.assets_backend"
>
<xpath
expr=
"."
position=
"inside"
>
<link
rel=
"stylesheet"
href=
"/lacagette_membership/static/src/css/backend.css"
/>
<script
type=
"text/javascript"
src=
"/lacagette_membership/static/src/js/backend.js"
></script>
</xpath>
</template>
</data>
</openerp>
\ No newline at end of file
lacagette_addons/lacagette_membership/views/res_partner.xml
0 → 100644
View file @
b8ea7bbc
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record
id=
"view_partner_form"
model=
"ir.ui.view"
>
<field
name=
"model"
>
res.partner
</field>
<field
name=
"inherit_id"
ref=
"coop_membership.view_partner_form"
/>
<field
name=
"arch"
type=
"xml"
>
<field
name=
"name"
position=
"after"
>
<select
id=
"coop_state_selection"
>
<option
value=
""
>
--Statuts spéciaux--
</option>
<option
value=
"gone"
>
Parti.e
</option>
<option
value=
"associated"
>
En binôme
</option>
</select>
</field>
</field>
</record>
</odoo>
\ 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