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
b073169b
Commit
b073169b
authored
Mar 14, 2022
by
Thibault Grandjean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
c87c1ccf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
6 deletions
+30
-6
admin.py
members/admin.py
+30
-6
No files found.
members/admin.py
View file @
b073169b
...
@@ -356,7 +356,7 @@ def update_members_makeups(request):
...
@@ -356,7 +356,7 @@ def update_members_makeups(request):
cm
=
CagetteMember
(
int
(
member_data
[
"member_id"
]))
cm
=
CagetteMember
(
int
(
member_data
[
"member_id"
]))
res
[
"res"
]
.
append
(
cm
.
update_member_makeups
(
member_data
))
res
[
"res"
]
.
append
(
cm
.
update_member_makeups
(
member_data
))
# Update member standard points, for standard members only
# Update member standard points, for standard members only
if
member_data
[
"member_shift_type"
]
==
"standard"
:
if
member_data
[
"member_shift_type"
]
==
"standard"
:
# Set points to minus the number of makeups to do (limited to -2)
# Set points to minus the number of makeups to do (limited to -2)
...
@@ -499,12 +499,15 @@ def create_pair(request):
...
@@ -499,12 +499,15 @@ def create_pair(request):
"street2"
,
"street2"
,
"zip"
,
"zip"
,
"nb_associated_people"
,
"nb_associated_people"
,
"current_template_name"
"current_template_name"
,
"parent_id"
,
"is_associated_people"
,
]
]
child
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
child_id
]],
fields
)[
0
]
child
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
child_id
]],
fields
)[
0
]
parent
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
parent_id
]],
parent
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
parent_id
]],
[
'commercial_partner_id'
,
[
'commercial_partner_id'
,
'nb_associated_people'
,
'nb_associated_people'
,
'current_template_name'
,
'parent_id'
])[
0
]
'parent_id'
])[
0
]
errors
=
[]
errors
=
[]
if
child
[
'nb_associated_people'
]
>
0
:
if
child
[
'nb_associated_people'
]
>
0
:
...
@@ -513,6 +516,12 @@ def create_pair(request):
...
@@ -513,6 +516,12 @@ def create_pair(request):
# le membre suppléant fait parti du commité?
# le membre suppléant fait parti du commité?
if
child
[
'current_template_name'
]
==
"Services des comités"
:
if
child
[
'current_template_name'
]
==
"Services des comités"
:
errors
.
append
(
"Le membre suppléant séléctionné fait parti du comité"
)
errors
.
append
(
"Le membre suppléant séléctionné fait parti du comité"
)
# Verifier que le suppléant n'est pas déjà en binôme soit titulaire soit suppléant
for
m
in
api
.
search_read
(
'res.partner'
,
[[
'email'
,
'='
,
child
[
'email'
]]]):
if
m
[
'is_associated_people'
]:
errors
.
append
(
'Le membre suppléant est déjà en bînome'
)
if
m
[
'child_ids'
]:
errors
.
append
(
"Le membre suppléant sélectionné est titulaire d'un binôme"
)
# le membre titulaire a déjà un/des suppléants?
# le membre titulaire a déjà un/des suppléants?
if
parent
[
'nb_associated_people'
]
>=
1
:
if
parent
[
'nb_associated_people'
]
>=
1
:
# On récupère le/s suppléant(s)
# On récupère le/s suppléant(s)
...
@@ -532,12 +541,18 @@ def create_pair(request):
...
@@ -532,12 +541,18 @@ def create_pair(request):
except
TypeError
:
except
TypeError
:
child
[
field
]
=
False
child
[
field
]
=
False
child
[
'is_associated_people'
]
=
True
child
[
'is_associated_people'
]
=
True
child
[
'parent_id'
]
=
parent
[
'
commercial_partner_id'
][
0
]
child
[
'parent_id'
]
=
parent
[
'
id'
]
# update child base account state
# update child base account state
api
.
update
(
"res.partner"
,
[
child_id
],
{
"cooperative_state"
:
"associated"
})
api
.
execute
(
"res.partner"
,
"set_special_state"
,
{
"id"
:
child_id
,
'state'
:
"associated"
})
# suppression du créneau pour le compte de base
shift_registration
=
api
.
search_read
(
"shift.template.registration"
,
[[
'partner_id'
,
'='
,
child_id
]],
[
'id'
])
api
.
delete
(
"shift.template.registration"
,
[
x
[
'id'
]
for
x
in
shift_registration
])
# suppression des rattrapages ?
# get barcode rule id
# get barcode rule id
bbcode_rule
=
api
.
search_read
(
"barcode.rule"
,
[[
'for_associated_people'
,
"="
,
True
]],
[
'id'
])[
0
]
bbcode_rule
=
api
.
search_read
(
"barcode.rule"
,
[[
'for_associated_people'
,
"="
,
True
]],
[
'id'
])[
0
]
child
[
'barcode_rule_id'
]
=
bbcode_rule
[
"id"
]
child
[
'barcode_rule_id'
]
=
bbcode_rule
[
"id"
]
# TODO: le compte rattaché doit être ajouté dans le créneau du titulaire
attached_account
=
api
.
create
(
'res.partner'
,
child
)
attached_account
=
api
.
create
(
'res.partner'
,
child
)
# generate_base
# generate_base
api
.
execute
(
'res.partner'
,
'generate_base'
,
[
attached_account
])
api
.
execute
(
'res.partner'
,
'generate_base'
,
[
attached_account
])
...
@@ -570,8 +585,17 @@ def delete_pair(request):
...
@@ -570,8 +585,17 @@ def delete_pair(request):
if
CagetteUser
.
are_credentials_ok
(
request
):
if
CagetteUser
.
are_credentials_ok
(
request
):
api
=
OdooAPI
()
api
=
OdooAPI
()
data
=
json
.
loads
(
request
.
body
.
decode
())
data
=
json
.
loads
(
request
.
body
.
decode
())
child_id
=
data
[
'child'
][
'id'
]
child_id
=
int
(
data
[
'child'
][
'id'
])
api
.
update
(
'res.partner'
,
[
int
(
child_id
)],
{
"parent_id"
:
False
,
"is_associated_people"
:
False
})
child
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
child_id
]],
[
'email'
,
'id'
,
'parent_id'
])[
0
]
child_accounts
=
api
.
search_read
(
'res.partner'
,
[[
'email'
,
'='
,
child
[
'email'
]]],
[
'id'
,
'email'
])
prev_child
=
[
x
[
'id'
]
for
x
in
child_accounts
if
x
[
'id'
]
!=
child_id
]
parent
=
api
.
search_read
(
'res.partner'
,
[[
'id'
,
'='
,
child
[
'parent_id'
][
0
]]],
[
'cooperative_state'
])
api
.
update
(
'res.partner'
,
[
child_id
],
{
"parent_id"
:
False
,
"is_associated_people"
:
False
})
api
.
delete
(
'res.partner'
,
[
child_id
])
for
id
in
prev_child
:
# api.update('res.partner', [id], {"cooperative_state": 'unsubscribed'})
api
.
execute
(
"res.partner"
,
"set_special_state"
,
{
"id"
:
id
,
'state'
:
"cancel_special"
})
response
=
JsonResponse
({
"message"
:
"Succesfuly unpaired members"
},
status
=
200
)
response
=
JsonResponse
({
"message"
:
"Succesfuly unpaired members"
},
status
=
200
)
else
:
else
:
...
...
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