Commit 52e4881c by François C.

#1774: current extensions are being closed when coop is being unsubscribe

parent 540be0cd
......@@ -21,8 +21,8 @@
<record forcecreate="True" id="cron_process_target_status" model="ir.cron">
<field name="name">Process coop target status</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">hours</field>
<field name="interval_number">5</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field name="doall" eval="True"/>
<field name="model" eval="'res.partner'"/>
......
......@@ -45,7 +45,6 @@ class ResPartner(models.Model):
"""Method called by cron task"""
# final_ftop_point, target_status
conf = self.env['ir.config_parameter']
absence_status = conf.get_param("lacagette_membership.absence_status")
makeups_todo_after_unsubscribed = conf.get_param("lacagette_membership.makeups_to_do_after_unsubscribed")
result = 'done'
for p in self.env['res.partner']\
......@@ -66,16 +65,24 @@ class ResPartner(models.Model):
unlink model: "shift.template.registration"
to delete all future shifts linked to this coop.
"""
now = datetime.datetime.now().isoformat()
for streg in self.env['shift.template.registration']\
.search([('partner_id', '=', p.id)]):
streg.unlink()
for sreg in self.env['shift.registration']\
.search([('partner_id', '=', p.id),
('date_begin', '>', datetime.datetime.now().isoformat())]):
('date_begin', '>', now)]):
sreg.unlink()
# 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})
mail_template = self.env.ref('coop_membership.unsubscribe_email')
if mail_template:
mail_template.send_mail(p.id)
mail_template.send_mail(p.id)
p.update(new_values)
except Exception as e:
_logger.error("run_process_target_status : %s", str(e))
......
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