[FIX] sale_project: batch confirmation of sales orders

The override of `_action_confirm` in sale_project will crash when orders from multiple companies
are confirmed together.
This commit adapts the method to handle multiple records correctly.

closes odoo/odoo#58269

X-original-commit: ab14083b0ddfb73da167938c43f35a992fbbe93c
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
tafaRU
2020-09-22 16:47:14 +00:00
committed by Victor Feyens
parent eb1ddf99cb
commit cb85e4baf5
+7 -2
View File
@@ -50,8 +50,13 @@ class SaleOrder(models.Model):
def _action_confirm(self):
""" On SO confirmation, some lines should generate a task or a project. """
result = super()._action_confirm()
self.mapped('order_line').sudo() \
.with_company(self.company_id)._timesheet_service_generation()
if len(self.company_id) == 1:
# All orders are in the same company
self.order_line.sudo().with_company(self.company_id)._timesheet_service_generation()
else:
# Orders from different companies are confirmed together
for order in self:
order.order_line.sudo().with_company(order.company_id)._timesheet_service_generation()
return result
def action_view_task(self):