diff --git a/addons/project/controllers/portal.py b/addons/project/controllers/portal.py index 3908605d527..fd89e92f0d3 100644 --- a/addons/project/controllers/portal.py +++ b/addons/project/controllers/portal.py @@ -147,7 +147,7 @@ class ProjectCustomerPortal(CustomerPortal): project_company = project.company_id session_info.update( cache_hashes=cache_hashes, - action_name='project.project_sharing_project_task_action', + action_name=project.action_project_sharing(), project_id=project.id, user_companies={ 'current_company': project_company.id, diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 46262d3e874..6f289f7d83f 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -12,7 +12,7 @@ from odoo import api, Command, fields, models, tools, SUPERUSER_ID, _, _lt from odoo.addons.rating.models import rating_data from odoo.exceptions import UserError, ValidationError, AccessError from odoo.osv import expression -from odoo.tools.misc import get_lang +from odoo.tools.misc import get_lang, format_date from .project_task_recurrence import DAYS, WEEKS from .project_update import STATUS_COLOR @@ -761,6 +761,12 @@ class Project(models.Model): action['display_name'] = _("%(name)s's Updates", name=self.name) return action + def action_project_sharing(self): + self.ensure_one() + action = self.env['ir.actions.act_window']._for_xml_id('project.project_sharing_project_task_action') + action['display_name'] = self.name + return action + def toggle_favorite(self): favorite_projects = not_fav_projects = self.env['project.project'].sudo() for project in self: @@ -1046,7 +1052,7 @@ class Task(models.Model): _date_name = "date_assign" _inherit = ['portal.mixin', 'mail.thread.cc', 'mail.activity.mixin', 'rating.mixin'] _mail_post_access = 'read' - _order = "priority desc, sequence, id desc" + _order = "priority desc, date_deadline asc, sequence, id desc" _primary_email = 'email_from' _check_company_auto = True @@ -1502,7 +1508,9 @@ class Task(models.Model): else: recurrence_title = _('A new task will be created on the following dates:') task.recurrence_message = '

%s

' diff --git a/addons/project/tests/test_project_recurrence.py b/addons/project/tests/test_project_recurrence.py index cde7d0eb537..f122adcd9ab 100644 --- a/addons/project/tests/test_project_recurrence.py +++ b/addons/project/tests/test_project_recurrence.py @@ -99,7 +99,7 @@ class TestProjectrecurrence(TransactionCase): tasks = self.env['project.task'].search(domain) self.assertEqual(len(tasks), 3) - self.assertTrue(bool(tasks[2].date_deadline)) + self.assertTrue(bool(tasks[0].date_deadline)) self.assertFalse(tasks[1].date_deadline, "Deadline should not be copied") for f in self.env['project.task.recurrence']._get_recurring_fields(): @@ -143,7 +143,7 @@ class TestProjectrecurrence(TransactionCase): tasks = self.env['project.task'].search(domain) self.assertEqual(len(tasks), 3) - self.assertTrue(bool(tasks[2].date_deadline)) + self.assertTrue(bool(tasks[0].date_deadline)) self.assertFalse(tasks[1].date_deadline, "Deadline should not be copied") for f in self.env['project.task.recurrence']._get_recurring_fields(): @@ -200,7 +200,7 @@ class TestProjectrecurrence(TransactionCase): tasks = self.env['project.task'].search(domain) self.assertEqual(len(tasks), 4) - self.assertTrue(bool(tasks[3].date_deadline)) + self.assertTrue(bool(tasks[0].date_deadline)) self.assertFalse(tasks[1].date_deadline, "Deadline should not be copied") for f in self.env['project.task.recurrence']._get_recurring_fields(): @@ -612,8 +612,7 @@ class TestProjectrecurrence(TransactionCase): tasks = self.env['project.task'].search(domain) self.assertEqual(len(tasks), 4) - - self.assertTrue(bool(tasks[2].date_deadline)) + self.assertTrue(bool(tasks[0].date_deadline)) self.assertFalse(tasks[1].date_deadline, "Deadline should not be copied") for f in self.env['project.task.recurrence']._get_recurring_fields(): @@ -778,10 +777,10 @@ class TestProjectrecurrence(TransactionCase): all_tasks = self.env['project.task'].search(domain) self.assertEqual(len(all_tasks), 21) deadlines = all_tasks.sorted('create_date').mapped('date_deadline') - self.assertTrue(bool(deadlines[-4])) - self.assertTrue(bool(deadlines[-3])) - del deadlines[-4] - del deadlines[-3] + self.assertTrue(bool(deadlines[0])) + self.assertTrue(bool(deadlines[1])) + del deadlines[1] + del deadlines[0] self.assertTrue(not any(deadlines), "Deadline should not be copied") bottom_genealogy = all_tasks.filtered(lambda t: not t.child_ids.exists()) @@ -789,6 +788,5 @@ class TestProjectrecurrence(TransactionCase): self.assertEqual(bottom_genealogy_name.count('Child task 1'), 1) self.assertEqual(bottom_genealogy_name.count('Grandchild task 1 (recurrent)'), 10) self.assertEqual(bottom_genealogy_name.count('Grandchild task 5'), 1) - for f in self.env['project.task.recurrence']._get_recurring_fields(): - self.assertTrue(all_tasks[0][f] == all_tasks[1][f] == all_tasks[2][f], "Field %s should have been copied" % f) + self.assertTrue(all_tasks[2][f] == all_tasks[3][f] == all_tasks[4][f], "Field %s should have been copied" % f)