[IMP] project: improve recurrence notebook and project sharing
Description of the features in this PR: add the date deadline to the order of tasks (sort priority) add the day of the week (only the first 3 letters) for the recurrence message in recurrent tasks display the name of the project in the action instead of 'Project Sharing' By changing the sorting order of the Project.Task model some indexations in the tests didn't point to the right tasks Now each task that has a deadline will be placed in front of other tasks (except for the high priority task) Task-3034635 closes odoo/odoo#105701 Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 = '<p><span class="fa fa-check-circle"></span> %s</p><ul>' % recurrence_title
|
||||
task.recurrence_message += ''.join(['<li>%s</li>' % date.strftime(date_format) for date in recurring_dates[:5]])
|
||||
task.recurrence_message += ''.join(['<li>%s %s</li>' % (
|
||||
format_date(self.env, date, date_format="EEE"), date.strftime(date_format)
|
||||
) for date in recurring_dates[:5]])
|
||||
if task.repeat_type == 'after' and recurrence_left > 5 or task.repeat_type == 'forever' or len(recurring_dates) > 5:
|
||||
task.recurrence_message += '<li>...</li>'
|
||||
task.recurrence_message += '</ul>'
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user