Skip to content

[18.0][REF] agreement_legal: Replace repeated dynamic field code with mixin#105

Open
tarteo wants to merge 1 commit into
OCA:18.0from
tarteo:18-ref-create-dynamic-content-mixin
Open

[18.0][REF] agreement_legal: Replace repeated dynamic field code with mixin#105
tarteo wants to merge 1 commit into
OCA:18.0from
tarteo:18-ref-create-dynamic-content-mixin

Conversation

@tarteo
Copy link
Copy Markdown
Member

@tarteo tarteo commented Feb 26, 2026

We can also move the rendering to the mixin

@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @max3903, @ygol,
some modules you are maintaining are being modified, check this out!

Copy link
Copy Markdown

@CRogos CRogos left a comment

Choose a reason for hiding this comment

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

I like this change very much.
Could you add the module name to the PR title and commit message?

Code review LGTM, but not tested.

@tarteo tarteo changed the title [18.0][REF] Replace repeated dynamic field code with mixin [18.0][REF] agreement_legal: Replace repeated dynamic field code with mixin Feb 26, 2026
@tarteo tarteo changed the title [18.0][REF] agreement_legal: Replace repeated dynamic field code with mixin [18.0][REF] agreement_legal: Replace repeated dynamic field code with mixin Feb 26, 2026
@tarteo tarteo force-pushed the 18-ref-create-dynamic-content-mixin branch from fd16a39 to d6074c7 Compare February 26, 2026 10:45
SyncMasta added a commit to SyncMasta/agreement that referenced this pull request May 2, 2026
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) <noreply@anthropic.com>
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.

3 participants