Commit d6828972 by Yvon

in makeups screen, update points on ajax success to reflect real point change…

in makeups screen, update points on ajax success to reflect real point change now performed by more complex logic (this may also helps to detect a failure in ajax call)
parent 4def3c86
Pipeline #3049 failed with stage
in 1 minute 5 seconds
...@@ -409,6 +409,7 @@ def update_members_makeups_core(members_data, res): ...@@ -409,6 +409,7 @@ def update_members_makeups_core(members_data, res):
# Don't update if no change # Don't update if no change
if points_diff == 0: if points_diff == 0:
res["res"][-1]['standard_points'] = member_points
continue continue
if member_points > target_points: if member_points > target_points:
...@@ -425,6 +426,9 @@ def update_members_makeups_core(members_data, res): ...@@ -425,6 +426,9 @@ def update_members_makeups_core(members_data, res):
} }
cm.update_member_points(data) cm.update_member_points(data)
#There are some odoo process happening here that could change the actual number of points
#so we want to fetch it again to send it back
res["res"][-1]['standard_points'] = cm.get_member_points("standard")
# Better to call run_process_target_status now, otherwise partner remains # Better to call run_process_target_status now, otherwise partner remains
# in alert until routine is called (every 5 minutes). It is a bit weird for users and # in alert until routine is called (every 5 minutes). It is a bit weird for users and
# allocation of rattrapages before the routine is executed will not trigger change to delay state ! # allocation of rattrapages before the routine is executed will not trigger change to delay state !
......
...@@ -292,21 +292,6 @@ function update_members_makeups(member_ids, action, description) { ...@@ -292,21 +292,6 @@ function update_members_makeups(member_ids, action, description) {
} else { } else {
makeups_members[member_index].makeups_to_do -= 1; makeups_members[member_index].makeups_to_do -= 1;
} }
if (makeups_members[member_index].shift_type === 'standard') {
if (action === "increment") {
if (makeups_members[member_index].display_std_points >= -1)
makeups_members[member_index].display_std_points -= 1;
} else if (makeups_members[member_index].display_std_points < 0) {
makeups_members[member_index].display_std_points += 1;
}
} else {
if (action === "increment") {
if (makeups_members[member_index].display_ftop_points >= -1)
makeups_members[member_index].display_ftop_points -= 1;
} else {
makeups_members[member_index].display_ftop_points += 1;
}
}
data.push({ data.push({
member_id: mid, member_id: mid,
...@@ -325,8 +310,17 @@ function update_members_makeups(member_ids, action, description) { ...@@ -325,8 +310,17 @@ function update_members_makeups(member_ids, action, description) {
dataType:"json", dataType:"json",
traditional: true, traditional: true,
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
success: function() { success: function(res) {
selected_rows = []; selected_rows = [];
for (element of res['res']) {
member_index = makeups_members.findIndex(m => m.id == element['mid']);
if (makeups_members[member_index].shift_type === 'standard') {
makeups_members[member_index].display_std_points = element['standard_points']
}
//there is no point change when shift_type is not standard
//and I think operation on rattrapages should definitely be forbidden for ftop because it
//has no sense !!
}
display_makeups_members(); display_makeups_members();
closeModal(); closeModal();
}, },
......
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