Compare commits
2 commits
18.0
...
17.0-bemad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96e5b2d2fe | ||
|
|
31c3695c3e |
4 changed files with 58 additions and 9 deletions
|
|
@ -154,3 +154,10 @@ class SaleOrder(models.Model):
|
||||||
def action_confirm(self):
|
def action_confirm(self):
|
||||||
self._create_or_organize_visits_if_needed()
|
self._create_or_organize_visits_if_needed()
|
||||||
return super().action_confirm()
|
return super().action_confirm()
|
||||||
|
|
||||||
|
def write(self, values):
|
||||||
|
res = super().write(values)
|
||||||
|
if "partner_shipping_id" in values:
|
||||||
|
for rec in self:
|
||||||
|
rec.tasks_ids.write({"partner_id": rec.partner_shipping_id.id})
|
||||||
|
return res
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ class SaleOrderLine(models.Model):
|
||||||
for t in template.subtasks:
|
for t in template.subtasks:
|
||||||
subtask = _create_task_from_template(project, t, task)
|
subtask = _create_task_from_template(project, t, task)
|
||||||
subtasks.append(subtask)
|
subtasks.append(subtask)
|
||||||
task.write({"child_ids": [Command.set([t.id for t in subtasks])]})
|
# task.write({"child_ids": [Command.set([t.id for t in subtasks])]})
|
||||||
# We don't want to see the sub-tasks on the SO
|
# We don't want to see the sub-tasks on the SO
|
||||||
task.child_ids.write(
|
task.child_ids.write(
|
||||||
{
|
{
|
||||||
|
|
@ -142,6 +142,7 @@ class SaleOrderLine(models.Model):
|
||||||
vals["tag_ids"] = template.tags.ids
|
vals["tag_ids"] = template.tags.ids
|
||||||
vals["allocated_hours"] = template.planned_hours
|
vals["allocated_hours"] = template.planned_hours
|
||||||
vals["sequence"] = template.sequence
|
vals["sequence"] = template.sequence
|
||||||
|
vals["partner_id"] = self.order_id.partner_id.id
|
||||||
if template.equipment_ids:
|
if template.equipment_ids:
|
||||||
vals["equipment_ids"] = template.equipment_ids.ids
|
vals["equipment_ids"] = template.equipment_ids.ids
|
||||||
return vals
|
return vals
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ class Task(models.Model):
|
||||||
root_ancestor = fields.Many2one(
|
root_ancestor = fields.Many2one(
|
||||||
comodel_name="project.task",
|
comodel_name="project.task",
|
||||||
compute="_compute_root_ancestor",
|
compute="_compute_root_ancestor",
|
||||||
|
recursive=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _compute_is_closed(self):
|
def _compute_is_closed(self):
|
||||||
|
|
@ -109,14 +110,20 @@ class Task(models.Model):
|
||||||
# Here we use child_ids instead of _get_all_subtasks() so as to allow for setting propagate_assignment
|
# Here we use child_ids instead of _get_all_subtasks() so as to allow for setting propagate_assignment
|
||||||
# to false on a child task.
|
# to false on a child task.
|
||||||
to_propagate.child_ids.write({"user_ids": vals["user_ids"]})
|
to_propagate.child_ids.write({"user_ids": vals["user_ids"]})
|
||||||
if "site_contacts" in vals and self.child_ids:
|
for rec in self:
|
||||||
self._get_all_subtasks().write(
|
if rec.child_ids:
|
||||||
{"site_contacts": [Command.set(self.site_contacts.ids)]}
|
child_vals = {}
|
||||||
)
|
if "site_contacts" in vals:
|
||||||
if "work_order_contacts" in vals and self.child_ids:
|
child_vals.update(
|
||||||
self._get_all_subtasks().write(
|
site_contacts=[Command.set(rec.site_contacts.ids)]
|
||||||
{"work_order_contacts": [Command.set(self.work_order_contacts.ids)]}
|
)
|
||||||
)
|
if "work_order_contacts" in vals:
|
||||||
|
child_vals.update(
|
||||||
|
work_order_contacts=[Command.set(rec.work_order_contacts.ids)]
|
||||||
|
)
|
||||||
|
if "partner_id" in vals:
|
||||||
|
child_vals.update(partner_id=vals["partner_id"])
|
||||||
|
rec.child_ids.write(child_vals)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.depends("sale_order_id")
|
@api.depends("sale_order_id")
|
||||||
|
|
|
||||||
|
|
@ -327,3 +327,37 @@ class TestSalesOrder(BemadeFSMBaseTest):
|
||||||
so.action_confirm()
|
so.action_confirm()
|
||||||
|
|
||||||
self.assertFalse(so.visit_ids)
|
self.assertFalse(so.visit_ids)
|
||||||
|
|
||||||
|
def test_changing_sale_order_customer_follows_to_tasks_and_subtasks(self):
|
||||||
|
so = self._generate_sale_order()
|
||||||
|
so = self._generate_sale_order()
|
||||||
|
so.company_id.create_default_fsm_visit = False
|
||||||
|
task_template = self._generate_task_template(
|
||||||
|
parent=None,
|
||||||
|
structure=[2, 2],
|
||||||
|
names=["Parent", "Child", "Grandchild"],
|
||||||
|
)
|
||||||
|
product = self._generate_product(task_template=task_template)
|
||||||
|
sol = self._generate_sale_order_line(so, product)
|
||||||
|
|
||||||
|
so.action_confirm()
|
||||||
|
|
||||||
|
parent_task = sol.task_id
|
||||||
|
for task in parent_task._get_all_subtasks() | parent_task:
|
||||||
|
self.assertEqual(so.partner_shipping_id, task.partner_id)
|
||||||
|
|
||||||
|
so.write(
|
||||||
|
{
|
||||||
|
"partner_shipping_id": self.env["res.partner"]
|
||||||
|
.create(
|
||||||
|
{
|
||||||
|
"name": "New shipping address",
|
||||||
|
"parent_id": so.partner_id.id,
|
||||||
|
"type": "delivery",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.id
|
||||||
|
}
|
||||||
|
)
|
||||||
|
for task in parent_task._get_all_subtasks() | parent_task:
|
||||||
|
self.assertEqual(so.partner_shipping_id, task.partner_id)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue