Skip to content

Commit

Permalink
[IMP] project: write tests subtasks unlinking/portal create user
Browse files Browse the repository at this point in the history
Task-3460027

closes odoo#135266

Signed-off-by: Xavier Bol (xbo) <[email protected]>
  • Loading branch information
bastvdn committed Oct 17, 2023
1 parent 55f4610 commit ddd380e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
30 changes: 29 additions & 1 deletion addons/project/tests/test_project_sharing_portal_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -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': '[email protected]',
'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')
12 changes: 12 additions & 0 deletions addons/project/tests/test_project_subtasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

0 comments on commit ddd380e

Please sign in to comment.