Skip to content

[18.0][ADD] cetmix_tower_access_link: add module#488

Open
marionumza wants to merge 7 commits intocetmix:18.0from
marionumza:18.0-add-access-link
Open

[18.0][ADD] cetmix_tower_access_link: add module#488
marionumza wants to merge 7 commits intocetmix:18.0from
marionumza:18.0-add-access-link

Conversation

@marionumza
Copy link
Copy Markdown

@marionumza marionumza commented Apr 21, 2026

…s for Jets

Summary by CodeRabbit

  • New Features
    • Introduced Access Links module for managing quick access links to Cetmix Tower jets.
    • Create reusable access templates with dynamic URLs supporting variable placeholders.
    • Configure access links at jet template level; automatically applied to new jets.
    • Sync access links manually on individual jets for customized configurations.
    • Access links include URL validation and one-click opening functionality.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

Walkthrough

This pull request introduces a new Odoo module cetmix_tower_access_link that provides access link template management for Cetmix Tower jets. The module enables configuration of quick access URLs with variable substitution and role-based access control, allowing templates to be applied to jet templates and individual jets.

Changes

Cohort / File(s) Summary
Package Setup & Configuration
README.rst, __init__.py, __manifest__.py, pyproject.toml
New module initialization, manifest metadata declaring dependencies on cetmix_tower_server, data file references, and build system configuration using whool.
Models Package Initialization
models/__init__.py
Package initializer exposing four model submodules: cx_tower_access_template, cx_tower_jet_access, cx_tower_jet_template, and cx_tower_jet.
Core Models
models/cx_tower_access_template.py, models/cx_tower_jet_access.py
CxTowerAccessTemplate defines access link templates with url_code field supporting Jinja-like {{ variable }} placeholders, computed variable_ids and required_variables, and Many2many links to users and managers. CxTowerJetAccess links jets to templates, computing url_resolved by substituting variables via jet_id.get_variable_value() and validating URLs via is_url_valid.
Model Extensions
models/cx_tower_jet.py, models/cx_tower_jet_template.py
CxTowerJet adds access_ids One2many field, overrides create() to populate access links from jet_template_id.access_template_ids, and provides action_sync_access_links() method. CxTowerJetTemplate adds access_template_ids Many2many to pre-configure templates for jets.
Views & UI
views/cx_tower_access_template_views.xml, views/cx_tower_jet_template_views.xml, views/cx_tower_jet_views.xml, views/menus.xml
Form and list views for access templates with ACE code editor for url_code, inherited views extending jet template and jet forms to display access link configurations, and menu structure routing to access template management under Tower Settings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title '[18.0][ADD] cetmix_tower_access_link: add module' accurately describes the primary change—adding a new Odoo module for managing access links for jets.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@marionumza marionumza changed the title [ADD] cetmix_tower_access_link: Initial implementation of Access Link… [18.0][ADD] cetmix_tower_access_link: base module add new Apr 21, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cetmix_tower_access_link/models/cx_tower_access_template.py`:
- Around line 45-72: The two compute methods _compute_variable_ids and
_compute_required_variables (and the duplicate use in
cx_tower_jet_access.py::_compute_url_resolved) both call
re.findall(r"\{\{\s*(\w+)\s*\}\}", record.url_code); extract and centralize that
regex into a single reusable symbol (either a compiled module-level constant
like PLACEHOLDER_RE = re.compile(r"\{\{\s*(\w+)\s*\}\}") or a small helper
method _extract_placeholders(self, text)) and update these methods to use the
centralized symbol (e.g., PLACEHOLDER_RE.findall(...) or
self._extract_placeholders(record.url_code)) so the placeholder parsing behavior
is defined in one place and won’t drift across functions.

In `@cetmix_tower_access_link/models/cx_tower_jet_access.py`:
- Around line 34-59: In _compute_url_resolved, ensure is_url_valid is explicitly
set on all early-return branches (when template_id, jet_id, or
template_id.url_code is missing) instead of leaving stale values; replace the
current manual placeholder replace loop with re.sub using the same regex
r"\{\{\s*(\w+)\s*\}\}" and a replacement function that calls
jet_id.get_variable_value(var) to return str(val or "") while also tracking
whether any variable was missing/False/empty; after substitution set
record.url_resolved to the final URL string and set record.is_url_valid to False
if any variable was missing/False/empty or the resulting URL is empty, otherwise
True (avoid using a substring check like "False" in url).

In `@cetmix_tower_access_link/models/cx_tower_jet_template.py`:
- Around line 14-16: Replace the Spanish user-facing source strings with English
equivalents: change the attribute string="Plantillas de Acceso" to an English
label (e.g., string="Access Templates") and rewrite the help text into English
(e.g., help="Pre-configured access link templates for jets created from this
template.") in the field definition in cx_tower_jet_template.py; keep
translations out of source and add any Spanish translations into the module's
i18n/*.po files instead.

In `@cetmix_tower_access_link/models/cx_tower_jet.py`:
- Around line 16-35: The create override should build and inject access_ids into
each vals in vals_list before calling super().create instead of creating then
writing per record: iterate vals_list, skip any vals that already contain
"access_ids" (preserve user-supplied values), and if vals contains
"jet_template_id" (id or command), fetch the corresponding template ids from
jet_template_id (use the template relationship access_template_ids) and populate
vals["access_ids"] with a list of (0, 0, {"template_id": template.id}) entries
(do NOT include "jet_id" since the ORM will set that on create); then call
super().create(vals_list) and return the result. Ensure you reference the create
method, vals_list, jet_template_id, access_template_ids and access_ids symbols
when implementing this change.
- Around line 9-14: The field declaration access_ids in class defined in
cx_tower_jet.py (and similarly access_template_ids in cx_tower_jet_template.py)
uses Spanish strings for string/help; change those hard-coded Spanish values to
English (e.g., string="Access Links", help="Quick links configured for this
jet.") so source stays consistent, and remove any locale-specific text from
Python code — translations belong in .po files — ensuring the field definitions
only contain English labels matching the form view.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 115e25a8-6e2d-4f46-9db7-592646ef92d0

📥 Commits

Reviewing files that changed from the base of the PR and between f1bbd4f and e938369.

⛔ Files ignored due to path filters (1)
  • cetmix_tower_access_link/security/ir.model.access.csv is excluded by !**/*.csv
📒 Files selected for processing (13)
  • cetmix_tower_access_link/README.rst
  • cetmix_tower_access_link/__init__.py
  • cetmix_tower_access_link/__manifest__.py
  • cetmix_tower_access_link/models/__init__.py
  • cetmix_tower_access_link/models/cx_tower_access_template.py
  • cetmix_tower_access_link/models/cx_tower_jet.py
  • cetmix_tower_access_link/models/cx_tower_jet_access.py
  • cetmix_tower_access_link/models/cx_tower_jet_template.py
  • cetmix_tower_access_link/pyproject.toml
  • cetmix_tower_access_link/views/cx_tower_access_template_views.xml
  • cetmix_tower_access_link/views/cx_tower_jet_template_views.xml
  • cetmix_tower_access_link/views/cx_tower_jet_views.xml
  • cetmix_tower_access_link/views/menus.xml

Comment thread cetmix_tower_access_link/models/cx_tower_access_template.py
Comment thread cetmix_tower_access_link/models/cx_tower_jet_access.py Outdated
Comment thread cetmix_tower_access_link/models/cx_tower_jet_template.py Outdated
Comment thread cetmix_tower_access_link/models/cx_tower_jet.py
Comment thread cetmix_tower_access_link/models/cx_tower_jet.py Outdated
Copy link
Copy Markdown
Collaborator

@tendil tendil left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

  1. We need to add the documentation;
  2. All methods must include signature typing, docstrings, and return values;
  3. We need to write tests for the new logic.

"views/menus.xml",
],
"installable": True,
"application": False,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lines 21 and 22 are default values and can be deleted

@@ -0,0 +1,12 @@
=========================
Cetmix Tower Access Link
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

you don't need to fill out this file manually, as it is generated automatically;

to do this, you need to create a "readme" folder and add the following files to it:

  1. DESCRIPTION.md - https://github.com/OCA/maintainer-tools/blob/master/template/module/readme/DESCRIPTION.md
  2. CONFIGURE.md - https://github.com/OCA/maintainer-tools/blob/master/template/module/readme/CONFIGURE.md
  3. USAGE.md - https://github.com/OCA/maintainer-tools/blob/master/template/module/readme/USAGE.md

@@ -0,0 +1,73 @@
import re
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

all .py files must contain:

# Copyright (C) 2026 Cetmix OÜ
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

)
variable_ids = fields.Many2many(
comodel_name="cx.tower.variable",
string="Variables",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

you don't need to specify string - it's already implied by the variable name


from odoo import api, fields, models

VARIABLE_PATTERN = re.compile(r"\{\{\s*(\w+)\s*\}\}")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

instead of creating the variable again, you can import it from cetmix_tower_access_link/models/cx_tower_access_template.py

)
if jet_template.access_template_ids:
access_vals = [
(0, 0, {"template_id": t.id})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please use fields.Command.create(...) instead of raw (0, 0, values) tuples

0,
0,
{
"jet_id": self.id,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

jet_id is redundant in this one2many create command;

since this method works on self.ensure_one() and writes to self.access_ids,
the orm already knows which parent record the new access line belongs to;

keeping jet_id here duplicates parent-linking logic and makes the payload noisier
than necessary.

only template_id should be enough

if new_templates:
access_vals = []
for template in new_templates:
access_vals.append(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

and here

help="Quick access links configured for this jet.",
)

@api.model_create_multi
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

since this method is @api.model_create_multi, please keep the implementation batch-friendly

right now each vals browses its own template and then reads access_template_ids
individually

record.variable_ids = [(6, 0, tower_vars.ids)]

@api.depends("url_code")
def _compute_required_variables(self):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

all methods must include signature typing, docstrings, and return values

@tendil tendil changed the title [18.0][ADD] cetmix_tower_access_link: base module add new [18.0][ADD] cetmix_tower_access_link: add module Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants