[18.0][ADD] cetmix_tower_access_link: add module#488
[18.0][ADD] cetmix_tower_access_link: add module#488marionumza wants to merge 7 commits intocetmix:18.0from
Conversation
WalkthroughThis pull request introduces a new Odoo module Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
cetmix_tower_access_link/security/ir.model.access.csvis excluded by!**/*.csv
📒 Files selected for processing (13)
cetmix_tower_access_link/README.rstcetmix_tower_access_link/__init__.pycetmix_tower_access_link/__manifest__.pycetmix_tower_access_link/models/__init__.pycetmix_tower_access_link/models/cx_tower_access_template.pycetmix_tower_access_link/models/cx_tower_jet.pycetmix_tower_access_link/models/cx_tower_jet_access.pycetmix_tower_access_link/models/cx_tower_jet_template.pycetmix_tower_access_link/pyproject.tomlcetmix_tower_access_link/views/cx_tower_access_template_views.xmlcetmix_tower_access_link/views/cx_tower_jet_template_views.xmlcetmix_tower_access_link/views/cx_tower_jet_views.xmlcetmix_tower_access_link/views/menus.xml
… CodeRabbit findings
tendil
left a comment
There was a problem hiding this comment.
Thank you for your contribution!
- We need to add the documentation;
- All methods must include signature typing, docstrings, and return values;
- We need to write tests for the new logic.
| "views/menus.xml", | ||
| ], | ||
| "installable": True, | ||
| "application": False, |
There was a problem hiding this comment.
lines 21 and 22 are default values and can be deleted
| @@ -0,0 +1,12 @@ | |||
| ========================= | |||
| Cetmix Tower Access Link | |||
There was a problem hiding this comment.
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:
- DESCRIPTION.md - https://github.com/OCA/maintainer-tools/blob/master/template/module/readme/DESCRIPTION.md
- CONFIGURE.md - https://github.com/OCA/maintainer-tools/blob/master/template/module/readme/CONFIGURE.md
- USAGE.md - https://github.com/OCA/maintainer-tools/blob/master/template/module/readme/USAGE.md
| @@ -0,0 +1,73 @@ | |||
| import re | |||
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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*\}\}") |
There was a problem hiding this comment.
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}) |
There was a problem hiding this comment.
please use fields.Command.create(...) instead of raw (0, 0, values) tuples
| 0, | ||
| 0, | ||
| { | ||
| "jet_id": self.id, |
There was a problem hiding this comment.
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( |
| help="Quick access links configured for this jet.", | ||
| ) | ||
|
|
||
| @api.model_create_multi |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
all methods must include signature typing, docstrings, and return values
…s for Jets
Summary by CodeRabbit