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
b9a6dc52
Commit
b9a6dc52
authored
3 years ago
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implements new La Cagette rules
parent
18714da9
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
121 additions
and
5 deletions
+121
-5
README.rst
lacagette_addons/lacagette_membership/README.rst
+23
-0
__openerp__.py
lacagette_addons/lacagette_membership/__openerp__.py
+4
-4
ir_config_parameter_data.xml
...ns/lacagette_membership/data/ir_config_parameter_data.xml
+7
-0
ir_cron.xml
lacagette_addons/lacagette_membership/data/ir_cron.xml
+14
-0
__init__.py
lacagette_addons/lacagette_membership/models/__init__.py
+1
-0
res_partner.py
lacagette_addons/lacagette_membership/models/res_partner.py
+27
-0
shift_counter_event.py
...addons/lacagette_membership/models/shift_counter_event.py
+40
-0
shift_registration.py
..._addons/lacagette_membership/models/shift_registration.py
+5
-1
No files found.
lacagette_addons/lacagette_membership/README.rst
0 → 100644
View file @
b9a6dc52
.. 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'
This diff is collapsed.
Click to expand it.
lacagette_addons/lacagette_membership/__openerp__.py
View file @
b9a6dc52
...
@@ -6,22 +6,22 @@
...
@@ -6,22 +6,22 @@
Tuning membership rules"""
,
Tuning membership rules"""
,
'description'
:
"""
'description'
:
"""
Specific rules are beeing implemented
"""
,
"""
,
'author'
:
"fracolo"
,
'author'
:
"fracolo
/cooperatic
"
,
'website'
:
"https://lacagette-coop.fr"
,
'website'
:
"https://lacagette-coop.fr"
,
#
#
'category'
:
'Uncategorized'
,
'category'
:
'Uncategorized'
,
'version'
:
'0.0.
3
'
,
'version'
:
'0.0.
4
'
,
# any module necessary for this one to work correctly
# any module necessary for this one to work correctly
'depends'
:
[
'base'
,
'coop_shift'
],
'depends'
:
[
'base'
,
'coop_shift'
],
# always loaded
# always loaded
'data'
:
[
'data'
:
[
'data/ir_cron.xml'
,
'data/ir_cron.xml'
,
#
'ir_config_parameter_data.xml'
'ir_config_parameter_data.xml'
],
],
'installable'
:
True
,
'installable'
:
True
,
}
}
This diff is collapsed.
Click to expand it.
lacagette_addons/lacagette_membership/data/ir_config_parameter_data.xml
0 → 100644
View file @
b9a6dc52
<?xml version="1.0"?>
<odoo
noupdate=
"0"
>
<record
id=
"makeups_to_do_if_missed_id"
model=
"ir.config_parameter"
>
<field
name=
"key"
>
lacagette_membership.makeups_to_do_on_shift_missed
</field>
<field
name=
"value"
>
2
</field>
</record>
</odoo>
This diff is collapsed.
Click to expand it.
lacagette_addons/lacagette_membership/data/ir_cron.xml
View file @
b9a6dc52
...
@@ -18,4 +18,17 @@
...
@@ -18,4 +18,17 @@
<field
name=
"active"
eval=
"False"
/>
<field
name=
"active"
eval=
"False"
/>
<field
name=
"priority"
>
2
</field>
<field
name=
"priority"
>
2
</field>
</record>
</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"
>
1
</field>
<field
name=
"interval_type"
>
hours
</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>
</odoo>
</odoo>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lacagette_addons/lacagette_membership/models/__init__.py
View file @
b9a6dc52
...
@@ -2,3 +2,4 @@
...
@@ -2,3 +2,4 @@
from
.
import
res_partner
from
.
import
res_partner
from
.
import
shift_registration
from
.
import
shift_registration
from
.
import
shift_counter_event
This diff is collapsed.
Click to expand it.
lacagette_addons/lacagette_membership/models/res_partner.py
View file @
b9a6dc52
...
@@ -3,6 +3,11 @@
...
@@ -3,6 +3,11 @@
from
openerp
import
_
,
api
,
models
,
fields
from
openerp
import
_
,
api
,
models
,
fields
import
datetime
import
datetime
TARGET_STATUS_SELECTION
=
[
(
'unsubscribed'
,
'Unsubscribed'
),
(
'suspended'
,
'Suspended'
)
]
class
ResPartner
(
models
.
Model
):
class
ResPartner
(
models
.
Model
):
_inherit
=
'res.partner'
_inherit
=
'res.partner'
...
@@ -11,6 +16,28 @@ class ResPartner(models.Model):
...
@@ -11,6 +16,28 @@ class ResPartner(models.Model):
"Number of make-ups to done"
,
"Number of make-ups to done"
,
default
=
0
)
default
=
0
)
target_status
=
fields
.
Selection
(
selection
=
TARGET_STATUS_SELECTION
,
default
=
''
)
@api.model
def
run_process_target_status
(
self
):
"""Method called by cron task"""
# final_ftop_point, target_status
for
p
in
self
.
env
[
'res.partner'
]
\
.
search
([(
'target_status'
,
'!='
,
""
)]):
new_values
=
{
'target_status'
:
""
,
"date_alert_stop"
:
""
}
if
p
.
final_ftop_point
<
0
:
new_values
[
'cooperative_state'
]
=
p
.
target_status
if
new_values
[
'cooperative_state'
]
==
"unsubscribed"
:
"""
unlink model: "shift.template.registration"
to delete all future shifts linked to this coop.
"""
for
streg
in
self
.
env
[
'shift.template.registration'
]
\
.
search
([(
'partner_id'
,
'='
,
p
.
id
)]):
streg
.
unlink
()
p
.
update
(
new_values
)
#@api.onchange('cooperativestate') : could be used only if it is called from client
#@api.onchange('cooperativestate') : could be used only if it is called from client
@api.model
@api.model
...
...
This diff is collapsed.
Click to expand it.
lacagette_addons/lacagette_membership/models/shift_counter_event.py
0 → 100644
View file @
b9a6dc52
# -*- 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"""
if
vals
[
'point_qty'
]
<
0
:
res_partner
=
self
.
env
[
'res.partner'
]
.
search
([(
'id'
,
'='
,
vals
[
'partner_id'
])])
if
res_partner
:
points_before_removing_points
=
res_partner
[
0
]
.
final_ftop_point
points_after_removal
=
points_before_removing_points
+
vals
[
'point_qty'
]
_logger
.
info
(
"points_after_removal =
%
s"
,
str
(
points_after_removal
))
if
points_after_removal
<=
-
2
:
target_status
=
'suspended'
if
points_after_removal
<
-
2
:
target_status
=
'unsubscribed'
res_partner
[
0
]
.
update
({
'target_status'
:
target_status
})
@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
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lacagette_addons/lacagette_membership/models/shift_registration.py
View file @
b9a6dc52
...
@@ -22,8 +22,11 @@ class ShiftRegistration(models.Model):
...
@@ -22,8 +22,11 @@ class ShiftRegistration(models.Model):
res
=
super
(
ShiftRegistration
,
self
)
.
write
(
vals
)
res
=
super
(
ShiftRegistration
,
self
)
.
write
(
vals
)
if
'state'
in
vals
and
vals
[
'state'
]
==
'excused'
:
if
'state'
in
vals
and
vals
[
'state'
]
==
'excused'
:
if
self
.
ids
:
if
self
.
ids
:
# it is the case when called from "absence cron job" run in external third-party
conf
=
self
.
env
[
'ir.config_parameter'
]
to_add
=
conf
.
get_param
(
"lacagette_membership.makeups_to_do_on_shift_missed"
)
for
s
in
self
.
env
[
'shift.registration'
]
\
for
s
in
self
.
env
[
'shift.registration'
]
\
.
search
([(
'id'
,
'in'
,
self
.
ids
)]):
.
search
([(
'id'
,
'in'
,
self
.
ids
)]):
new_makeups_to_do
=
s
.
partner_id
.
makeups_to_do
+
1
new_makeups_to_do
=
s
.
partner_id
.
makeups_to_do
+
to_add
s
.
partner_id
.
update
({
'makeups_to_do'
:
new_makeups_to_do
})
s
.
partner_id
.
update
({
'makeups_to_do'
:
new_makeups_to_do
})
return
res
return
res
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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