Commit e9635429 by Thibault Grandjean

can create pair

parent d0fea7ae
Pipeline #1871 failed with stage
in 1 minute 27 seconds
......@@ -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"]
......
......@@ -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.');
}
})
})
})
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment