[FIX] project_sms: fix sms failure

1. Install Contacts, Projects
2. Settings - Register account for SMS
3. Add the account with credit for IAP service with debug mode on
4. Create a Contact with mobile number and country from step 2
5. Go to Projects
- create a project and stages
- create SMS templates under Configuration
- under Task Stages, add sms template to each stages of the project
- on the task created, set the customer to what you created on step 3
- move the task from a stage to another

Issue:
- Lognote shows failed state when it is sent successfully
- On Settings/Technical/Discuss/Messages, record is duplicated

Resolve by:
- partiallly revert commit https://github.com/odoo/odoo/commit/5de1b941ce580253a21f0e4f6da0a8ca818f26b3

opw-3251410

closes odoo/odoo#118391

X-original-commit: c1a7e3c20244f45d49496db7d506bbf0fd96472a
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
Hansun (hale)
2023-04-13 05:07:55 +02:00
parent abdf22c9dc
commit 7618380c46
3 changed files with 12 additions and 3 deletions
@@ -13,7 +13,6 @@ class ProjectProject(models.Model):
project._message_sms_with_template(
template=project.stage_id.sms_template_id,
partner_ids=project.partner_id.ids,
sms_numbers=project.partner_id.mapped('mobile'),
)
@api.model_create_multi
@@ -13,7 +13,6 @@ class ProjectTask(models.Model):
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
@@ -44,7 +44,18 @@ class TestProjectSharingWithSms(TestProjectSharingCommon, SMSCommon):
'stage_id': self.task_stage_with_sms.id,
})
self.assertEqual(self.task_portal.stage_id, self.task_stage_with_sms)
self.assertSMSIapSent([self.task_portal.partner_id.mobile])
self.assertSMSIapSent([]) # no sms sent since the author is the recipient
self.task_portal.write({
'partner_id': self.user_projectuser.partner_id.id,
'stage_id': self.project_portal.type_ids[0].id,
})
with self.mockSMSGateway():
self.task_portal.with_user(self.user_portal).write({
'stage_id': self.task_stage_with_sms.id,
})
self.assertEqual(self.task_portal.stage_id, self.task_stage_with_sms)
self.assertSMSIapSent([self.user_projectuser.partner_id.mobile])
with self.mockSMSGateway():
self.project_portal.write({