Commit c8394a0e by Damien Moulard

Merge branch…

Merge branch '5349-suppression-rattrapages-choisis-suite-changement-std-to-ftop-et-blocage-actions-rattrapages-sur-ftop' into 'dev_cooperatic'

5349 suppression rattrapages choisis suite changement std to ftop et blocage actions rattrapages sur ftop

See merge request !252
parents fd39d9aa 786e04ab
Pipeline #3149 failed with stage
in 1 minute 6 seconds
......@@ -597,8 +597,11 @@ def shift_subscription(request):
if 'success' in credentials and credentials['success'] is True and credentials['id'] == partner_id:
is_allowed = True
if is_allowed is True:
api = OdooAPI()
partner_id = int(data["partner_id"])
shift_type = data["shift_type"]
moving_from_std_to_ftop = False
if shift_type == 1:
# 1 = standard
shift_template_id = int(data["shift_template_id"])
......@@ -610,13 +613,16 @@ def shift_subscription(request):
# If None, no committees shift, get the first ftop shift
if shift_template_id is None:
shift_template_id = CagetteServices.get_first_ftop_shift_id()
c = [['id', '=', partner_id]]
f = ['shift_type']
moving_from_std_to_ftop = api.search_read('res.partner', c, f)[0]['shift_type'] == 'standard'
else:
# 3 = exempté
# Get exemptions shift
shift_template_id = CagetteServices.get_exemptions_shift_id()
m = CagetteMember(partner_id)
api = OdooAPI()
unsubscribe_first = data["unsubscribe_first"]
if unsubscribe_first is True:
......@@ -631,11 +637,11 @@ def shift_subscription(request):
},
status=409
)
changing_shift = not moving_from_std_to_ftop
res["unsubscribe_member"] = m.unsubscribe_member(changing_shift)
res["unsubscribe_member"] = m.unsubscribe_member(changing_shift = True)
# https://redmine.coopdev.fr/issues/4715
lower_makeup_count_to_zero_if_moving_from_std_to_ftop(api, partner_id, shift_type, res)
if moving_from_std_to_ftop:
lower_makeup_count_to_zero_if_moving_from_std_to_ftop(partner_id, res)
reg_id = m.create_coop_shift_subscription(shift_template_id, shift_type)
# Return necessary data
......@@ -657,23 +663,18 @@ def shift_subscription(request):
return response
def lower_makeup_count_to_zero_if_moving_from_std_to_ftop(api, partner_id, shift_type, res):
if shift_type == 2:
c = [['id', '=', partner_id]]
f = ['shift_type']
old_shift_type = api.search_read('res.partner', c, f)[0]['shift_type']
if old_shift_type == 'standard':
members_data = []
members_data.append({
'member_id': partner_id,
'member_shift_type': old_shift_type,
'target_makeups_nb': 0,
'description': 'reset automatique du compteur rattrapages suite changement créneau standard vers non standard'
})
res["res"] = []
update_members_makeups_core(members_data, res)
if res["res"][0]["update"]:
res["makeups_to_do"] = 0
def lower_makeup_count_to_zero_if_moving_from_std_to_ftop(partner_id, res):
members_data = []
members_data.append({
'member_id': partner_id,
'member_shift_type': 'standard',
'target_makeups_nb': 0,
'description': 'reset automatique du compteur rattrapages suite changement créneau standard vers non standard'
})
res["res"] = []
update_members_makeups_core(members_data, res)
if res["res"][0]["update"]:
res["makeups_to_do"] = 0
# --- Gestion des binômes
......
......@@ -845,6 +845,7 @@ class CagetteMember(models.Model):
elif search_type == "makeups_data":
fields = CagetteMember.m_short_default_fields
fields = fields + ['shift_type', 'makeups_to_do', 'display_ftop_points', 'display_std_points', 'shift_type']
cond.append(['shift_type', '=', 'standard'])
res = api.search_read('res.partner', cond, fields)
CagetteMembers.add_makeups_to_come_to_member_data(res)
return res
......
......@@ -115,13 +115,17 @@ function display_makeups_members() {
className: "dt-body-center",
width: "10%",
render: function (data, type, full) {
return `<b>${data}</b>
var html = `<b>${data}</b>
<button class="decrement_makeup btn--primary" id="decrement_member_${full.id}">
<i class="fas fa-minus"></i>
</button>
</button>`;
if(full.shift_type == 'standard') {
html += `
<button class="increment_makeup btn--primary" id="increment_member_${full.id}">
<i class="fas fa-plus"></i>
</button>`;
}
return html;
}
},
{
......
......@@ -40,7 +40,7 @@
</div>
<div id="add_members_area">
<div id="add_members_form_area">
<h4>Ou, ajouter un rattrapage à un.e membre</h4>
<h4>Ou, ajouter un rattrapage à un.e membre standard</h4>
<form id="search_member_form" action="javascript:;" method="post">
<input type="text" id="search_member_input" value="" placeholder="Nom ou numéro du coop..." required>
<button type="submit" class="btn--primary" id="search_member_button">Recherche</button>
......
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