From 0aab0bf13ee7c27a49a394d633e8ac89f06acbcd Mon Sep 17 00:00:00 2001 From: Gurupreet Singh Date: Tue, 25 Jul 2023 12:51:47 +0000 Subject: [PATCH] [FIX] sale_project: fix tasks stat button traceback steps: -install sale module. -create product with product type as course -Generate a sale order containing the newly created product. -link the sale order to any project task, and then attempt to view the tasks stat button by clicking. However, encounter an unexpected traceback or error message during this action. issue: In the sale module quotation view, the traceback is occurring when clicking on the tasks stat button fix: Improved action_view_task method in sale_order model to handle missing sales order lines with 'service' products. Set default project ID when no suitable sales order line is found, preventing errors and ensuring smooth functionality. Refactor involved using conditional expressions for better readability and maintaining default behavior. task-3436556 closes odoo/odoo#132981 X-original-commit: 10838145c0981e46221b2cbf65b2c4ce84c3b8c7 Signed-off-by: Xavier Bol (xbo) --- addons/sale_project/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_project/models/sale_order.py b/addons/sale_project/models/sale_order.py index ec477f7a9dc..82de63ca2c2 100644 --- a/addons/sale_project/models/sale_order.py +++ b/addons/sale_project/models/sale_order.py @@ -118,7 +118,7 @@ class SaleOrder(models.Model): action['views'] = [(form_view_id, 'form')] action['res_id'] = self.tasks_ids.id # set default project - default_line = next(sol for sol in self.order_line if sol.product_id.detailed_type == 'service') + default_line = next((sol for sol in self.order_line if sol.product_id.detailed_type == 'service'), self.env['sale.order.line']) default_project_id = default_line.project_id.id or self.project_id.id or self.project_ids[:1].id action['context'] = {