Commit b6d31ca5 by François C.

#1487 Clean all futur shifts, including extra shift template registration one

parent ca04e2c6
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
<field name="key">lacagette_membership.points_limit_to_get_unsubscribed</field> <field name="key">lacagette_membership.points_limit_to_get_unsubscribed</field>
<field name="value">-3</field> <field name="value">-3</field>
</record> </record>
<record id="makeups_to_do_after_unsubscribed" model="ir.config_parameter">
<field name="key">lacagette_membership.makeups_to_do_after_unsubscribed</field>
<field name="value">2</field>
</record>
<record id="absence_status" model="ir.config_parameter"> <record id="absence_status" model="ir.config_parameter">
<field name="key">lacagette_membership.absence_status</field> <field name="key">lacagette_membership.absence_status</field>
<field name="value">excused</field> <field name="value">excused</field>
......
...@@ -28,6 +28,7 @@ class ResPartner(models.Model): ...@@ -28,6 +28,7 @@ class ResPartner(models.Model):
# final_ftop_point, target_status # final_ftop_point, target_status
conf = self.env['ir.config_parameter'] conf = self.env['ir.config_parameter']
absence_status = conf.get_param("lacagette_membership.absence_status") 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' result = 'done'
for p in self.env['res.partner']\ for p in self.env['res.partner']\
.search([('target_status', '!=', "")]): .search([('target_status', '!=', "")]):
...@@ -37,7 +38,7 @@ class ResPartner(models.Model): ...@@ -37,7 +38,7 @@ class ResPartner(models.Model):
if final_points < 0: if final_points < 0:
new_values['cooperative_state'] = p.target_status new_values['cooperative_state'] = p.target_status
if new_values['cooperative_state'] == "unsubscribed": if new_values['cooperative_state'] == "unsubscribed":
new_values['makeups_to_do'] = 2 if absence_status == 'absent' else 1 new_values['makeups_to_do'] = makeups_todo_after_unsubscribed
new_values['final_' + p.shift_type + '_point'] = -2 new_values['final_' + p.shift_type + '_point'] = -2
if p.shift_type == 'standard': if p.shift_type == 'standard':
new_values['display_std_points'] = -2 new_values['display_std_points'] = -2
...@@ -50,7 +51,10 @@ class ResPartner(models.Model): ...@@ -50,7 +51,10 @@ class ResPartner(models.Model):
for streg in self.env['shift.template.registration']\ for streg in self.env['shift.template.registration']\
.search([('partner_id', '=', p.id)]): .search([('partner_id', '=', p.id)]):
streg.unlink() streg.unlink()
for sreg in self.env['shift.registration']\
.search([('partner_id', '=', p.id),
('date_begin', '>', datetime.datetime.now().isoformat())]):
sreg.unlink()
mail_template = self.env.ref('coop_membership.unsubscribe_email') mail_template = self.env.ref('coop_membership.unsubscribe_email')
if mail_template: if mail_template:
mail_template.send_mail(p.id) mail_template.send_mail(p.id)
......
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