Tower: upload cx_web_refresh_from_backend 18.0.1.0.0 (was 18.0.1.0.0, via marketplace)

This commit is contained in:
2026-05-03 18:55:11 +00:00
parent ed5f0d6535
commit e50acbac83
19 changed files with 1636 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
# Copyright 2025 Cetmix OÜ
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import res_users

View File

@@ -0,0 +1,50 @@
# Copyright 2025 Cetmix OÜ
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo import models
class ResUsers(models.Model):
_inherit = "res.users"
def reload_views(self, model, view_types=None, rec_ids=None):
"""
Trigger UI reload for selected users and record IDs.
This method allows to reload specific views from the backend.
Be aware that when reloading form views, if a user is currently
doing some updates, those updates may be lost when the form reloads
(no confirmation dialog on the client).
:param model: str, Model name (e.g., 'res.partner')
:param view_types: list of str, optional, View types to reload
(e.g., ['form', 'kanban']). Leave blank to reload all views.
:param rec_ids: list of int, optional, View will be reloaded only if a record
with id from the list is present in the view.
Example usage:
# Reload the kanban and form views for all salespeople
# when an opportunity is won.
# Will reload views only if the current opportunity is being displayed
group_id = self.env.ref("sales_team.group_sale_salesman").id
users_to_reload = self.env["res.users"].search(
[("groups_id", "in", [group_id])]
)
users_to_reload.reload_views(
model="crm.lead",
view_types=["kanban", "form"],
rec_ids=[self.ids]
)
"""
# Prepare the message payload
bus_message = {
"model": model,
"view_types": view_types or [],
"rec_ids": rec_ids or [],
}
# Send one notification per user's partner in deterministic order.
bus_bus = self.env["bus.bus"]
for user in self.sorted("id"):
bus_bus._sendone(user.partner_id, "web.refresh_view", bus_message)