Commit 3817e753 by Gwenaël Léger

Merge remote-tracking branch 'origin/migration-v12' into refonte_espace_membre_sc

parents a3741a77 b8648c03
Pipeline #3988 failed with stage
......@@ -854,8 +854,8 @@ def create_pair(request):
if child_makeups + parent_makeups <=2:
# on transfert les rattrapages sur le parent
# Comme on annule les services du suppléant, on ajoute en makeup_to_do du titulaire les rattrapages choisis ou non du suppléant
api.update("res.partner", [parent_id], {"makeups_to_do": parent['makeups_to_do'] + child_makeups})
# Comme on annule les services du suppléant, les makeup_to_do du titulaire seront affectés par la modification du compteur
# On annule les rattrapages du child
api.update('res.partner', [child_id], {"makeups_to_do": 0})
......@@ -866,15 +866,14 @@ def create_pair(request):
"type": child['shift_type'],
"partner_id": child_id,
"point_qty": 1})
# on retire les points au titulaire
# on retire les points au titulaire, les rattrages sont automatiquement ajoutés
api.create('shift.counter.event', {"name": 'passage en binôme',
"shift_id": False,
"type": parent['shift_type'],
"partner_id": parent_id,
"point_qty": -1})
elif child_makeups + parent_makeups > 2:
# on annule les rattrapages du suppléant et on met 2 rattrapages sur le titulaire
api.update('res.partner', [parent_id], {"makeups_to_do": 2})
# on annule les rattrapages du suppléant et les rattrapages du titulaire seront ajustés par les modifications de compteur
api.update('res.partner', [child_id], {"makeups_to_do": 0})
for makeup in range(child_makeups):
# reset du compteur du suppléant
......@@ -883,18 +882,16 @@ def create_pair(request):
"type": child['shift_type'],
"partner_id": child_id,
"point_qty": 1})
for i in range((parent_makeups + child_makeups) - 2):
for i in range(abs(parent_makeups - 2)):
# màj du compteur du titulaire
api.create('shift.counter.event', {"name": "passage en binôme",
"shift_id": False,
"type": parent['shift_type'],
"partner_id": parent_id,
"point_qty": -1})
# No more useful since status is fully managed by lacagette_addons modules
# api.execute('res.partner', 'run_process_target_status', [])
try:
api.execute('res.partner', 'run_process_target_status', [])
except:
pass
m = CagetteMember(child_id).unsubscribe_member()
# update child base account state
......
......@@ -859,20 +859,28 @@ class CagetteServices(models.Model):
canceled_reg_ids.append(int(r['id']))
# coop_logger.info("Traitement absences shift_registration ids %s", ids)
f = {'state': absence_status, 'date_closed': now.isoformat()}
update_shift_reg_result = {'update': api.update('shift.registration', ids, f), 'reg_shift': res, 'errors': []}
if update_shift_reg_result['update'] is True:
update_shift_reg_result['process_status_res'] = api.execute('res.partner','run_process_target_status', [])
# change shift state by triggering button_done method for all related shifts
if len(canceled_reg_ids) > 0:
f = {'state': 'cancel', 'date_closed': now.isoformat()}
api.update('shift.registration', canceled_reg_ids, f)
for sid in shift_ids:
try:
api.execute('shift.shift', 'button_done', sid)
except Exception as e:
marshal_none_error = 'cannot marshal None unless allow_none is enabled'
if not (marshal_none_error in str(e)):
update_shift_reg_result['errors'].append({'shift_id': sid, 'msg' :str(e)})
update_shift_reg_result = {'update': False, 'reg_shift': res, 'errors': []}
individual_update_result = {}
for mysregid in ids:
try:
individual_update_result[str(mysregid)] = api.update('shift.registration', [mysregid], f)
except Exception as e:
coop_logger.error("Error on updating shift.registration ids %s : %s", str(mysregid), str(e))
update_shift_reg_result['update'] = individual_update_result
# With new way of overriding awesomefoodcoop status management, the following line is no more useful
# update_shift_reg_result['process_status_res'] = api.execute('res.partner','run_process_target_status', [])
# change shift state by triggering button_done method for all related shifts
if len(canceled_reg_ids) > 0:
f = {'state': 'cancel', 'date_closed': now.isoformat()}
api.update('shift.registration', canceled_reg_ids, f)
for sid in shift_ids:
try:
api.execute('shift.shift', 'button_done', sid)
except Exception as e:
marshal_none_error = 'cannot marshal None unless allow_none is enabled'
if not (marshal_none_error in str(e)):
update_shift_reg_result['errors'].append({'shift_id': sid, 'msg' :str(e)})
return update_shift_reg_result
......
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