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
1bf2ae0d
Commit
1bf2ae0d
authored
Feb 10, 2022
by
Thibault Grandjean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add script
parent
88a7adaf
Pipeline
#1785
passed with stage
in 1 minute 37 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
delete_makeups_for_uptodate_members.py
outils/scripts/delete_makeups_for_uptodate_members.py
+56
-0
No files found.
outils/scripts/delete_makeups_for_uptodate_members.py
0 → 100644
View file @
1bf2ae0d
"""
Delete makeups_to_do for up_to_date members.
Run this script from the project root with:
$ python -m outils.scripts.delete_makeups_for_uptodate_members
"""
import
os
from
pathlib
import
Path
from
importlib
import
import_module
import
logging
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
format
=
'[
%(asctime)
s]
%(levelname)
s -
%(message)
s'
,
datefmt
=
'
%
H:
%
M:
%
S'
)
logger
=
logging
.
getLogger
(
__file__
)
project_path
=
Path
(
__file__
)
.
resolve
()
.
parents
[
2
]
def
get_api
():
if
not
os
.
environ
.
get
(
'DJANGO_SETTINGS_MODULE'
):
os
.
environ
[
'DJANGO_SETTINGS_MODULE'
]
=
"outils.settings"
module
=
import_module
(
'outils.common'
)
return
module
.
OdooAPI
()
def
get_concerned_users
(
api
):
cond
=
[
[
'cooperative_state'
,
'='
,
'up_to_date'
],
[
'makeups_to_do'
,
'>'
,
0
]
]
fields
=
[
'id'
]
return
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
def
main
():
api
=
get_api
()
concerned_users
=
get_concerned_users
(
api
)
logger
.
info
(
'Number of concerned members
%
i'
,
len
(
concerned_users
))
for
user
in
concerned_users
:
logger
.
debug
(
"Member:
%
s is concerned"
,
user
.
get
(
'name'
))
api
.
update
(
'res.partner'
,
user
.
get
(
'id'
),
{
'makeups_to_do'
:
0
})
logger
.
debug
(
"Member:
%
s has no more make ups to do!"
,
user
.
get
(
'name'
))
new_concerned_users
=
get_concerned_users
(
api
)
logger
.
info
(
'Now the number of concerned members
%
i'
,
len
(
new_concerned_users
))
if
__name__
==
"__main__"
:
main
()
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