From 5111416ab89fa4540df04b5bdfea0b6bccd8f573 Mon Sep 17 00:00:00 2001 From: Dmytro Meita Date: Fri, 17 Jan 2025 13:24:12 +0000 Subject: [PATCH] [FIX] cetmix_tower_server: resolve comments Task ID: 4263 --- .../models/cx_tower_plan_line.py | 28 ++++++++++++------ .../views/cx_tower_command_log_view.xml | 29 +++++++++++++++---- .../views/cx_tower_plan_line_view.xml | 11 ++++++- 3 files changed, 53 insertions(+), 15 deletions(-) diff --git a/cetmix_tower_server/models/cx_tower_plan_line.py b/cetmix_tower_server/models/cx_tower_plan_line.py index d4444c44..1dde4d8f 100644 --- a/cetmix_tower_server/models/cx_tower_plan_line.py +++ b/cetmix_tower_server/models/cx_tower_plan_line.py @@ -47,6 +47,12 @@ class CxTowerPlanLine(models.Model): command_code = fields.Text( string="Code", compute="_compute_command_code", readonly=True ) + plan_line_ids = fields.One2many( + comodel_name="cx.tower.plan.line", + compute="_compute_plan_line_ids", + string="Plan Lines", + readonly=True, + ) action = fields.Selection(related="command_id.action", readonly=True) tag_ids = fields.Many2many(related="command_id.tag_ids", readonly=True) access_level = fields.Selection( @@ -98,17 +104,21 @@ def _compute_command_code(self): for line in self: if line.action == "file_using_template": line.command_code = line.command_id.code or "No template code available" - elif line.action == "plan": - flight_plan_lines = line.command_id.flight_plan_id.line_ids - preview_lines = [line.name for line in flight_plan_lines] - line.command_code = ( - "\n".join(preview_lines) - if preview_lines - else "No related lines available" - ) - else: + elif line.action != "plan": line.command_code = "No preview available" + @api.depends("command_id", "action") + def _compute_plan_line_ids(self): + """ + Compute the related plan lines if the action is "plan". + """ + for line in self: + if line.action == "plan": + flight_plan = line.command_id.flight_plan_id + line.plan_line_ids = flight_plan.line_ids if flight_plan else [] + else: + line.plan_line_ids = False + def _check_recursive_plan(self, command, visited_plans): """ Recursively check if the command plan creates a cycle. diff --git a/cetmix_tower_server/views/cx_tower_command_log_view.xml b/cetmix_tower_server/views/cx_tower_command_log_view.xml index 22bb485d..fe681fd7 100644 --- a/cetmix_tower_server/views/cx_tower_command_log_view.xml +++ b/cetmix_tower_server/views/cx_tower_command_log_view.xml @@ -75,11 +75,30 @@ - - - - - + + + + + diff --git a/cetmix_tower_server/views/cx_tower_plan_line_view.xml b/cetmix_tower_server/views/cx_tower_plan_line_view.xml index df0497e1..62ab48fa 100644 --- a/cetmix_tower_server/views/cx_tower_plan_line_view.xml +++ b/cetmix_tower_server/views/cx_tower_plan_line_view.xml @@ -38,7 +38,16 @@ - + + + +