Merge remote-tracking branch 'origin/15.0' into 16.0
This commit is contained in:
commit
12f19c5fbc
3 changed files with 40 additions and 23 deletions
|
|
@ -20,7 +20,7 @@
|
|||
########################################################################################
|
||||
{
|
||||
'name': 'Improved Field Service Management',
|
||||
'version': '16.0.1.0.0',
|
||||
'version': '16.0.1.0.1',
|
||||
'summary': 'Adds functionality necessary for managing field service operations at Durpro.',
|
||||
'description': 'Adds functionality necessary for managing field service operations at Durpro.',
|
||||
'category': 'Services/Field Service',
|
||||
|
|
|
|||
|
|
@ -102,6 +102,9 @@ class Task(models.Model):
|
|||
super().write(vals)
|
||||
if not self: # End recursion on empty RecordSet
|
||||
return
|
||||
if 'propagate_assignment' in vals:
|
||||
# When a user sets propagate assignment, it should propagate that setting all the way down the chain
|
||||
self.child_ids.write({'propagate_assignment': vals['propagate_assignment']})
|
||||
if 'user_ids' in vals:
|
||||
to_propagate = self.filtered(lambda task: task.propagate_assignment)
|
||||
# Here we use child_ids instead of _get_all_subtasks() so as to allow for setting propagate_assignment
|
||||
|
|
|
|||
|
|
@ -6,37 +6,51 @@ from odoo import Command
|
|||
@tagged('post_install', '-at_install')
|
||||
class TaskTest(BemadeFSMBaseTest):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# Chose to set up all tests the same way since this code was becoming very redundant
|
||||
super().setUpClass()
|
||||
cls.so = cls._generate_sale_order()
|
||||
cls.template = cls._generate_task_template(names=['Parent', 'Child', 'Grandchild'], structure=[2, 1])
|
||||
cls.product = cls._generate_product(task_template=cls.template)
|
||||
cls.sol = cls._generate_sale_order_line(sale_order=cls.so, product=cls.product)
|
||||
cls.user = cls._generate_project_manager_user('Bob', 'Bob')
|
||||
cls.so.action_confirm()
|
||||
cls.task = cls.sol.task_id
|
||||
|
||||
def test_reassigning_assignment_propagating_task_changes_subtasks(self):
|
||||
# This creation step is a bit lazy - we use defaults to make tasks with a hierachy and settings we want
|
||||
so = self._generate_sale_order()
|
||||
template = self._generate_task_template(names=['Parent', 'Child'], structure=[2])
|
||||
product = self._generate_product(task_template=template)
|
||||
sol = self._generate_sale_order_line(sale_order=so, product=product)
|
||||
user = self._generate_project_manager_user('Bob', 'Bob')
|
||||
so.action_confirm()
|
||||
task = sol.task_id
|
||||
task = self.task
|
||||
task.propagate_assignment = True
|
||||
|
||||
task.write({
|
||||
'user_ids': [Command.set([user.id])],
|
||||
'user_ids': [Command.set([self.user.id])],
|
||||
'propagate_assignment': True,
|
||||
})
|
||||
|
||||
self.assertTrue(all([t.user_ids == user for t in task | task._get_all_subtasks()]))
|
||||
|
||||
def test_reassigning_assignment_non_propagating_task_doesnt_change_subtasks(self):
|
||||
so = self._generate_sale_order()
|
||||
template = self._generate_task_template(names=['Parent', 'Child', 'Grandchild'], structure=[2, 1])
|
||||
product = self._generate_product(task_template=template)
|
||||
sol = self._generate_sale_order_line(sale_order=so, product=product)
|
||||
user = self._generate_project_manager_user('Bob', 'Bob')
|
||||
so.action_confirm()
|
||||
task = sol.task_id
|
||||
task.child_ids.write({'propagate_assignment': False}) # Stop propagation after the first level
|
||||
self.assertTrue(all([t.user_ids == self.user for t in task | task._get_all_subtasks()]))
|
||||
|
||||
def test_reassigning_task_doesnt_propagate_by_default(self):
|
||||
task = self.task
|
||||
task.write({
|
||||
'user_ids': [Command.set([user.id])],
|
||||
'user_ids': [Command.set([self.user.id])],
|
||||
'propagate_assignment': True,
|
||||
})
|
||||
|
||||
self.assertTrue(all([t.user_ids == user for t in task | task.child_ids]))
|
||||
self.assertFalse(any([t.user_ids for t in task.child_ids.child_ids]))
|
||||
|
||||
def test_unset_propagate_assignment_unsets_for_all_children(self):
|
||||
task = self.task
|
||||
# First, set propagation and assign
|
||||
task.propagate_assignment = True
|
||||
task.write({
|
||||
'user_ids': [Command.set([self.user.id])]
|
||||
})
|
||||
# Then, unset propagation for the children and re-set assignment
|
||||
task.child_ids.write({'propagate_assignment': False})
|
||||
self.assertFalse(any([t.propagate_assignment for t in task._get_all_subtasks()]))
|
||||
# Then, test that assigning the parent only assigns its children, not its grandchildren
|
||||
task.write({
|
||||
'user_ids': [Command.set([])]
|
||||
})
|
||||
self.assertTrue(all([not t.user_ids for t in task | task.child_ids]))
|
||||
self.assertTrue(all([t.user_ids == self.user for t in task.child_ids.child_ids]))
|
||||
|
|
|
|||
Loading…
Reference in a new issue