Commit f4db68f7 by root

Modifications pour envoi mail de désinscription

parent 1964bd13
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# #
'category': 'Uncategorized', 'category': 'Uncategorized',
'version': '0.0.5', 'version': '0.0.6',
# any module necessary for this one to work correctly # any module necessary for this one to work correctly
'depends': ['base', 'coop_membership', 'coop_shift'], 'depends': ['base', 'coop_membership', 'coop_shift'],
......
<?xml version="1.0"?> <?xml version="1.0"?>
<odoo noupdate="0"> <odoo noupdate="1">
<record id="points_limit_to_get_suspended" model="ir.config_parameter"> <record id="points_limit_to_get_suspended" model="ir.config_parameter">
<field name="key">lacagette_membership.points_limit_to_get_suspended</field> <field name="key">lacagette_membership.points_limit_to_get_suspended</field>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
Author : fracolo Author : fracolo
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
--> -->
<odoo> <odoo noupdate="1">
<record forcecreate="True" id="cron_close_unnecessary_extensions" model="ir.cron"> <record forcecreate="True" id="cron_close_unnecessary_extensions" model="ir.cron">
<field name="name">Close unnecessary Extensions</field> <field name="name">Close unnecessary Extensions</field>
<field name="user_id" ref="base.user_root" /> <field name="user_id" ref="base.user_root" />
......
...@@ -36,6 +36,8 @@ class ResPartner(models.Model): ...@@ -36,6 +36,8 @@ class ResPartner(models.Model):
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'] = 2 if absence_status == 'absent' else 1
new_values['final_ftop_point'] = -2
new_values['display_ftop_points'] = -2
""" """
unlink model: "shift.template.registration" unlink model: "shift.template.registration"
to delete all future shifts linked to this coop. to delete all future shifts linked to this coop.
...@@ -43,7 +45,9 @@ class ResPartner(models.Model): ...@@ -43,7 +45,9 @@ 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()
mail_template = self.env.ref('coop_membership.unsubscribe_email')
if mail_template:
mail_template.send_mail(p.id)
p.update(new_values) p.update(new_values)
#@api.onchange('cooperativestate') : could be used only if it is called from client #@api.onchange('cooperativestate') : could be used only if it is called from client
...@@ -106,8 +110,10 @@ class ResPartner(models.Model): ...@@ -106,8 +110,10 @@ class ResPartner(models.Model):
elif 'current_cooperative_state' in vals: elif 'current_cooperative_state' in vals:
state_to_record = vals['current_cooperative_state'] state_to_record = vals['current_cooperative_state']
del vals['current_cooperative_state']
if len(state_to_record) > 0: if len(state_to_record) > 0:
self._write_state_change(state_to_record) self._write_state_change(state_to_record)
return super(ResPartner, self).update(vals) return super(ResPartner, self).update(vals)
@api.model @api.model
......
...@@ -19,15 +19,14 @@ class ShiftRegistration(models.Model): ...@@ -19,15 +19,14 @@ class ShiftRegistration(models.Model):
@api.multi @api.multi
def write(self, vals): def write(self, vals):
res = super(ShiftRegistration, self).write(vals)
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")
if 'state' in vals and vals['state'] == absence_status: if 'state' in vals and vals['state'] == absence_status:
if self.ids: if self.ids:
# it is the case when called from "absence cron job" run in external third-party # it is the case when called from "absence cron job" run in external third-party
to_add = conf.get_param("lacagette_membership.makeups_to_do_on_shift_missed") to_add = 2 if absence_status == 'absent' else 1
for s in self.env['shift.registration']\ for s in self.env['shift.registration']\
.search([('id', 'in', self.ids)]): .search([('id', 'in', self.ids)]):
new_makeups_to_do = s.partner_id.makeups_to_do + to_add new_makeups_to_do = s.partner_id.makeups_to_do + to_add
s.partner_id.update({'makeups_to_do': new_makeups_to_do}) s.partner_id.update({'makeups_to_do': new_makeups_to_do})
return res return super(ShiftRegistration, self).write(vals)
\ No newline at end of file \ No newline at end of file
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