Metadata-Version: 2.1
Name: odoo-addon-web_refresh_from_backend
Version: 16.0.1.0.0.4
Summary: Refresh views from backend
Home-page: https://github.com/OCA/web
Author: Cetmix, Odoo Community Association (OCA)
Author-email: support@odoo-community.org
License: LGPL-3
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 16.0
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
Requires-Python: >=3.10
Requires-Dist: odoo<16.1dev,>=16.0a

.. image:: https://odoo-community.org/readme-banner-image
   :target: https://odoo-community.org/get-involved?utm_source=readme
   :alt: Odoo Community Association

========================
Web Refresh From Backend
========================

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:3fa12acb12fc8ba91141e344bd5dde385fc00e19cd307fd40c253be39dd8111f
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
    :target: https://odoo-community.org/page/development-status
    :alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
    :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
    :alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
    :target: https://github.com/OCA/web/tree/16.0/web_refresh_from_backend
    :alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
    :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_refresh_from_backend
    :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
    :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
    :alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Backend UI Reload Module
========================

This is a **technical module** that allows triggering a **UI reload**
from the backend. It enables triggering the reload action for selected
users and record IDs.

**NB:** this module refreshes views using direct actions instead of
calling ``action_reload``. This is done to avoid possible glitches and
is aligned with the same approach used in the
`web_refreshed <https://github.com/OCA/web/tree/16.0/web_refresher>`__
module.

--------------

🔧 Helper Function: ``reload_views``
------------------------------------

A special helper function ``reload_views`` is added to the ``res.users``
model.

**Arguments**
~~~~~~~~~~~~~

+----------------+--------------------------+--------------------------+
| Argument       | Type                     | Description              |
+================+==========================+==========================+
| **model**      | ``Char``                 | Model name, e.g.         |
|                |                          | ``'res.partner'``        |
+----------------+--------------------------+--------------------------+
| **view_types** | ``List of Char``         | View types to reload,    |
|                | *(optional)*             | e.g.                     |
|                |                          | ``["form", "kanban"]``.  |
|                |                          | Leave blank to reload    |
|                |                          | all views.               |
+----------------+--------------------------+--------------------------+
| **rec_ids**    | ``List of Integer``      | The view will be         |
|                | *(optional)*             | reloaded only if a       |
|                |                          | record with an ID from   |
|                |                          | this list is present in  |
|                |                          | the view.                |
+----------------+--------------------------+--------------------------+

--------------

⚠️ Important Notes
------------------

Use this function **wisely**.

When reloading **form views**, be aware that if a user is currently
editing a record, **their unsaved updates may be lost**.

**Table of contents**

.. contents::
   :local:

Usage
=====

🧩 Example Usage
----------------

Below is a code snippet showing how to use the ``reload_views`` helper
function.

.. code:: python

   # 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.id],
   )

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_refresh_from_backend%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Cetmix

Contributors
------------

- Cetmix

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
   :alt: Odoo Community Association
   :target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_refresh_from_backend>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
