Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
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
2
Merge Requests
2
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
third-party
Commits
6a0a6120
Commit
6a0a6120
authored
Jan 27, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update script to fix counters for other status than alert
parent
2242affb
Pipeline
#1729
passed with stage
in 2 minutes 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
4 deletions
+37
-4
fix_wrong_points_counter.py
outils/scripts/fix_wrong_points_counter.py
+37
-4
No files found.
outils/scripts/fix_wrong_points_counter.py
View file @
6a0a6120
...
@@ -14,11 +14,19 @@ def main():
...
@@ -14,11 +14,19 @@ def main():
"""For coops in alert state, reajust points counter so they get to 0 after adding their makeups to their actual calculated total"""
"""For coops in alert state, reajust points counter so they get to 0 after adding their makeups to their actual calculated total"""
api
=
OdooAPI
()
api
=
OdooAPI
()
cond
=
[[
'cooperative_state'
,
'='
,
'alert'
]]
cond
=
[
fields
=
[
'id'
,
'name'
,
'makeups_to_do'
]
'|'
,
'|'
,
'|'
,
[
'cooperative_state'
,
'='
,
'alert'
],
[
'cooperative_state'
,
'='
,
'unsubscribed'
],
[
'cooperative_state'
,
'='
,
'suspended'
],
[
'cooperative_state'
,
'='
,
'delay'
]
]
fields
=
[
'id'
,
'name'
,
'makeups_to_do'
,
'cooperative_state'
]
res
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
res
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
print
(
"Nb en alerte avant action : "
+
str
(
len
(
res
)))
cpt
=
0
for
p
in
res
:
for
p
in
res
:
# Get real points count
# Get real points count
...
@@ -42,13 +50,22 @@ def main():
...
@@ -42,13 +50,22 @@ def main():
final_theoric_pts
=
total_pts
+
p
[
'makeups_to_do'
]
+
len
(
res_shift_reg
)
final_theoric_pts
=
total_pts
+
p
[
'makeups_to_do'
]
+
len
(
res_shift_reg
)
if
final_theoric_pts
!=
0
:
if
final_theoric_pts
<
0
:
cpt
+=
1
print
(
p
[
"name"
])
print
(
p
[
"name"
])
print
(
'theoric total : '
+
str
(
final_theoric_pts
))
print
(
'theoric total : '
+
str
(
final_theoric_pts
))
print
(
'>> total_pts : '
+
str
(
total_pts
))
print
(
'>> total_pts : '
+
str
(
total_pts
))
print
(
'>> makeups_to_do : '
+
str
(
p
[
'makeups_to_do'
]))
print
(
'>> makeups_to_do : '
+
str
(
p
[
'makeups_to_do'
]))
print
(
'>> nb future makeups : '
+
str
(
len
(
res_shift_reg
)))
print
(
'>> nb future makeups : '
+
str
(
len
(
res_shift_reg
)))
"""
For unsubscribed people,
adding a point and going through run_process_target_status may lead them to be suspended
whereas they're not subscribed to any shift.
Adding a fake point will lead odoo to reset Unsuscribed status.
"""
add_second_corrective_pt
=
p
[
'cooperative_state'
]
==
'unsubscribed'
# Add/remove points so their final theoric points is 0
# Add/remove points so their final theoric points is 0
points_to_add
=
-
final_theoric_pts
points_to_add
=
-
final_theoric_pts
...
@@ -61,7 +78,22 @@ def main():
...
@@ -61,7 +78,22 @@ def main():
}
}
api
.
create
(
'shift.counter.event'
,
fields
)
api
.
create
(
'shift.counter.event'
,
fields
)
print
(
'===> Pts ajoutés : '
+
str
(
points_to_add
))
print
(
'===> Pts ajoutés : '
+
str
(
points_to_add
))
if
add_second_corrective_pt
is
True
:
api
.
execute
(
'res.partner'
,
'run_process_target_status'
,
[])
fields
=
{
'name'
:
"Correction de l'historique - Sécurité pour les désinscrit.es"
,
'shift_id'
:
False
,
'type'
:
'standard'
,
'partner_id'
:
p
[
'id'
],
'point_qty'
:
0
}
api
.
create
(
'shift.counter.event'
,
fields
)
print
(
'===> Pt correctif pour désinscrits'
)
print
(
'--------'
)
print
(
'--------'
)
print
(
'Nb de personnes concernées : '
+
str
(
cpt
))
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
main
()
main
()
\ 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