Browse Source

[ADD] send (un)subscribed mail when worker is

changed.
12.0-macavrac-prod
odoo-pda 4 years ago
parent
commit
ddf9296b23
  1. 1
      macavrac_base/__manifest__.py
  2. 16
      macavrac_base/data/mail_template.xml
  3. 15
      macavrac_base/models/planning.py

1
macavrac_base/__manifest__.py

@ -9,6 +9,7 @@
"version": "12.0.1.0.0", "version": "12.0.1.0.0",
"depends": ["beesdoo_shift", "contacts"], "depends": ["beesdoo_shift", "contacts"],
"data": [ "data": [
"data/mail_template.xml",
"views/res_partner.xml", "views/res_partner.xml",
"views/shift.xml", "views/shift.xml",
], ],

16
macavrac_base/data/mail_template.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Mail template are declared in a NOUPDATE block
so users can freely customize/delete them -->
<data noupdate="1">
<record id="email_template_shift_subscribed" model="mail.template">
<field name="name">Shift Subscribed</field>
<field name="model_id" ref="model_beesdoo_shift_shift"/>
</record>
<record id="email_template_shift_unsubscribed" model="mail.template">
<field name="name">Shift Unsubscribed</field>
<field name="model_id" ref="model_beesdoo_shift_shift"/>
</record>
</data>
</odoo>

15
macavrac_base/models/planning.py

@ -62,6 +62,21 @@ class Task(models.Model):
rec.can_unsubscribe = True rec.can_unsubscribe = True
def write(self, vals):
if 'worker_id' in vals:
template_unsubscribed = self.env.ref("macavrac_base.email_template_shift_unsubscribed")
template_subscribed = self.env.ref("macavrac_base.email_template_shift_subscribed")
new_worker_id = self.env['beesdoo.shift.shift'].browse(vals.get('worker_id'))
for record in self:
old_worker_id = record.worker_id
if old_worker_id:
template_unsubscribed.send_mail(record.id)
if new_worker_id and old_worker_id != new_worker_id:
res = super(Task, record).write(vals)
template_subscribed.send_mail(record.id)
return super(Task, self).write(vals)
class CooperativeStatus(models.Model): class CooperativeStatus(models.Model):
_inherit = 'cooperative.status' _inherit = 'cooperative.status'

Loading…
Cancel
Save