Files
odoo_source/addons/project_sms/models/project_task.py
T
Audric Onockx (auon) 4b3a8b4f7a [FIX] project_sms: send sms, but for real
`/project_sms:ProjectTask._send_sms` called `_message_sms_with_template`
without numbers, and so no sms was sent.
Now, we give the method an `sms_numbers` arg, and it works.

closes odoo/odoo#116514

X-original-commit: 5de1b941ce580253a21f0e4f6da0a8ca818f26b3
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2023-03-25 18:58:00 +01:00

35 lines
1.0 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
class ProjectTask(models.Model):
_inherit = "project.task"
def _send_sms(self):
for task in self:
if task.partner_id and task.stage_id and task.stage_id.sms_template_id:
task._message_sms_with_template(
template=task.stage_id.sms_template_id,
partner_ids=task.partner_id.ids,
sms_numbers=task.partner_id.mapped('mobile'),
)
@api.model_create_multi
def create(self, vals_list):
tasks = super().create(vals_list)
tasks._send_sms()
return tasks
def write(self, vals):
res = super().write(vals)
if 'stage_id' in vals:
if self.env.user.has_group('base.group_portal') and not self.env.su:
# sudo as sms template model is protected
self.sudo()._send_sms()
else:
self._send_sms()
return res