Commit bd819db7 by Etienne Freiss

Merge branch 'fix-points-update-during-unsubscribe' into 'dev_cooperatic'

add points instead of forcing points counter when unbsuscribing partner

See merge request !18
parents d5e94325 aee62659
......@@ -56,11 +56,29 @@ class ResPartner(models.Model):
new_values['cooperative_state'] = p.target_status
if new_values['cooperative_state'] == "unsubscribed":
new_values['makeups_to_do'] = makeups_todo_after_unsubscribed
new_values['final_' + p.shift_type + '_point'] = -2
if p.shift_type == 'standard':
new_values['display_std_points'] = -2
# Get points difference to set points to -2
current_points = p['final_' + p.shift_type + '_point']
target_points = -2
points_diff = abs(current_points - target_points)
if points_diff != 0:
if current_points > target_points:
points_update = - points_diff
else:
new_values['display_ftop_points'] = -2
points_update = points_diff
data = {
'name': "Désinscription : passage à -2 pts",
'shift_id': False,
'type': p.shift_type,
'partner_id': p.id,
'point_qty': points_update
}
self.env['shift.counter.event'].create(data)
"""
unlink model: "shift.template.registration"
to delete all future shifts linked to this coop.
......@@ -73,16 +91,20 @@ class ResPartner(models.Model):
.search([('partner_id', '=', p.id),
('date_begin', '>', now)]):
sreg.unlink()
# Close extensions
# Close extensions
for ext in self.env['shift.extension']\
.search([('partner_id', '=', p.id),
('date_start', '<=', now),
('date_stop', '>=', now)]):
ext.update({'date_stop': now})
try:
mail_template = self.env.ref('coop_membership.unsubscribe_email')
if mail_template:
mail_template.send_mail(p.id)
except Exception as e:
_logger.error("run_process_target_status - send mail : %s - Process not interrupted", str(e))
p.update(new_values)
except Exception as e:
_logger.error("run_process_target_status : %s", str(e))
......@@ -148,7 +170,7 @@ class ResPartner(models.Model):
@api.multi
def update(self, vals):
_logger.info("valeurs reçues pour update partner = %s", str(vals))
_logger.info("valeurs recues pour update partner = %s", str(vals))
state_to_record = ""
if 'cooperative_state' in vals:
state_to_record = vals['cooperative_state']
......@@ -164,7 +186,7 @@ class ResPartner(models.Model):
@api.multi
def write(self, vals):
_logger.info("valeurs reçues pour write partner = %s", str(vals))
_logger.info("valeurs recues pour write partner = %s", str(vals))
if 'cooperative_state' in vals:
self._write_state_change(vals['cooperative_state'])
return super(ResPartner, self).write(vals)
......
......@@ -36,13 +36,13 @@ class ShiftCounterEvent(models.Model):
@api.model
def write(self, vals):
res = super(ShiftCounterEvent, self).write(vals)
_logger.info("Vals reçues = %s", str(vals))
_logger.info("Vals recues = %s", str(vals))
self._update_partner_target_status(vals)
return res
@api.model
def create(self, vals):
self._update_partner_target_status(vals)
_logger.info("Vals reçues creation = %s", str(vals))
_logger.info("Vals recues creation = %s", str(vals))
return super(ShiftCounterEvent, self).create(vals)
......@@ -12,7 +12,7 @@ class ShiftTemplateRegistrationLine(models.Model):
def create(self, vals):
super_res = super(ShiftTemplateRegistrationLine, self.with_context(
dict(self.env.context, **{'creation_in_progress': True}))).create(vals)
#_logger.info("valeurs reçues pour create shift.template.registration.line = %s", str(vals))
#_logger.info("valeurs recues pour create shift.template.registration.line = %s", str(vals))
if 'partner_id' in vals and 'shift_ticket_id' in vals:
conf = self.env['ir.config_parameter']
......
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