Commit 4184d5c7 by Etienne Freiss

Merge branch 'dev_cooperatic' into 2253-new-binome

parents 9b019d61 75bca762
Pipeline #1868 passed with stage
in 1 minute 30 seconds
...@@ -59,7 +59,7 @@ class CagetteEnvelops(models.Model): ...@@ -59,7 +59,7 @@ class CagetteEnvelops(models.Model):
# Get first invoice for which amount being paid <= amount left to pay in invoice # Get first invoice for which amount being paid <= amount left to pay in invoice
for invoice_item in invoice_res: for invoice_item in invoice_res:
if int(float(data['amount']) * 100) <= int(float(invoice_item['residual_signed']) * 100): if int(float(data['amount']) * 100) <= int(float(invoice_item['residual_signed']) * 100):
invoice = invoice_ite invoice = invoice_item
if invoice is None: if invoice is None:
res['error'] = 'The amount is too high for the invoices found for this partner.' res['error'] = 'The amount is too high for the invoices found for this partner.'
......
...@@ -4,7 +4,7 @@ $(document).ready(function() { ...@@ -4,7 +4,7 @@ $(document).ready(function() {
$(".page_content").show(); $(".page_content").show();
let location = window.location.href; let location = window.location.href.replace(/\/$/, '');
$('.management_type_button').on('click', function() { $('.management_type_button').on('click', function() {
if (this.id == 'manage_makeups_button') { if (this.id == 'manage_makeups_button') {
......
...@@ -55,7 +55,7 @@ urlpatterns = [ ...@@ -55,7 +55,7 @@ urlpatterns = [
url(r'^save_partner_info$', views.save_partner_info), url(r'^save_partner_info$', views.save_partner_info),
# BDM - members admin # BDM - members admin
url(r'^admin$', admin.admin), url(r'^admin/?$', admin.admin),
url(r'^admin/manage_makeups$', admin.manage_makeups), url(r'^admin/manage_makeups$', admin.manage_makeups),
url(r'^admin/manage_shift_registrations$', admin.manage_shift_registrations), url(r'^admin/manage_shift_registrations$', admin.manage_shift_registrations),
url(r'^get_makeups_members$', admin.get_makeups_members), url(r'^get_makeups_members$', admin.get_makeups_members),
......
...@@ -20,7 +20,7 @@ function can_exchange_shifts() { ...@@ -20,7 +20,7 @@ function can_exchange_shifts() {
* @returns boolean * @returns boolean
*/ */
function should_select_makeup() { function should_select_makeup() {
return partner_data.makeups_to_do == 0 && (partner_data.is_associated_people === "False" || (partner_data.is_associated_people === "True" && block_actions_for_attached_people === "False")); return partner_data.makeups_to_do > 0 || (partner_data.makeups_to_do > 0 && partner_data.is_associated_people === "True" && block_actions_for_attached_people === "False");
} }
/** /**
...@@ -175,7 +175,7 @@ function init_shifts_list() { ...@@ -175,7 +175,7 @@ function init_shifts_list() {
if (partner_data.associated_partner_id === "False" && partner_data.parent_id === "False") { if (partner_data.associated_partner_id === "False" && partner_data.parent_id === "False") {
shift_line_template.find('.affect_associate_registered').hide(); shift_line_template.find('.affect_associate_registered').hide();
} else { } else {
shift_line_template.find('.affect_associate_registered').attr('id', 'shidt_id_'+shift.id); shift_line_template.find('.affect_associate_registered').attr('id', 'shift_id_'+shift.id);
if (shift.associate_registered==="both") { if (shift.associate_registered==="both") {
shift_line_template.find('.affect_associate_registered').text("Les deux"); shift_line_template.find('.affect_associate_registered').text("Les deux");
} else if (shift.associate_registered==="partner") { } else if (shift.associate_registered==="partner") {
...@@ -237,7 +237,7 @@ function init_shifts_list() { ...@@ -237,7 +237,7 @@ function init_shifts_list() {
modal_template.find("#shift_associate").text(partner_data.associated_partner_name); modal_template.find("#shift_associate").text(partner_data.associated_partner_name);
} else { } else {
modal_template.find("#shift_partner").text(partner_data.associated_partner_name); modal_template.find("#shift_partner").text(partner_data.name);
modal_template.find("#shift_associate").text(partner_data.parent_name); modal_template.find("#shift_associate").text(partner_data.parent_name);
} }
......
...@@ -178,20 +178,30 @@ class CagetteShift(models.Model): ...@@ -178,20 +178,30 @@ class CagetteShift(models.Model):
def affect_shift(self, data): def affect_shift(self, data):
"""Affect shift to partner, his associate or both""" """Affect shift to partner, his associate or both"""
response = None response = None
cond = [['partner_id', '=', int(data['idPartner'])], # partner_id can be 'associated_people' one, which is never use as shift partner_id reference
['id', '=', int(data['idShiftRegistration'])]] # So, let's first retrieved data about the res.partner involved
fields = ['id'] cond = [['id', '=', int(data['idPartner'])]]
try: fields = ['parent_id']
print(cond) partner = self.o_api.search_read('res.partner', cond, fields, 1)
shit_to_affect = self.o_api.search_read('shift.registration', cond, fields, 1) if partner:
print(shit_to_affect) if partner[0]['parent_id']:
if (len(shit_to_affect) == 1): partner_id = partner[0]['parent_id'][0]
shift_res = shit_to_affect[0] else:
print(shift_res) partner_id = int(data['idPartner'])
fieldsDatas = { "associate_registered":data['affected_partner']} cond = [['partner_id', '=', partner_id],
response = self.o_api.update('shift.registration', [shift_res['id']], fieldsDatas) ['id', '=', int(data['idShiftRegistration'])]]
except Exception as e: fields = ['id']
coop_logger.error("Reopen shift : %s", str(e)) try:
# make sure there is coherence between shift.registration id and partner_id (to avoid forged request)
shit_to_affect = self.o_api.search_read('shift.registration', cond, fields, 1)
if (len(shit_to_affect) == 1):
shift_res = shit_to_affect[0]
fieldsDatas = { "associate_registered":data['affected_partner']}
response = self.o_api.update('shift.registration', [shift_res['id']], fieldsDatas)
except Exception as e:
coop_logger.error("Model affect shift : %s", str(e))
else:
coop_logger.error("Model affect shift nobody found : %s", str(cond))
return response return response
def cancel_shift(self, idsRegisteur): def cancel_shift(self, idsRegisteur):
......
...@@ -239,11 +239,14 @@ def affect_shift(request): ...@@ -239,11 +239,14 @@ def affect_shift(request):
if Verification.verif_token(request.POST.get('verif_token'), int(request.POST.get('idPartner'))) is True: if Verification.verif_token(request.POST.get('verif_token'), int(request.POST.get('idPartner'))) is True:
cs = CagetteShift() cs = CagetteShift()
if 'idShiftRegistration' in request.POST and 'affected_partner' in request.POST: if 'idShiftRegistration' in request.POST and 'affected_partner' in request.POST:
# if request is made by associated people, idPartner is it's id, not "master" res.partner
# it's will be handled in model's method (affect_shift)
data = { data = {
"idPartner": int(request.POST['idPartner']), "idPartner": int(request.POST['idPartner']),
"idShiftRegistration": int(request.POST['idShiftRegistration']), "idShiftRegistration": int(request.POST['idShiftRegistration']),
"affected_partner": request.POST['affected_partner'], "affected_partner": request.POST['affected_partner'],
} }
st_r_id = None
try: try:
st_r_id = cs.affect_shift(data) st_r_id = cs.affect_shift(data)
except Exception as e: except Exception as e:
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<div class="management_type_buttons txtcenter"> <div class="management_type_buttons txtcenter">
<button type="button" class="btn--primary management_type_button" id="manage_makeups_button"> <button type="button" class="btn--primary management_type_button" id="manage_makeups_button">
Gestion des rattragapes Gestion des rattrapages
<span class="management_type_button_icons"><i class="fas fa-arrow-right"></i></span> <span class="management_type_button_icons"><i class="fas fa-arrow-right"></i></span>
</button><br> </button><br>
<button type="button" class="btn--primary management_type_button" id="manage_shift_registrations_button"> <button type="button" class="btn--primary management_type_button" id="manage_shift_registrations_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