Skip to content

Commit

Permalink
[FIX] cetmix_tower_server: resolve comments
Browse files Browse the repository at this point in the history
Task ID: 4263
  • Loading branch information
tendil committed Jan 17, 2025
1 parent 54fcb67 commit 5111416
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 15 deletions.
28 changes: 19 additions & 9 deletions cetmix_tower_server/models/cx_tower_plan_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand Down
29 changes: 24 additions & 5 deletions cetmix_tower_server/views/cx_tower_command_log_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,30 @@
</group>
</group>
<group>
<field name="plan_log_id" />
<field name="plan_start_date" string="Plan Start Date" />
<field name="plan_finish_date" string="Plan Finish Date" />
<field name="plan_status" string="Plan Status" />
<field name="plan_is_running" string="Plan Running" />
<field
name="plan_log_id"
attrs="{'invisible': [('plan_log_id', '=', False)]}"
/>
<field
name="plan_start_date"
string="Plan Start Date"
attrs="{'invisible': [('plan_log_id', '=', False)]}"
/>
<field
name="plan_finish_date"
string="Plan Finish Date"
attrs="{'invisible': [('plan_log_id', '=', False)]}"
/>
<field
name="plan_status"
string="Plan Status"
attrs="{'invisible': [('plan_log_id', '=', False)]}"
/>
<field
name="plan_is_running"
string="Plan Running"
attrs="{'invisible': [('plan_log_id', '=', False)]}"
/>
</group>
<notebook attrs="{'invisible': [('command_action', '=', 'plan')]}">
<page name="result" string="Result">
Expand Down
11 changes: 10 additions & 1 deletion cetmix_tower_server/views/cx_tower_plan_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@
<notebook>
<page name="preview" string="Command Preview">
<group>
<field name="command_code" />
<field name="command_id" />
<field name="action" />
<field
name="command_code"
attrs="{'invisible': [('action', '=', 'plan')]}"
/>
<field
name="plan_line_ids"
attrs="{'invisible': [('action', '!=', 'plan')]}"
/>
</group>
</page>
<page name="actions" string="Post Run Actions">
Expand Down

0 comments on commit 5111416

Please sign in to comment.