Browse Source

publish muk_web_client_refresh - 12.0

pull/35/head
MuK IT GmbH 6 years ago
parent
commit
80f1526d7b
  1. 2
      muk_web_client_refresh/__manifest__.py
  2. 1
      muk_web_client_refresh/models/__init__.py
  3. 56
      muk_web_client_refresh/models/base.py
  4. 51
      muk_web_client_refresh/models/ir_actions.py

2
muk_web_client_refresh/__manifest__.py

@ -20,7 +20,7 @@
{
"name": "MuK Web Refresh",
"summary": """Web Client Refresh""",
"version": "12.0.2.1.4",
"version": "12.0.2.1.5",
"category": "Extra Tools",
"license": "AGPL-3",
"website": "http://www.mukit.at",

1
muk_web_client_refresh/models/__init__.py

@ -17,5 +17,6 @@
#
###################################################################################
from . import base
from . import ir_actions
from . import res_config_settings

56
muk_web_client_refresh/models/base.py

@ -0,0 +1,56 @@
###################################################################################
#
# Copyright (C) 2018 MuK IT GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
import logging
from odoo import api, models, fields
_logger = logging.getLogger(__name__)
class Base(models.AbstractModel):
_inherit = 'base'
@api.multi
def refresh_views(self, model=None, ids=None, user=None, create=False):
""" Informs the web client to refresh the views that belong to the
corresponding model by sending a message to the bus.
There are two ways to use this method. First by calling it
without any parameters. In this case, the views are determined
and updated using the current records in self. Alternatively,
the method can also be called with corresponding parameters
to explicitly update a view from another model.
:param model: The model of the records is used to find the
corresponding views
:param ids: IDs of the records are used to determine which
records have been updated
:param user: The user (res.users) is used to determine whether
the current one has caused the refresh
:param create: Indicates whether the record has been newly
created or updated
"""
if self.exists() or ids:
record = next(iter(self)) if len(self) > 1 else self
self.env['bus.bus'].sendone('refresh', {
'create': create if ids else record.exists() and record.create_date == record.write_date or False,
'model': model or self._name,
'uid': user and user.id or False if ids else self.env.user.id,
'ids': ids or self.mapped('id')})

51
muk_web_client_refresh/models/ir_actions.py

@ -2,35 +2,18 @@
#
# Copyright (C) 2018 MuK IT GmbH
#
# Odoo Proprietary License v1.0
#
# This software and associated files (the "Software") may only be used
# (executed, modified, executed after modifications) if you have
# purchased a valid license from the authors, typically via Odoo Apps,
# or if you have received a written agreement from the authors of the
# Software (see the COPYRIGHT file).
#
# You may develop Odoo modules that use the Software as a library
# (typically by depending on it, importing it and using its resources),
# but without copying any source code or material from the Software.
# You may distribute those modules under the license of your choice,
# provided that this license is compatible with the terms of the Odoo
# Proprietary License (For example: LGPL, MIT, or proprietary licenses
# similar to this one).
#
# It is forbidden to publish, distribute, sublicense, or sell copies of
# the Software or modified copies of the Software.
#
# The above copyright notice and this permission notice must be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
@ -59,9 +42,9 @@ class ServerActions(models.Model):
def run_action_refresh_multi(self, action, eval_context={}):
record = eval_context.get('record', None)
records = eval_context.get('records', None)
self.env["bus.bus"].sendone("refresh", {
"uid": self.env.uid,
"model": action.model_name,
"ids": list(set().union(record and record.ids or [], records and records.ids or [])),
"create": record and record.exists() and record.create_date == record.write_date,
self.env['bus.bus'].sendone('refresh', {
'uid': self.env.uid,
'model': action.model_name,
'ids': list(set().union(record and record.ids or [], records and records.ids or [])),
'create': record and record.exists() and record.create_date == record.write_date,
})
Loading…
Cancel
Save