Commit 1b055b5c by François C.

dérivé de #7054 : modifications pour préserver l'historique des services à la désincription

parent 2bb6880e
......@@ -42,7 +42,7 @@ class ShiftCounterEvent(models.Model):
if res_partner:
p = res_partner[0]
if p.final_standard_point == suspension_limit and p.shift_type != "ftop":
_logger.info("Le nombre de points est la limite pour être suspendu, et membre ABCD, on va chercher à ajuster les points")
_logger.debug("Le nombre de points est la limite pour être suspendu, et membre ABCD, on va chercher à ajuster les points")
cond = [
['name', '=', p["name"]],
['shift_type', '=', 'standard'],
......@@ -76,7 +76,7 @@ class ShiftCounterEvent(models.Model):
'working_state': 'unsubscribed', 'cooperative_state': 'unsubscribed'}
# Get points difference to set points to unsubscribe_limit - 1
_logger.info("unsubscribe_partner : current_points = %s", str(current_points))
_logger.debug("unsubscribe_partner : partner = %s, current_points = %s", partner.display_name, str(current_points))
target_points = unsubscribe_limit + 1
points_diff = abs(current_points - target_points)
if points_diff != 0:
......@@ -101,10 +101,12 @@ class ShiftCounterEvent(models.Model):
"""
now = datetime.datetime.now().isoformat()
for streg in self.env['shift.template.registration'].search([('partner_id', '=', partner.id)]):
_logger.debug("unlink shift.template.registration = %s", str(streg))
streg.unlink()
for sreg in self.env['shift.registration']\
.search([('partner_id', '=', partner.id),
('date_begin', '>', now)]):
_logger.debug("unling shift_registration = %s", str(sreg))
sreg.unlink()
# Close extensions
......@@ -160,7 +162,7 @@ class ShiftCounterEvent(models.Model):
to_consider_vals = vals # TODO : Reimplement this adjustments
if res_partner:
partner = res_partner[0]
_logger.info("partner = : %s, makeups_to_do : %s", str(partner), str(partner.makeups_to_do))
_logger.debug("partner = : %s, makeups_to_do : %s", str(partner), str(partner.makeups_to_do))
if to_consider_vals['type'] != partner.shift_type:
_logger.error("Counter shift type is not corresponding to partner shift_type : %s", str(to_consider_vals))
return None
......
......@@ -21,8 +21,13 @@ class ShiftTemplateRegistration(models.Model):
@api.multi
def unlink(self):
partners_to_update = []
partner_ids = []
for reg in self:
partners_to_update.append(reg.partner_id)
partner_ids.append(int(reg.partner_id.id))
# remove tmpl_reg_line_id for all shift_registrations to prevent them to be deleted (keep shift history)
self.env['shift.registration'].search([('partner_id', 'in', partner_ids)])\
.write({'tmpl_reg_line_id' : False})
super_res = super(ShiftTemplateRegistration, self).unlink()
for p in partners_to_update:
p.recompute_member_states()
......
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