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): ...@@ -597,8 +597,11 @@ def shift_subscription(request):
if 'success' in credentials and credentials['success'] is True and credentials['id'] == partner_id: if 'success' in credentials and credentials['success'] is True and credentials['id'] == partner_id:
is_allowed = True is_allowed = True
if is_allowed is True: if is_allowed is True:
api = OdooAPI()
partner_id = int(data["partner_id"]) partner_id = int(data["partner_id"])
shift_type = data["shift_type"] shift_type = data["shift_type"]
moving_from_std_to_ftop = False
if shift_type == 1: if shift_type == 1:
# 1 = standard # 1 = standard
shift_template_id = int(data["shift_template_id"]) shift_template_id = int(data["shift_template_id"])
...@@ -610,13 +613,16 @@ def shift_subscription(request): ...@@ -610,13 +613,16 @@ def shift_subscription(request):
# If None, no committees shift, get the first ftop shift # If None, no committees shift, get the first ftop shift
if shift_template_id is None: if shift_template_id is None:
shift_template_id = CagetteServices.get_first_ftop_shift_id() 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: else:
# 3 = exempté # 3 = exempté
# Get exemptions shift # Get exemptions shift
shift_template_id = CagetteServices.get_exemptions_shift_id() shift_template_id = CagetteServices.get_exemptions_shift_id()
m = CagetteMember(partner_id) m = CagetteMember(partner_id)
api = OdooAPI()
unsubscribe_first = data["unsubscribe_first"] unsubscribe_first = data["unsubscribe_first"]
if unsubscribe_first is True: if unsubscribe_first is True:
...@@ -631,11 +637,11 @@ def shift_subscription(request): ...@@ -631,11 +637,11 @@ def shift_subscription(request):
}, },
status=409 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) if moving_from_std_to_ftop:
lower_makeup_count_to_zero_if_moving_from_std_to_ftop(partner_id, res)
# https://redmine.coopdev.fr/issues/4715
lower_makeup_count_to_zero_if_moving_from_std_to_ftop(api, partner_id, shift_type, res)
reg_id = m.create_coop_shift_subscription(shift_template_id, shift_type) reg_id = m.create_coop_shift_subscription(shift_template_id, shift_type)
# Return necessary data # Return necessary data
...@@ -657,23 +663,18 @@ def shift_subscription(request): ...@@ -657,23 +663,18 @@ def shift_subscription(request):
return response return response
def lower_makeup_count_to_zero_if_moving_from_std_to_ftop(api, partner_id, shift_type, res): def lower_makeup_count_to_zero_if_moving_from_std_to_ftop(partner_id, res):
if shift_type == 2: members_data = []
c = [['id', '=', partner_id]] members_data.append({
f = ['shift_type'] 'member_id': partner_id,
old_shift_type = api.search_read('res.partner', c, f)[0]['shift_type'] 'member_shift_type': 'standard',
if old_shift_type == 'standard': 'target_makeups_nb': 0,
members_data = [] 'description': 'reset automatique du compteur rattrapages suite changement créneau standard vers non standard'
members_data.append({ })
'member_id': partner_id, res["res"] = []
'member_shift_type': old_shift_type, update_members_makeups_core(members_data, res)
'target_makeups_nb': 0, if res["res"][0]["update"]:
'description': 'reset automatique du compteur rattrapages suite changement créneau standard vers non standard' res["makeups_to_do"] = 0
})
res["res"] = []
update_members_makeups_core(members_data, res)
if res["res"][0]["update"]:
res["makeups_to_do"] = 0
# --- Gestion des binômes # --- Gestion des binômes
......
...@@ -845,6 +845,7 @@ class CagetteMember(models.Model): ...@@ -845,6 +845,7 @@ class CagetteMember(models.Model):
elif search_type == "makeups_data": elif search_type == "makeups_data":
fields = CagetteMember.m_short_default_fields fields = CagetteMember.m_short_default_fields
fields = fields + ['shift_type', 'makeups_to_do', 'display_ftop_points', 'display_std_points', 'shift_type'] 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) res = api.search_read('res.partner', cond, fields)
CagetteMembers.add_makeups_to_come_to_member_data(res) CagetteMembers.add_makeups_to_come_to_member_data(res)
return res return res
......
...@@ -115,13 +115,17 @@ function display_makeups_members() { ...@@ -115,13 +115,17 @@ function display_makeups_members() {
className: "dt-body-center", className: "dt-body-center",
width: "10%", width: "10%",
render: function (data, type, full) { 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}"> <button class="decrement_makeup btn--primary" id="decrement_member_${full.id}">
<i class="fas fa-minus"></i> <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}"> <button class="increment_makeup btn--primary" id="increment_member_${full.id}">
<i class="fas fa-plus"></i> <i class="fas fa-plus"></i>
</button>`; </button>`;
}
return html;
} }
}, },
{ {
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
</div> </div>
<div id="add_members_area"> <div id="add_members_area">
<div id="add_members_form_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"> <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> <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> <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