[IMP] project: write tests subtasks unlinking/portal create user

Task-3460027

closes odoo/odoo#135266

Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
Bastien (bvdn)
2023-10-17 08:53:04 +00:00
parent 55f461060e
commit ddd380edb0
2 changed files with 41 additions and 1 deletions
@@ -24,7 +24,7 @@ class TestProjectSharingPortalAccess(TestProjectSharingCommon):
Command.link(cls.partner_portal.id),
],
})
project_share_wizard.action_send_mail()
project_share_wizard.action_share_record()
Task = cls.env['project.task']
cls.read_protected_fields_task = OrderedDict([
@@ -76,3 +76,31 @@ class TestProjectSharingPortalAccess(TestProjectSharingCommon):
for field in self.other_fields_task:
with self.assertRaises(AccessError):
self.task_portal.with_user(self.user_portal).write({field: 'dummy'})
def test_wizard_confirm(self):
partner_portal_no_user = self.env['res.partner'].create({
'name': 'NoUser portal',
'email': 'no@user.portal',
'company_id': False,
'user_ids': [],
})
project_share_wizard_no_user = self.env['project.share.wizard'].create({
'access_mode': 'edit',
'res_model': 'project.project',
'res_id': self.project_portal.id,
'partner_ids': [
Command.link(partner_portal_no_user.id),
],
})
self.env["res.config.settings"].create({"auth_signup_uninvited": 'b2b'}).execute()
project_share_wizard_no_user_action = project_share_wizard_no_user.action_share_record()
self.assertEqual(project_share_wizard_no_user_action['type'], 'ir.actions.act_window', 'Sharing a project with partner without user should display a confimation dialog')
project_share_wizard_confirmation = self.env['project.share.wizard'].browse(project_share_wizard_no_user_action['res_id'])
project_share_wizard_confirmation.action_send_mail()
mail_partner = self.env['mail.message'].search([('partner_ids', '=', partner_portal_no_user.id)], limit=1)
self.assertTrue(mail_partner, 'A mail should have been sent to the non portal user')
self.assertIn('href="http://localhost:8069/web/signup', str(mail_partner.body), 'The message link should contain the url to register to the portal')
self.assertIn('token=', str(mail_partner.body), 'The message link should contain a personalized token to register to the portal')
@@ -307,3 +307,15 @@ class TestProjectSubtasks(TestProjectCommon):
self.assertEqual(len(project_copy.task_ids.child_ids), 4)
subtask_not_display_in_project_copy = project_copy.task_ids.child_ids.filtered(lambda t: not t.display_in_project)
self.assertEqual(len(subtask_not_display_in_project_copy), 4, "No subtask should be displayed in the duplicate project")
def test_subtask_unlinking(self):
task_form = Form(self.task_1.with_context({'tracking_disable': True}))
with task_form.child_ids.new() as child_task_form:
child_task_form.name = 'Test Subtask 1'
child_task_form.project_id = task_form.project_id
task_form.save()
child_subtask = self.task_1.child_ids[0]
self.task_1.unlink()
self.assertFalse(self.task_1.exists())
self.assertFalse(child_subtask.exists(), 'Subtask should be removed if the parent task has been deleted')