Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] cetmix_tower_server: implement UI updates #185

Open
wants to merge 15 commits into
base: 14.0-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions cetmix_tower_server/models/cx_tower_command_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,6 @@ class CxTowerCommandLog(models.Model):
plan_log_id = fields.Many2one(comodel_name="cx.tower.plan.log", ondelete="cascade")
triggered_plan_log_id = fields.Many2one(comodel_name="cx.tower.plan.log")

# -- Related fields for plan_log_id
plan_start_date = fields.Datetime(
related="plan_log_id.start_date", store=True, string="Plan Start Date"
)
plan_finish_date = fields.Datetime(
related="plan_log_id.finish_date", store=True, string="Plan Finish Date"
)
plan_status = fields.Integer(
related="plan_log_id.plan_status", store=True, string="Plan Status"
)
plan_is_running = fields.Boolean(
related="plan_log_id.is_running", store=True, string="Plan Running"
)

@api.depends("name", "command_id.name")
def _compute_name(self):
for rec in self:
Expand Down
29 changes: 2 additions & 27 deletions cetmix_tower_server/models/cx_tower_plan_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class CxTowerPlanLine(models.Model):
" If empty next command will be executed",
)
command_code = fields.Text(
ivs-cetmix marked this conversation as resolved.
Show resolved Hide resolved
string="Code", compute="_compute_command_code", readonly=True
comodel_name="cx.tower.command", string="Code", readonly=True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason behind removing the "related" key?

)
plan_line_ids = fields.One2many(
comodel_name="cx.tower.plan.line",
compute="_compute_plan_line_ids",
inverse_name="command_id",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will allow to modify those lines directly which is not what we want.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After analyzing and checking, I found that this field is redundant within the scope of this task. If this is not the case, please let me know

string="Plan Lines",
readonly=True,
)
Expand Down Expand Up @@ -96,31 +96,6 @@ def _check_command_id(self):
visited_plans = set()
self._check_recursive_plan(line.command_id, visited_plans)

@api.depends("command_id", "action")
def _compute_command_code(self):
"""
Compute the preview of the command based on its action.
"""
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":
line.command_code = False
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
20 changes: 0 additions & 20 deletions cetmix_tower_server/views/cx_tower_command_log_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,6 @@
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
2 changes: 1 addition & 1 deletion cetmix_tower_server/views/cx_tower_plan_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<field name="action" />
<field
name="command_code"
attrs="{'invisible': [('action', '=', 'plan')]}"
attrs="{'invisible': [('action', 'not in', ['ssh_command', 'python_code'])]}"
/>
<field
name="plan_line_ids"
Expand Down
Loading