[IMP] hr_presence: Don't notify followers when sending a email

This commit is contained in:
Yannick Tivisse
2018-11-07 16:30:29 +00:00
parent faf90c4f52
commit 32051efdc9
3 changed files with 11 additions and 9 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<data noupdate="1">
<record id="mail_template_presence" model="mail.template">
<field name="name">Presence: Contact Employee</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="model_id" ref="hr.model_hr_employee"/>
<field name="subject">Unexpected Absence</field>
<field name="email_from">${ctx['email_from'] or ''}</field>
<field name="email_to">${ctx['email_to'] or ''}</field>
+8 -6
View File
@@ -101,6 +101,7 @@ class ResCompany(models.Model):
self.write({'hr_presence_state': 'present'})
def action_send_sms(self):
self.ensure_one()
if not self.env.user.has_group('hr.group_hr_manager'):
raise UserError(_("You don't have the right to do this. Please contact an Administrator."))
if not self.mobile_phone:
@@ -113,7 +114,7 @@ Do not hesitate to contact your manager or the human resource department.""")
"res_model": "sms.send_sms",
"view_mode": 'form',
"context": {
'active_id': self.env.context.get('active_id'),
'active_id': self.id,
'default_message': body,
'default_recipients': self.mobile_phone,
},
@@ -122,22 +123,23 @@ Do not hesitate to contact your manager or the human resource department.""")
}
def action_send_mail(self):
self.ensure_one()
if not self.env.user.has_group('hr.group_hr_manager'):
raise UserError(_("You don't have the right to do this. Please contact an Administrator."))
employee = self.env['hr.employee'].sudo().browse(self.env.context.get('active_id'))
if not employee.work_email:
if not self.work_email:
raise UserError(_("There is no professional email address for this employee."))
template = self.env.ref('hr_presence.mail_template_presence', False)
compose_form = self.env.ref('mail.email_compose_message_wizard_form', False)
ctx = dict(
default_model='hr.employee',
default_res_id=employee.id,
default_model="hr.employee",
default_res_id=self.id,
default_use_template=bool(template),
default_template_id=template.id,
default_composition_mode='comment',
default_is_log=True,
custom_layout='mail.mail_notification_light',
email_from=self.env.user.email,
email_to=employee.work_email,
email_to=self.work_email,
)
return {
'name': _('Compose Email'),
@@ -25,8 +25,8 @@
<field name="hr_presence_state" invisible="1"/>
<button name="action_set_present" type="object" class="btn btn-primary btn-sm mt8 fa fa-check" title="Set as present" attrs="{'invisible': [('hr_presence_state', '!=', 'to_define')]}"> </button>
<button name="%(hr_holidays.hr_leave_action_all)d" type="action" class="btn btn-primary btn-sm mt8" context="{'default_employee_id': active_id}">Leaves</button>
<button name="action_send_sms" type="object" class="btn btn-primary btn-sm mt8" context="{'active_id': active_id}">SMS</button>
<button name="action_send_mail" type="object" class="btn btn-primary btn-sm mt8" context="{'active_id': active_id}">Mail</button>
<button name="action_send_sms" type="object" class="btn btn-primary btn-sm mt8">SMS</button>
<button name="action_send_mail" type="object" class="btn btn-primary btn-sm mt8">Mail</button>
</div>
</div>
</xpath>