Commit 2804d911 by François C.

Merge branch 'ticket_3968' into 'dev_cooperatic'

Allow other name for commitee shift template (equivalent for Supercoop)

See merge request !216
parents e5d02715 1a6574de
dev_cooperatic #5673_bug_calendrier_echange_service 4081 4444_improve_presence_recording 4709 4778-reception-dont-get-finished-orders 4809-remove-shelf-value-col-to-reduce-server-load 4880-rapports-reception-faux 4950-douchage-appli-reception 5474-et-5462-Voir-les-rattrapages-choisis-dans-admin-bdm-et-corrige-lenteur-affichage-admin-rattrapages 5641-reception-trier-a-la-maj-prix-dans-ordre-de-pointage-quantites 6286_bug_encaissement_souscription_cheque_espece 6813-marking-parent-gone-when-unpairing-binom-does-not-unsuscribe-parent-from-shift-template 6832--certaines-absences-engendrent-une-erreur 7723-7559-change-purchase-order-workflow-django-side 7731-third-party-side-brinks-pos-export-not-working 7747-inventaire-par-article 7800-make-test-solution-work 7848-cannot-validate-qty-with-decimal-on-kg-product 7918_bug_quantites_stade_demande_prix adpatation_chouette assistance_import_article coop_dev_necessitant_modules_bdm_odoo_modifies correctif_nb_rattrapages_creation_binome_avec_ajout_automatique_au_point_negatif export_capital_detenu fix_bug_process_picking fusion_custom_graoucoop graoucoop_backup graoucoop_prod graoucoop_tmp hot_fix_shelf_labels_auto_print impression_etiquettes_rayons integration_lien_precommandes_dans_espace_membre lacagette_prod local_branch meal-voucher-and-label-printer-software-bug migration-v12 pour_graoucoop_prod pour_version_prod_cagette refonte_espace_membre_sc retouches_tickets_supercoop sc-setup-stock-app supercafoutch-preprod supercafoutch-prod-20221003 supercafoutch_prod ticket_4146 supercafoutch_20250120_151258 supercafoutch_20250120_150340 supercafoutch_20240909_080630 supercafoutch_20240609_115709 supercafoutch_20240212_082431 supercafoutch_20240107_181851 supercafoutch_prod_until_240107 supercafoutch-230911 supercafoutch-230824 supercafoutch-230823-the-true-one migration-v12-tag lacagette_20240310_074751 lacagette_20240107_122554 lacagette_20240107_120916 graoucoop_20240609_122614 cagette_testtag cagette-230814 cagette-230630
1 merge request!218Ticket 4292
Pipeline #2467 passed with stage
in 1 minute 25 seconds
......@@ -346,6 +346,7 @@ def manage_regular_shifts(request):
""" Administration des créneaux des membres """
template = loader.get_template('members/admin/manage_regular_shifts.html')
committees_shift_id = CagetteServices.get_committees_shift_id()
committees_shift_name = getattr(settings, 'COMMITTEES_SHIFT_NAME', "service des Comités")
context = {
'title': 'BDM - Créneaux',
'module': 'Membres',
......@@ -357,6 +358,7 @@ def manage_regular_shifts(request):
'show_ftop_button': getattr(settings, 'BDM_SHOW_FTOP_BUTTON', True),
'has_committe_shift': committees_shift_id is not None,
'committees_shift_id': committees_shift_id,
'committees_shift_name': committees_shift_name,
'ASSOCIATE_MEMBER_SHIFT' : getattr(settings, 'ASSOCIATE_MEMBER_SHIFT', '')
}
return HttpResponse(template.render(context, request))
......@@ -582,7 +584,6 @@ def shift_subscription(request):
# First try to get committees shift
shift_template_id = CagetteServices.get_committees_shift_id()
# 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()
......@@ -604,19 +605,22 @@ def shift_subscription(request):
)
res["unsubscribe_member"] = m.unsubscribe_member(changing_shift = True)
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
api = OdooAPI()
c = [['id', '=', shift_template_id]]
f = ['id', 'name']
res["shift_template"] = api.search_read('shift.template', c, f)[0]
c = [['id', '=', partner_id]]
f = ['cooperative_state']
res["cooperative_state"] = api.search_read('res.partner', c, f)[0]['cooperative_state']
response = JsonResponse(res)
if reg_id is not None:
api = OdooAPI()
c = [['id', '=', shift_template_id]]
f = ['id', 'name']
res["shift_template"] = api.search_read('shift.template', c, f)[0]
c = [['id', '=', partner_id]]
f = ['cooperative_state']
res["cooperative_state"] = api.search_read('res.partner', c, f)[0]['cooperative_state']
coop_logger.info("Resultat shift_subscription : %s (données reçues = %s)", str(res), str(data))
response = JsonResponse(res)
else:
response = JsonResponse({"message": "Subscription failed"}, status=500)
else:
response = JsonResponse({"message": "Unauthorized"}, status=403)
......
......@@ -317,7 +317,7 @@ class CagetteMember(models.Model):
[invoice_id])
return [invoice_id, invoice_line_id]
def create_coop_shift_subscription(self, shift_t_id, stype):
def create_coop_shift_subscription(self, shift_t_id, stype, call_nb=1):
"""Store coop shift subscription."""
# Get shift template ticket corresponding to given shift temp. id
sti = None
......@@ -345,8 +345,12 @@ class CagetteMember(models.Model):
}
st_r_id = self.o_api.create('shift.template.registration',
st_r_fields)
except:
st_r_id = None
except Exception as ex:
if 'seules les inscriptions ABCD sont possibles' in str(ex) and call_nb < 2:
return self.create_coop_shift_subscription(shift_t_id, 1, call_nb + 1)
else:
coop_logger.error("Error while creating shift.template.registration : %s, (fields =%s)", str(ex), str(st_r_fields))
st_r_id = None
return st_r_id
......
......@@ -193,7 +193,7 @@ function set_subscription_area() {
$(document).on("click", "#shifts_calendar_area button[data-select='Volant']", function() {
// Subscribe to comitee/ftop shift
msg = (has_committe_shift === "True")
? `Inscrire ${selected_member.name} au service des Comités ?`
? `Inscrire ${selected_member.name} au ${committees_shift_name} ?`
: `Inscrire ${selected_member.name} en Volant ?`;
openModal(
......@@ -281,7 +281,7 @@ $(document).ready(function() {
$(".page_content").show();
if (has_committe_shift === "True") {
$("#shifts_calendar_area button[data-select='Volant']").text("Comités");
$("#shifts_calendar_area button[data-select='Volant']").text(committees_shift_name);
}
// Set action to search for the member
......
......@@ -354,6 +354,9 @@
By default 1. Extension type id (from shift_extension_type table) used to create extension
- COMMITTEES_SHIFT_NAME = 'Coolisses'
By default "service des Comités"
### Reception
- RECEPTION_ADD_ADMIN_MODE = True
......
......@@ -447,7 +447,10 @@ function shift_loc_selection() {
if (clicked.data('select') != 'Volant') {
retrieve_and_draw_shift_tempates();
} else {
subscribe_shift(volant);
//shift_templates[volant] is not always set (when call from bdm interface)
if (typeof volant !== "undefined" && typeof shift_templates[volant] !== "undefined") {
subscribe_shift(volant);
}
}
}
......
......@@ -96,6 +96,7 @@
var couchdb_dbname = '{{db}}';
var couchdb_server = '{{couchdb_server}}' + couchdb_dbname;
var committees_shift_id = '{{committees_shift_id}}';
const committees_shift_name = '{{committees_shift_name}}';
var ASSOCIATE_MEMBER_SHIFT = '{{ASSOCIATE_MEMBER_SHIFT}}';
</script>
<script src='{% static "js/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