Commit 298c4ee4 by Etienne Freiss

Merge branch 'dev_cooperatic' into 2496-create-connection-for-shift-registration-station

parents 1828883a 17a551fc
Pipeline #1928 passed with stage
in 1 minute 30 seconds
...@@ -385,14 +385,24 @@ def delete_shift_registration(request): ...@@ -385,14 +385,24 @@ def delete_shift_registration(request):
is_connected_user = CagetteUser.are_credentials_ok(request) is_connected_user = CagetteUser.are_credentials_ok(request)
if is_connected_user is True: if is_connected_user is True:
data = json.loads(request.body.decode()) data = json.loads(request.body.decode())
shift_registration_id = int(data["shift_registration_id"])
member_id = int(data["member_id"]) member_id = int(data["member_id"])
shift_registration_id = int(data["shift_registration_id"])
m = CagetteShift() shift_is_makeup = data["shift_is_makeup"]
res["res"] = m.cancel_shift([shift_registration_id])
# 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()
res["cancel_shift"] = m.cancel_shift([shift_registration_id])
if shift_is_makeup is True:
fields = {
'name': "Admin BDM - Suppression d'un rattrapage",
'shift_id': False,
'type': data["member_shift_type"],
'partner_id': member_id,
'point_qty': 1
}
res["update_counter"] = m.update_counter_event(fields)
response = JsonResponse(res, safe=False) response = JsonResponse(res, safe=False)
else: else:
......
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
padding-top: 0.755em; padding-top: 0.755em;
} }
.makeup_row {
background-color: #ffc854 !important;
}
/* Search membres area */ /* Search membres area */
#search_member_area { #search_member_area {
margin-top: 30px; margin-top: 30px;
......
...@@ -88,17 +88,29 @@ function display_member_shifts() { ...@@ -88,17 +88,29 @@ function display_member_shifts() {
"sLoadingRecords": "Chargement en cours...", "sLoadingRecords": "Chargement en cours...",
"sZeroRecords": "Aucun élément à afficher", "sZeroRecords": "Aucun élément à afficher",
"sEmptyTable": "Aucun futur service pour ce.tte membre" "sEmptyTable": "Aucun futur service pour ce.tte membre"
} },
createdRow: function(row, rdata) {
if (rdata.is_makeup === true) {
$(row).addClass("makeup_row");
$(row).prop('title', 'Ce service est un rattrapage');
}
},
}); });
$('#member_shifts_table').on('click', 'tbody td .delete_shift_registration', function () { $('#member_shifts_table').on('click', 'tbody td .delete_shift_registration', function () {
const row_data = member_shifts_table.row($(this).parents('tr')).data(); const row_data = member_shifts_table.row($(this).parents('tr')).data();
const shift_reg_id = row_data.id; 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>`;
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>`;
}
openModal( openModal(
`Enlever la présence de ${member.name} au service du ${row_data.shift_id[1]} ?`, msg,
() => { () => {
delete_shift_registration(shift_reg_id); delete_shift_registration(shift_reg_id, shift_is_makeup);
}, },
"Confirmer", "Confirmer",
false false
...@@ -109,13 +121,16 @@ function display_member_shifts() { ...@@ -109,13 +121,16 @@ 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?
*/ */
function delete_shift_registration(shift_reg_id) { function delete_shift_registration(shift_reg_id, shift_is_makeup) {
openModal(); openModal();
data = { data = {
member_id: selected_member.id, member_id: selected_member.id,
shift_registration_id: shift_reg_id member_shift_type: selected_member.shift_type,
shift_registration_id: shift_reg_id,
shift_is_makeup: shift_is_makeup
}; };
$.ajax({ $.ajax({
......
...@@ -367,4 +367,8 @@ class CagetteShift(models.Model): ...@@ -367,4 +367,8 @@ class CagetteShift(models.Model):
def member_can_have_delay(self, partner_id): def member_can_have_delay(self, partner_id):
""" Can a member have a delay? """ """ Can a member have a delay? """
return self.o_api.execute('res.partner', 'can_have_extension', [partner_id]) return self.o_api.execute('res.partner', 'can_have_extension', [partner_id])
\ No newline at end of file
def update_counter_event(self, fields):
""" Add/remove points """
return self.o_api.create('shift.counter.event', fields)
\ No newline at end of file
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