[IMP] website_sale_aplicoop: signal frontend to reload on deploy
When we ship a JS-only fix, users with a long-lived tab keep running the old code until they hard-refresh — there is no clean way to push new code to an already-loaded page. Now /eskaera/check-status returns the module's installed_version as client_version, and the eskaera page embeds the same version in data-build-version on the cart container. The JS captures the page's build version at init; on every check-status response it compares them and triggers window.location. reload() on mismatch. A sessionStorage timestamp guards against reload loops if the versions stay disagreeing (cached HTML upstream). The version bump in __manifest__.py also invalidates the asset bundle URL hash, so even users without this signalling path get fresh JS on their next navigation. This is forward-looking: clients on the old JS (no check) still need one manual refresh today, but every future deploy will auto-recover. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
bd8d87060f
commit
6e6d1e5256
4 changed files with 71 additions and 2 deletions
|
|
@ -641,6 +641,16 @@ class AplicoopWebsiteSale(WebsiteSale):
|
|||
def _decode_json_body(self):
|
||||
return _utils._decode_json_body(self, request)
|
||||
|
||||
def _get_installed_module_version(self):
|
||||
"""Return the installed version of this addon, used as a build-id
|
||||
signal so the frontend can detect a deploy and force a reload."""
|
||||
module = (
|
||||
request.env["ir.module.module"]
|
||||
.sudo()
|
||||
.search([("name", "=", "website_sale_aplicoop")], limit=1)
|
||||
)
|
||||
return module.installed_version or ""
|
||||
|
||||
def _build_group_order_unavailable_response(self, group_order, status=403):
|
||||
"""Delegate building of unavailable response to utils helper."""
|
||||
self._request = request
|
||||
|
|
@ -827,6 +837,7 @@ class AplicoopWebsiteSale(WebsiteSale):
|
|||
"current_page": page,
|
||||
"has_next": has_next,
|
||||
"total_products": total_products,
|
||||
"module_version": self._get_installed_module_version(),
|
||||
},
|
||||
)
|
||||
|
||||
|
|
@ -1370,6 +1381,7 @@ class AplicoopWebsiteSale(WebsiteSale):
|
|||
),
|
||||
"cutoff_passed": cutoff_passed,
|
||||
"cutoff_date": cutoff_date_str,
|
||||
"client_version": self._get_installed_module_version(),
|
||||
}
|
||||
return request.make_response(
|
||||
json.dumps(response_data),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue