Commit ad509301 by François C.

Merge branch '3882-explication-pour-suppression-presence' into 'dev_cooperatic'

3882 explication suppression presence

See merge request !226
parents 27f86846 41228043
Pipeline #2753 passed with stage
in 1 minute 29 seconds
...@@ -498,15 +498,16 @@ def delete_shift_registration(request): ...@@ -498,15 +498,16 @@ def delete_shift_registration(request):
member_id = int(data["member_id"]) member_id = int(data["member_id"])
shift_registration_id = int(data["shift_registration_id"]) shift_registration_id = int(data["shift_registration_id"])
shift_is_makeup = data["shift_is_makeup"] 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 # Note: 'upcoming_registration_count' in res.partner won't change because the _compute method
# in odoo counts canceled shift registrations. # in odoo counts canceled shift registrations.
m = CagetteShift() 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: if shift_is_makeup is True:
fields = { 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, 'shift_id': False,
'type': data["member_shift_type"], 'type': data["member_shift_type"],
'partner_id': member_id, 'partner_id': member_id,
......
...@@ -102,16 +102,21 @@ function display_member_shifts() { ...@@ -102,16 +102,21 @@ function display_member_shifts() {
const shift_reg_id = row_data.id; const shift_reg_id = row_data.id;
const shift_is_makeup = row_data.is_makeup; 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) { 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( 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", "Confirmer",
false false
...@@ -123,15 +128,17 @@ function display_member_shifts() { ...@@ -123,15 +128,17 @@ function display_member_shifts() {
* Send request to delete shift registration * Send request to delete shift registration
* @param {Int} shift_reg_id Id of the shift_registration to delete * @param {Int} shift_reg_id Id of the shift_registration to delete
* @param {Boolean} shift_is_makeup Is the shift a makeup? * @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(); openModal();
data = { data = {
member_id: selected_member.id, member_id: selected_member.id,
member_shift_type: selected_member.shift_type, member_shift_type: selected_member.shift_type,
shift_registration_id: shift_reg_id, shift_registration_id: shift_reg_id,
shift_is_makeup: shift_is_makeup shift_is_makeup: shift_is_makeup,
cancellation_description: description
}; };
$.ajax({ $.ajax({
......
...@@ -292,11 +292,12 @@ class CagetteShift(models.Model): ...@@ -292,11 +292,12 @@ class CagetteShift(models.Model):
coop_logger.error("Model affect shift nobody found : %s", str(cond)) coop_logger.error("Model affect shift nobody found : %s", str(cond))
return response return response
def cancel_shift(self, idsRegisteur, origin='memberspace'): def cancel_shift(self, idsRegisteur, origin='memberspace', description=None):
"""Annule un shift""" """Annule un shift"""
fieldsDatas = { "related_shift_state": 'cancel', fieldsDatas = { "related_shift_state": 'cancel',
"origin": origin, "origin": origin,
"state": 'cancel'} "state": 'cancel',
"cancellation_description": description}
return self.o_api.update('shift.registration', idsRegisteur, fieldsDatas) return self.o_api.update('shift.registration', idsRegisteur, fieldsDatas)
......
...@@ -51,7 +51,16 @@ ...@@ -51,7 +51,16 @@
</div> </div>
</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> </div>
<script src='{% static "js/all_common.js" %}?v=1651853225'></script> <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