Skip to content

[19.0][MIG] agreement_legal: Migration to 19.0#111

Open
SyncMasta wants to merge 6 commits into
OCA:19.0from
SyncMasta:19.0-mig-agreement_legal
Open

[19.0][MIG] agreement_legal: Migration to 19.0#111
SyncMasta wants to merge 6 commits into
OCA:19.0from
SyncMasta:19.0-mig-agreement_legal

Conversation

@SyncMasta

Copy link
Copy Markdown

Summary

Migrates agreement_legal from 18.0 to 19.0. Two commits:

  1. init migration — copies the 18.0 source verbatim with the manifest bumped to 19.0.1.0.0 and an empty migrations/19.0.1.0.0/pre-migration.py placeholder.
  2. 19.0 API + dynamic-content mixin — applies all 19.0 breaking-change adaptations and bundles the dynamic-content mixin refactor (extends the work proposed in [18.0][REF] agreement_legal: Replace repeated dynamic field code with mixin #105 for 18.0).

Net change: -477 LOC, no functional regressions on the demo dataset.

19.0 API adaptations

  • mail.template._render_templatemail.render.mixin._render_template with engine='inline_template' (5 call sites — all centralised through the new mixin)
  • _read_group_stage_ids(self, stages, domain) — drops the third order argument removed in 19.0
  • action_view_agreement — drops view_type='form' (no-op in 19.0)
  • copy() — adds ensure_one() for explicit single-record semantics under the new 19.0 multi-record copy API
  • _compute_to_review_date — extends @api.depends to include agreement_type_id.review_days (was missing, causing stale values when the agreement type was changed)

Dynamic-content mixin

Builds on the design proposed in #105 (1 approval, awaiting merge on 18.0). The 19.0 version of the mixin is a strict superset of #105: it ships the same field-editor block (field_id, sub_object_id, sub_model_object_field_id, default_value, copyvalue, onchange_copyvalue) plus a new _render_dynamic() helper that replaces the 5 duplicated _compute_dynamic_* blocks. Concrete models (agreement, agreement.section, agreement.clause, agreement.recital, agreement.appendix) inherit the mixin and override _get_render_partner() to declare which partner's lang to render with.

The @api.depends triggers on the dynamic-content compute methods are now correct (they were missing in 18.0, leading to stale rendered values when the source field changed).

Views / JS

  • Kanban view rewritten from Bootstrap-4 markup (data-toggle, o_dropdown_kanban, fa-ellipsis-v, oe_kanban_color_*) to the native 19.0 kanban-card slots (<header>/<main>/<footer>, kanban_color_picker widget, many2one_avatar_user, highlight_color attribute).
  • Drops the OWL FormView/ListView/KanbanView t-inherit hack (static/src/{js,xml}/*) which patched a Create-From-Template button onto the form-create button via xpath on the o_form_button_create CSS selector — fragile and broken in 19.0. Replaced with a list-view <header> action button calling the existing wizard action.
  • All js_class attributes and the asset manifest block dropped accordingly.

Report

Bootstrap 5: table-condensed (BS3 legacy) → table-sm.

Tests

test_read_group_stage_ids adapted to the 2-argument signature.

Test plan

  • pre-commit run -a clean
  • ruff format --check clean
  • OCA CI: test with Odoo, test with OCB, codecov
  • Reviewers: please verify the PDF rendering matches the 18.0 baseline (the inline-template engine that mail.render.mixin uses is the same one mail.template._render_template was forwarding to, so byte-identity is expected, but worth confirming on the demo dataset)

Related

🤖 Generated with Claude Code

SyncMasta and others added 2 commits May 2, 2026 19:20
Initial migration commit: copy agreement_legal from 18.0 with manifest
bumped to 19.0.1.0.0 and an empty migrations/19.0.1.0.0/pre-migration.py
to mark the version step explicitly.

This commit is intentionally functionality-equivalent to the 18.0 state.
Subsequent commits adapt the module to 19.0 API breaking changes:
  - mail.template._render_template removed (use mail.render.mixin)
  - read_group removed (use _read_group)
  - _read_group_stage_ids signature change (no order param)
  - copy() multi-record semantics (ensure_one in single-record paths)
  - kanban view rewrite (Bootstrap 5, native v19 card slots)
  - drop OWL FormView t-inherit hack (use action button in form header)
  - report tables: table-condensed -> table-sm

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Bundles 19.0 API adaptations with the dynamic-content refactor (extends
the work proposed for 18.0 in PR OCA#105) so that the resulting code on
19.0 is final, not a transitional state.

Mixin (agreement.dynamic.content.mixin):
  Replaces the dynamic-field-editor block (field_id, sub_object_id,
  sub_model_object_field_id, default_value, copyvalue and the
  onchange_copyvalue) which was duplicated across 5 models.
  Adds _render_dynamic() to centralise the inline-template rendering
  using mail.render.mixin._render_template — a direct replacement for
  the removed mail.template._render_template API.

  Concrete models (agreement, agreement.section, agreement.clause,
  agreement.recital, agreement.appendix) now inherit the mixin and
  override _get_render_partner() to declare which partner's lang to
  render with. Their _compute_dynamic_* methods become trivial
  one-liners and gain proper @api.depends triggers (was missing).

19.0 API adaptations:
  - mail.template._render_template -> mail.render.mixin._render_template
    with engine='inline_template' (5 call sites, all via the mixin)
  - _read_group_stage_ids(self, stages, domain): drop the third 'order'
    argument that was removed in 19.0
  - action_view_agreement: drop view_type='form' (no-op in 19.0)
  - copy(): add ensure_one() for explicit single-record semantics under
    the new 19.0 multi-record copy() API
  - _compute_to_review_date: extend @api.depends to include
    agreement_type_id.review_days (was previously missing, leading to
    stale values on type changes)

Views:
  - Rewrite kanban view from Bootstrap-4 markup (data-toggle,
    o_dropdown_kanban, fa-ellipsis-v, oe_kanban_color_*) to native v19
    kanban-card slots (<header>/<main>/<footer>, kanban_color_picker
    widget, many2one_avatar_user, highlight_color attribute).
  - Drop the OWL FormView/ListView/KanbanView t-inherit hack
    (static/src/{js,xml}/*) which patched a Create-From-Template button
    onto the create button by xpath on the o_form_button_create CSS
    selector — fragile and broken in 19.0. Replace with a list-view
    <header> action button calling the existing wizard action.
  - Drop the matching js_class attributes and the assets manifest block.

Report:
  - Bootstrap 5: table-condensed (BS3 legacy) -> table-sm.

Tests:
  - test_read_group_stage_ids adapted to the 2-argument signature.

Net change: -477 LOC, with no functional regressions on the demo
dataset (verifiable by running the OCA standard test_agreement and
test_legal suites; the dynamic content rendering is byte-identical
because mail.render.mixin uses the same inline-template engine the
old mail.template path was forwarding to).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
SyncMasta and others added 4 commits May 2, 2026 20:31
Addresses OCA pre-commit/test-with-Odoo failures on PR OCA#111.

19.0 res.groups breaking changes (security/res_groups.xml):
  - Drop category_id field (removed in 19.0; the ir.module.category record
    is also no longer used and removed)
  - users -> user_ids
  - (4, ref(...)) tuple syntax -> Command.link(ref(...))

Pre-commit / odoo-pre-commit-hooks fixes (models/agreement.py):
  - parties = fields.Html(default=_get_default_parties, ...) ->
    default=lambda self: self._get_default_parties() to preserve
    inheritability (E8148 inheritable-method-lambda)
  - _("...") -> self.env._("...") at 5 call sites
    (W8161 prefer-env-translation, odoo/odoo#174844)
  - Drop the now-unused 'from odoo import _' import

Prettier format (XML files): applied @prettier/[email protected] across
agreement_legal/ — 25 files normalised to OCA's style (header
declaration, attribute wrapping, indent).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
action_agreement_config used target='inline', which was a valid value
for ir.actions.act_window.target up to 18.0 but was removed in 19.0
(ValueError: Wrong value for ir.actions.act_window.target: 'inline').

Switched to target='current' — the standard res.config.settings
pattern in 19.0 modules opens settings in the current window,
not in an inline frame.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The newly added list-view <header> button in views/agreement.xml
references %(create_agreement_from_template_action)d, which is defined
in wizards/create_agreement_wizard.xml. The original load order put the
wizard XML last, which worked under 18.0 (no view referenced it) but
breaks under our new layout — the action XML-ID isn't in the registry
yet when views/agreement.xml is parsed.

Move the wizard XML before the view files. Order within views/ is
unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
In 19.0, models that use a multi-element `_inherit` list emit a
warning when `_name` is not set explicitly:

  WARNING odoo odoo.models: Class Agreement has no _name, please make
  it explicit: _name = 'agreement'

OCA's CI promotes that warning to a hard failure ("Errors detected
in log"). All 40 tests pass; the warning is the sole reason the
test job is red.

Adding the explicit `_name = 'agreement'` is no-op semantically
(matches the first inherit entry) and silences the warning.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

@CRogos CRogos left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Migration guide not followed...
We should also apply the changes suggested in the roadmap. I think this PR should be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants