Commit 41228043 by Yvon

3882 explication suppression presence

parent 66fc8c7c
Pipeline #2740 passed with stage
in 1 minute 27 seconds
......@@ -498,15 +498,16 @@ def delete_shift_registration(request):
member_id = int(data["member_id"])
shift_registration_id = int(data["shift_registration_id"])
shift_is_makeup = data["shift_is_makeup"]
cancellation_description = data["cancellation_description"]
# Note: 'upcoming_registration_count' in res.partner won't change because the _compute method
# in odoo counts canceled shift registrations.
m = CagetteShift()
res["cancel_shift"] = m.cancel_shift([shift_registration_id], origin='bdm')
res["cancel_shift"] = m.cancel_shift([shift_registration_id], origin='bdm', description=cancellation_description)
if shift_is_makeup is True:
fields = {
'name': "Admin BDM - Suppression d'un rattrapage",
'name': "Admin BDM (annulation de rattrapage par une annulation de présence) - " + cancellation_description,
'shift_id': False,
'type': data["member_shift_type"],
'partner_id': member_id,
......
......@@ -102,16 +102,21 @@ function display_member_shifts() {
const shift_reg_id = row_data.id;
const shift_is_makeup = row_data.is_makeup;
let msg = `<p>Enlever la présence de <b>${member.name}</b> au service du <b>${row_data.shift_id[1]}</b> ?</p>`;
let modal_template = $("#modal_delete_shift_registration");
modal_template.find(".member_name").text(member.name);
modal_template.find(".service_name").text(row_data.shift_id[1]);
if (shift_is_makeup === true) {
msg += `<p><i class="fas fa-exclamation-triangle"></i> Ce service est un rattrapage. Le supprimer ajoutera un point au compteur de ce.tte membre.</p>`;
modal_template.find("#makeup_case_explanation").show();
}
openModal(
msg,
$("#modal_delete_shift_registration").html(),
() => {
delete_shift_registration(shift_reg_id, shift_is_makeup);
delete_shift_registration(
shift_reg_id,
shift_is_makeup,
($("#cancellation-explanation")[0].value || "pas d'explication") + ' : ' + ($("#cancellation-signature")[0].value || "auteur inconnu"),
);
},
"Confirmer",
false
......@@ -123,15 +128,17 @@ function display_member_shifts() {
* Send request to delete shift registration
* @param {Int} shift_reg_id Id of the shift_registration to delete
* @param {Boolean} shift_is_makeup Is the shift a makeup?
* @param {String} description explanation and signature for the cancellation from bdm
*/
function delete_shift_registration(shift_reg_id, shift_is_makeup) {
function delete_shift_registration(shift_reg_id, shift_is_makeup, description) {
openModal();
data = {
member_id: selected_member.id,
member_shift_type: selected_member.shift_type,
shift_registration_id: shift_reg_id,
shift_is_makeup: shift_is_makeup
shift_is_makeup: shift_is_makeup,
cancellation_description: description
};
$.ajax({
......
......@@ -293,11 +293,12 @@ class CagetteShift(models.Model):
coop_logger.error("Model affect shift nobody found : %s", str(cond))
return response
def cancel_shift(self, idsRegisteur, origin='memberspace'):
def cancel_shift(self, idsRegisteur, origin='memberspace', description=None):
"""Annule un shift"""
fieldsDatas = { "related_shift_state": 'cancel',
"origin": origin,
"state": 'cancel'}
"state": 'cancel',
"cancellation_description": description}
return self.o_api.update('shift.registration', idsRegisteur, fieldsDatas)
......
......@@ -51,7 +51,16 @@
</div>
</div>
<div id="templates" style="display:none;"></div>
<div id="templates" style="display:none;">
<div id="modal_delete_shift_registration">
<p>Enlever la présence de <b><span class="member_name"></span></b> au service du <b><span class="service_name"></span></b> ?</p>
<div id="makeup_case_explanation" style="display:none">
<p><i class="fas fa-exclamation-triangle"></i> Ce service est un rattrapage. Le supprimer ajoutera un point au compteur de ce.tte membre.</p>
</div>
<br><label for="cancellation-explanation">Explication : </label><input class="" type="text" id="cancellation-explanation">
<br><br><label for="cancellation-signature">Signature : </label><input class="" type="text" id="cancellation-signature">
</div>
</div>
</div>
<script src='{% static "js/all_common.js" %}?v=1651853225'></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