Skip to content

spp_programs: retire the DOM workaround for the form "New" button now that #582 keeps canCreate #589

Open

Description

@gonzalesedwin1123

spp_programs/static/src/js/form_controller_create.js hides .o_form_button_create with style.display = "none",
re-applied on onMounted/onPatched, two timers and a MutationObserver, whenever context.create === false,
this.canCreate === false, or the model is in MODELS_WITHOUT_CREATE. Its comment blames Odoo 19 ("t-if="canCreate"
on the form template does not always prevent the 'New' button from rendering"). The real cause was the
spp_base_common template extension dropping canCreate (#582, fixed in PR #588). With that fix:

  • the context.create === false and canCreate === false branches are dead: Odoo never renders the button in those
    cases, so the observer and timers find nothing;
  • MODELS_WITHOUT_CREATE (spp.entitlement, spp.entitlement.inkind, spp.program.membership,
    spp.cycle.membership) can be expressed the way spp_programs already does for spp.program
    (create_program.js): this.hideFormCreateButton = true in the FormController patch. Note that all four of
    those forms also carry create="0" on their arch (entitlement_view.xml, entitlement_cash_view.xml,
    program_membership_view.xml, cycle_membership_view.xml), so the list may be redundant altogether; keep the
    flag only if a form of those models exists without the arch attribute.

Also, two comments elsewhere describe the same symptom as an Odoo 19 defect and should be corrected (code is fine):

  • spp_drims/static/src/js/hide_dispatch_form_create.js: "Action context 'create': False is unreliable in Odoo 19
    too" — it was unreliable because of the spp_base_common override.
  • spp_farmer_registry/static/src/js/registry_restriction.js: the .o_form_button_create entry in its DOM-hiding
    selector list is redundant once this.canCreate = false (which it already sets in onWillStart) is honoured by the
    template. The other selectors (save/cancel/statusbar) and the o_form_readonly class handling are unrelated and stay.

Scope: spp_programs patch bump + HISTORY (and whichever of the other two modules gets a code, not comment, change).
Regression coverage already exists in spp_base_common (test_form_create_button_template.py) and in the e2e suite
(spec 01, test 20).

Refs #582.

Activity

  1. gonzalesedwin1123 commented on Oct 8, 2026

    @gonzalesedwin1123
    MemberAuthor

    Correction to the "Regression coverage" line: the e2e suite covers both paths, not just test 20. Spec 01 test 16 asserts the detail form the create wizard opens with context: {create: False} renders no .o_form_button_create (the context path); test 20 covers the approval review form (create="0" on the arch, no create ACL for the role). Both assert DOM count 0, so the display:none workaround cannot mask a regression while it still exists.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions