diff --git a/muk_web_client_refresh/__manifest__.py b/muk_web_client_refresh/__manifest__.py index 738f926..1a3f394 100644 --- a/muk_web_client_refresh/__manifest__.py +++ b/muk_web_client_refresh/__manifest__.py @@ -20,7 +20,7 @@ { "name": "MuK Web Refresh", "summary": """Web Client Refresh""", - "version": "11.0.2.0.0", + "version": "11.0.2.1.0", "category": "Extra Tools", "license": "AGPL-3", "website": "http://www.mukit.at", diff --git a/muk_web_client_refresh/controllers/main.py b/muk_web_client_refresh/controllers/main.py index b325d89..3df727f 100644 --- a/muk_web_client_refresh/controllers/main.py +++ b/muk_web_client_refresh/controllers/main.py @@ -30,5 +30,5 @@ class RefreshController(http.Controller): def refresh_delay(self, **kw): params = request.env['ir.config_parameter'].sudo() return { - 'refresh_delay': int(params.get_param("muk_web_client_refresh.refresh_delay", default=10000)) + 'refresh_delay': int(params.get_param("muk_web_client_refresh.refresh_delay", default=1000)) } \ No newline at end of file diff --git a/muk_web_client_refresh/data/refresh_actions.xml b/muk_web_client_refresh/data/refresh_actions.xml index d1a1bf6..1d4e8eb 100644 --- a/muk_web_client_refresh/data/refresh_actions.xml +++ b/muk_web_client_refresh/data/refresh_actions.xml @@ -24,7 +24,11 @@ code on_create - env["bus.bus"].sendone("refresh", {"model": model._name, "uid": env.user.id, "ids": (record | records).mapped("id")}) + env["bus.bus"].sendone("refresh", { + "create": record.exists() and record.create_date == record.write_date, + "model": model._name, + "uid": env.user.id, + "ids": (record | records).mapped("id")}) @@ -32,7 +36,11 @@ code on_write - env["bus.bus"].sendone("refresh", {"model": model._name, "uid": env.user.id, "ids": (record | records).mapped("id")}) + env["bus.bus"].sendone("refresh", { + "create": record.exists() and record.create_date == record.write_date, + "model": model._name, + "uid": env.user.id, + "ids": (record | records).mapped("id")}) @@ -40,7 +48,23 @@ code on_unlink - env["bus.bus"].sendone("refresh", {"model": model._name, "uid": env.user.id, "ids": (record | records).mapped("id")}) + env["bus.bus"].sendone("refresh", { + "create": record.exists() and record.create_date == record.write_date, + "model": model._name, + "uid": env.user.id, + "ids": (record | records).mapped("id")}) + + + + Refresh Users on Creation/Update + + code + on_create_or_write + env["bus.bus"].sendone("refresh", { + "create": record.exists() and record.create_date == record.write_date, + "model": model._name, + "uid": env.user.id, + "ids": (record | records).mapped("id")}) \ No newline at end of file diff --git a/muk_web_client_refresh/doc/changelog.rst b/muk_web_client_refresh/doc/changelog.rst index d161cc9..dbc118c 100644 --- a/muk_web_client_refresh/doc/changelog.rst +++ b/muk_web_client_refresh/doc/changelog.rst @@ -1,3 +1,8 @@ +`2.1.0` +------- + +- Reduced unnecessary refresh calls + `2.0.0` ------- diff --git a/muk_web_client_refresh/static/src/js/client_refresh.js b/muk_web_client_refresh/static/src/js/client_refresh.js index 7dec137..0b7cb0a 100644 --- a/muk_web_client_refresh/static/src/js/client_refresh.js +++ b/muk_web_client_refresh/static/src/js/client_refresh.js @@ -43,23 +43,27 @@ WebClient.include({ return this._super.apply(this, arguments); }, refresh: function(message) { - var self = this; - utils.delay(function() { - var widget = self.action_manager && self.action_manager.inner_widget; - var active_view = widget ? widget.active_view : false; - if (active_view && message.uid && session.uid !== message.uid) { - var controller = self.action_manager.inner_widget.active_view.controller; - if(controller.modelName === message.model && controller.mode === "readonly") { - if(active_view.type === "form" && message.ids.includes(widget.env.currentId)) { - controller.reload(); - } else if(active_view.type === "list") { - controller.reload(); - } else if(active_view.type === "kanban") { - controller.reload(); - } - } + var widget = this.action_manager && this.action_manager.inner_widget; + var active_view = widget ? widget.active_view : false; + if (active_view && message.uid && session.uid !== message.uid) { + var controller = this.action_manager.inner_widget.active_view.controller; + if(controller.modelName === message.model && controller.mode === "readonly") { + if(active_view.type === "form" && message.ids.includes(widget.env.currentId)) { + this.reload(controller); + } else if(active_view.type === "list" && + (message.create || _.intersection(message.ids, widget.env.ids) >= 1)) { + this.reload(controller); + } else if(active_view.type === "kanban" && + (message.create || _.intersection(message.ids, widget.env.ids) >= 1)) { + this.reload(controller); + } } - }, self.refresh_delay || 1000); + } + }, + reload: function(controller) { + utils.delay(function() { + controller.reload(); + }, this.refresh_delay || 1000); }, }); diff --git a/muk_web_client_refresh/views/refresh_action_view.xml b/muk_web_client_refresh/views/refresh_action_view.xml index e5727da..0ab90b9 100644 --- a/muk_web_client_refresh/views/refresh_action_view.xml +++ b/muk_web_client_refresh/views/refresh_action_view.xml @@ -41,7 +41,7 @@ base.automation.tree base.automation - + @@ -57,13 +57,21 @@ tree,form [ - ['code', '=', 'env["bus.bus"].sendone("refresh", {"model": model._name, "uid": env.user.id, "ids": (record | records).mapped("id")})'] + ['code', '=', 'env["bus.bus"].sendone("refresh", { + "create": record.exists() and record.create_date == record.write_date, + "model": model._name, + "uid": env.user.id, + "ids": (record | records).mapped("id")})'] ] { 'default_state': 'code', - 'default_code': 'env["bus.bus"].sendone("refresh", {"model": model._name, "uid": env.user.id, "ids": (record | records).mapped("id")})' + 'default_code': 'env["bus.bus"].sendone("refresh", { + "create": record.exists() and record.create_date == record.write_date, + "model": model._name, + "uid": env.user.id, + "ids": (record | records).mapped("id")})' }