Files
odoo_source/addons/project_sms/tests/test_project_sharing.py
T
Hansun (hale) 7618380c46 [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>
2023-04-13 05:07:55 +02:00

66 lines
2.8 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import Command
from odoo.addons.project.tests.test_project_sharing import TestProjectSharingCommon
from odoo.addons.sms.tests.common import SMSCommon
class TestProjectSharingWithSms(TestProjectSharingCommon, SMSCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
project_settings = cls.env["res.config.settings"].create({'group_project_stages': True})
project_settings.execute()
cls.sms_template = cls.env['sms.template'].sudo().create({
'body': '{{ object.name }}',
'model_id': cls.env['ir.model'].sudo().search([('model', '=', 'project.task')]).id,
})
cls.task_stage_with_sms = cls.project_portal.type_ids[-1]
cls.task_stage_with_sms.write({'sms_template_id': cls.sms_template.id})
cls.sms_template_2 = cls.env['sms.template'].sudo().create({
'body': '{{ object.name }}',
'model_id': cls.env['ir.model'].sudo().search([('model', '=', 'project.project')]).id,
})
cls.project_stage_with_sms = cls.project_portal.stage_id.browse(2)
cls.project_stage_with_sms.write({'sms_template_id': cls.sms_template_2.id})
cls.project_portal.write({
'collaborator_ids': [
Command.create({'partner_id': cls.user_portal.partner_id.id}),
],
})
cls.project_portal.partner_id.mobile = cls.random_numbers[0]
def test_portal_user_can_change_stage_with_sms_template(self):
""" Test user portal can change the stage of a task to a stage with a sms template
The sms template should be sent and the stage should be changed on the task.
"""
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([]) # 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({
'stage_id': self.project_stage_with_sms.id,
})
self.assertEqual(self.project_portal.stage_id, self.project_stage_with_sms)
self.assertSMSIapSent([self.project_portal.partner_id.mobile])