Commit a8cc5d42 by Damien Moulard

fix makeups errors

parent edafd2a3
......@@ -61,6 +61,22 @@ class CagetteMember(models.Model):
image = res[0]['image_medium']
return image
# def update_member_points(self, status):
# fields = {'name': reason,
# 'shift_id': False,
# 'type': stype,
# 'partner_id': self.id,
# 'point_qty': pts
# }
# return self.o_api.create('shift.counter.event', fields)
# if status not in ["suspended", "delay", "up_to_date", "unsuscribed", "alert"]:
# raise Exception("Bad status")
# f = { 'cooperative_state': "delay" }
# return self.o_api.update('res.partner', [self.id], f)
@staticmethod
def retrieve_data_according_keys(keys, full=False):
api = OdooAPI()
......
......@@ -11,12 +11,13 @@ class CagetteMembersSpace(models.Model):
"""Init with odoo id."""
self.o_api = OdooAPI()
def get_points_history(self, partner_id, limit, offset, date_from):
def get_points_history(self, partner_id, limit, offset, date_from, shift_type):
""" Get partner points history with related shift registration if needed """
cond = [
['partner_id', '=', partner_id],
['type', '=', 'ftop'],
['create_date', '>', date_from]
['type', '=', shift_type],
['create_date', '>', date_from],
['point_qty', '!=', 0]
]
f = ['create_date', 'create_uid', 'shift_id', 'name', 'point_qty']
......
......@@ -30,7 +30,8 @@ function request_delay() {
verif_token: partner_data.verif_token,
idPartner: partner_data.partner_id,
start_date: delay_start,
duration: diff_days
duration: diff_days,
shift_type: (partner_data.in_ftop_team === "True") ? "ftop" : "standard"
},
success: function() {
partner_data.cooperative_state = 'delay';
......
......@@ -14,7 +14,8 @@ function load_partner_history(offset = 0) {
partner_id: partner_data.concerned_partner_id,
verif_token: partner_data.verif_token,
limit: history_items_limit,
offset: offset
offset: offset,
shift_type: (partner_data.in_ftop_team === "True") ? "ftop" : "standard"
},
dataType:"json",
traditional: true,
......
......@@ -271,6 +271,16 @@ function init_calendar_page() {
);
} else if (can_select_makeup()) {
/* choose a makeup service */
// Check if selected new shift is in less than 6 months
if (partner_data.date_delay_stop !== 'False') {
date_partner_delay_stop = new Date(partner_data.date_delay_stop);
if ( datetime_new_shift > date_partner_delay_stop ) {
let msg = `Vous avez jusqu'au ${date_partner_delay_stop.toLocaleDateString("fr-fr", date_options)} ` +
`pour sélectionner un rattrapage (soit une période de 6 mois depuis votre absence).`;
alert(msg);
return;
}
}
let modal_template = $("#modal_add_shift_template");
modal_template.find(".date_new_shift").text(new_shift_date);
......
......@@ -160,7 +160,8 @@ def get_points_history(request):
limit = int(request.GET.get('limit'))
offset = int(request.GET.get('offset'))
shift_type = request.GET.get('shift_type')
date_from = getattr(settings, 'START_DATE_FOR_POINTS_HISTORY', '2018-01-01')
res["data"] = m.get_points_history(partner_id, limit, offset, date_from)
res["data"] = m.get_points_history(partner_id, limit, offset, date_from, shift_type)
return JsonResponse(res)
\ No newline at end of file
......@@ -3,6 +3,7 @@ from outils.for_view_imports import *
from outils.common import Verification
from shifts.models import CagetteShift
from members.models import CagetteMember
# working_state = ['up_to_date', 'alert', 'exempted', 'delay', 'suspended']
state_shift_allowed = ["up_to_date", "alert", "delay"]
......@@ -289,6 +290,16 @@ def request_delay(request):
try:
new_id = cs.create_delay(data, duration)
if (new_id):
try:
if ('shift_type' in request.POST):
shift_type = request.POST['shift_type']
# This is a hack to ensure that the coop goes in delay state when a delay is created
cm = CagetteMember(int(request.POST['idPartner']))
res_addpt = cm.add_pts(shift_type, 0, "[fo] passage en délai")
except Exception as e:
coop_logger.error("force_delay_status : %s, %s", str(e), str(data))
response = {'result': True}
else:
coop_logger.error("request delay : %s, %s", str(new_id), str(data))
......
......@@ -62,16 +62,8 @@
"partner_id":"{{partnerData.id}}",
"name":"{{partnerData.display_name}}",
"in_ftop_team":"{{partnerData.in_ftop_team}}",
"final_standard_point":"{{partnerData.final_standard_point}}",
"final_ftop_point":"{{partnerData.final_ftop_point}}",
"date_delay_stop":"{{partnerData.date_delay_stop}}",
"date_alert_stop":"{{partnerData.date_alert_stop}}",
"cooperative_state":"{{partnerData.cooperative_state}}",
"is_leave": "{{partnerData.is_leave}}",
"leave_start_date": "{{partnerData.leave_start_date}}",
"leave_stop_date": "{{partnerData.leave_stop_date}}",
"next_regular_shift_date": "{{partnerData.next_regular_shift_date}}",
"regular_shift_name": "{{partnerData.regular_shift_name}}",
"verif_token" : "{{partnerData.verif_token}}",
"makeups_to_do" : "{{partnerData.makeups_to_do}}",
"barcode_base" : "{{partnerData.barcode_base}}",
......
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