[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) <xbo@odoo.com>
This commit is contained in:
@@ -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'] = {
|
||||
|
||||
Reference in New Issue
Block a user