diff --git a/addons/project/tests/test_project_sharing_portal_access.py b/addons/project/tests/test_project_sharing_portal_access.py index e3cf97fc01709..cc8ca865ce515 100644 --- a/addons/project/tests/test_project_sharing_portal_access.py +++ b/addons/project/tests/test_project_sharing_portal_access.py @@ -24,7 +24,7 @@ def setUpClass(cls): 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 @@ def test_write_with_portal_user(self): 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') diff --git a/addons/project/tests/test_project_subtasks.py b/addons/project/tests/test_project_subtasks.py index 8753808a40c4b..b7dd7e8b8e060 100644 --- a/addons/project/tests/test_project_subtasks.py +++ b/addons/project/tests/test_project_subtasks.py @@ -307,3 +307,15 @@ def test_subtask_copy_display_in_project(self): 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')