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
e9635429
Commit
e9635429
authored
Mar 04, 2022
by
Thibault Grandjean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
can create pair
parent
d0fea7ae
Pipeline
#1871
failed with stage
in 1 minute 27 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
13 deletions
+68
-13
admin.py
members/admin.py
+2
-1
manage_attached.js
members/static/js/admin/manage_attached.js
+53
-5
manage_attached_create_pair.html
templates/members/admin/manage_attached_create_pair.html
+13
-7
No files found.
members/admin.py
View file @
e9635429
...
...
@@ -501,7 +501,8 @@ def create_pair(request):
child
[
field
]
=
child
[
field
][
0
]
child
[
'is_associated_people'
]
=
True
child
[
'parent_id'
]
=
parent
[
'commercial_partner_id'
][
0
]
child
[
'cooperative_state'
]
=
"associated"
# update child base account state
api
.
update
(
"res.partner"
,
[
child_id
],
{
"cooperative_state"
:
"associated"
})
# get barcode rule id
bbcode_rule
=
api
.
search_read
(
"barcode.rule"
,
[[
'for_associated_people'
,
"="
,
True
]],
[
'id'
])[
0
]
child
[
'barcode_rule_id'
]
=
bbcode_rule
[
"id"
]
...
...
members/static/js/admin/manage_attached.js
View file @
e9635429
...
...
@@ -13,6 +13,13 @@ function load_member_infos(divId, memberId) {
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
success
:
function
(
data
)
{
console
.
log
(
data
)
console
.
log
(
divId
)
if
(
divId
===
'parentInfo'
)
{
parentId
=
data
.
member
.
id
}
else
if
(
divId
===
'childInfo'
)
{
childId
=
data
.
member
.
id
}
display_member_infos
(
divId
,
data
.
member
)
},
error
:
function
(
data
)
{
...
...
@@ -28,14 +35,24 @@ function load_member_infos(divId, memberId) {
});
}
function
ready_for_submission
()
{
if
(
parentId
!=
null
&&
childId
!=
null
)
{
console
.
log
(
"ready"
)
return
true
}
}
/**
* Display member info
*/
function
display_member_infos
(
divId
,
memberData
)
{
$
(
"#"
+
divId
).
show
()
console
.
log
(
memberData
)
$
(
"#"
+
divId
).
show
()
$
(
"#"
+
divId
).
find
(
"#name"
).
text
(
memberData
.
name
)
if
(
parentId
!=
null
&&
childId
!=
null
)
{
$
(
"#createPair"
).
prop
(
"disabled"
,
false
)
}
}
...
...
@@ -90,7 +107,7 @@ $(document).ready(function() {
}
)
},
minLength
:
3
,
minLength
:
1
,
select
:
function
(
event
,
ui
)
{
if
(
ui
.
item
)
{
load_member_infos
(
"parentInfo"
,
ui
.
item
.
value
)
...
...
@@ -132,9 +149,40 @@ $(document).ready(function() {
}
)
},
minLength
:
3
,
minLength
:
1
,
select
:
function
(
event
,
ui
)
{
return
null
if
(
ui
.
item
)
{
load_member_infos
(
"childInfo"
,
ui
.
item
.
value
)
}
},
})
$
(
"#createPair"
).
on
(
'click'
,
function
()
{
var
payload
=
{
"parent"
:
{
"id"
:
parentId
},
"child"
:
{
"id"
:
childId
}
}
$
.
ajax
({
type
:
'POST'
,
url
:
"/members/admin/manage_attached/create_pair"
,
dataType
:
"json"
,
contentType
:
"application/json; charset=utf-8"
,
data
:
JSON
.
stringify
(
payload
),
success
:
function
(
data
)
{
console
.
log
(
data
)
alert
(
"binôme créé"
)
},
error
:
function
(
data
)
{
err
=
{
msg
:
"erreur serveur"
,
ctx
:
'create pair'
};
if
(
typeof
data
.
responseJSON
!=
'undefined'
&&
typeof
data
.
responseJSON
.
error
!=
'undefined'
)
{
err
.
msg
+=
' : '
+
data
.
responseJSON
.
error
;
}
report_JS_error
(
err
,
'members.admin'
);
closeModal
();
alert
(
'Erreur lors de création du binôme.'
);
}
})
})
})
templates/members/admin/manage_attached_create_pair.html
View file @
e9635429
...
...
@@ -40,15 +40,21 @@
</div>
</div>
<div
class=
"tiles_container"
>
<div
class=
"tile high_tile"
>
<div
id=
"search_member_form_area"
>
<h4>
Rechercher le.a coopérateur.ice co-titulaire
</h4>
<form
autocomplete=
"off"
id=
"search_member_form_child"
action=
"javascript:;"
method=
"post"
>
<input
name=
"searchChild"
type=
"text"
id=
"search_child_input"
value=
""
placeholder=
"Nom ou numéro du coop..."
required
>
</form>
</div>
<div
class=
"tile high_tile"
>
<div
id=
"search_member_form_area"
>
<h4>
Rechercher le.a coopérateur.ice co-titulaire
</h4>
<form
autocomplete=
"off"
id=
"search_member_form_child"
action=
"javascript:;"
method=
"post"
>
<input
name=
"searchChild"
type=
"text"
id=
"search_child_input"
value=
""
placeholder=
"Nom ou numéro du coop..."
required
>
</form>
</div>
<div
id=
"childInfo"
style=
"display:none;"
>
<div>
Nom
</div><div
id=
"name"
></div>
</div>
</div>
</div>
<div
class=
"create-pair"
>
<button
id=
"createPair"
type=
"button"
name=
"button"
disabled
>
Créer le binôme
</button>
</div>
</div>
<script
src=
'{% static "js/all_common.js" %}?v='
></script>
...
...
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