|
| 1 | +.. image:: https://odoo-community.org/readme-banner-image |
| 2 | + :target: https://odoo-community.org/get-involved?utm_source=readme |
| 3 | + :alt: Odoo Community Association |
| 4 | + |
| 5 | +======================== |
| 6 | +Web Refresh From Backend |
| 7 | +======================== |
| 8 | + |
| 9 | +.. |
| 10 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 11 | + !! This file is generated by oca-gen-addon-readme !! |
| 12 | + !! changes will be overwritten. !! |
| 13 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 14 | + !! source digest: sha256:2513ead70de52d1dd678016ee4f5991596bf94a25cfbdf5b62a4f4ef85bec099 |
| 15 | + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 16 | +
|
| 17 | +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png |
| 18 | + :target: https://odoo-community.org/page/development-status |
| 19 | + :alt: Beta |
| 20 | +.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png |
| 21 | + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html |
| 22 | + :alt: License: LGPL-3 |
| 23 | +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github |
| 24 | + :target: https://github.com/OCA/web/tree/16.0/web_refresh_from_backend |
| 25 | + :alt: OCA/web |
| 26 | +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png |
| 27 | + :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_refresh_from_backend |
| 28 | + :alt: Translate me on Weblate |
| 29 | +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png |
| 30 | + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0 |
| 31 | + :alt: Try me on Runboat |
| 32 | + |
| 33 | +|badge1| |badge2| |badge3| |badge4| |badge5| |
| 34 | + |
| 35 | +This is a **technical module** that allows triggering a **UI reload** |
| 36 | +from the backend. It enables triggering the reload action for selected |
| 37 | +users and record IDs. |
| 38 | + |
| 39 | +**NB:** this module refreshes views using direct actions instead of |
| 40 | +calling ``action_reload``. This is done to avoid possible glitches and |
| 41 | +is aligned with the same approach used in the |
| 42 | +`web_refreshed <https://github.com/OCA/web/tree/16.0/web_refresher>`__ |
| 43 | +module. |
| 44 | + |
| 45 | +-------------- |
| 46 | + |
| 47 | +🔧 Helper Function: ``reload_views`` |
| 48 | +------------------------------------ |
| 49 | + |
| 50 | +A special helper function ``reload_views`` is added to the ``res.users`` |
| 51 | +model. |
| 52 | + |
| 53 | +**Arguments** |
| 54 | +~~~~~~~~~~~~~ |
| 55 | + |
| 56 | ++----------------+-------------------------+-------------------------+ |
| 57 | +| Argument | Type | Description | |
| 58 | ++================+=========================+=========================+ |
| 59 | +| **model** | ``Char`` | Model name, e.g. | |
| 60 | +| | | ``'res.partner'`` | |
| 61 | ++----------------+-------------------------+-------------------------+ |
| 62 | +| **view_types** | ``List of Char`` | View types to reload, | |
| 63 | +| | *(optional)* | e.g. | |
| 64 | +| | | ``["form", "kanban"]``. | |
| 65 | +| | | Leave blank to reload | |
| 66 | +| | | all views. | |
| 67 | ++----------------+-------------------------+-------------------------+ |
| 68 | +| **rec_ids** | ``List of Integer`` | The view will be | |
| 69 | +| | *(optional)* | reloaded only if a | |
| 70 | +| | | record with an ID from | |
| 71 | +| | | this list is present in | |
| 72 | +| | | the view. | |
| 73 | ++----------------+-------------------------+-------------------------+ |
| 74 | + |
| 75 | +-------------- |
| 76 | + |
| 77 | +⚠️ Important Notes |
| 78 | +------------------ |
| 79 | + |
| 80 | +Use this function **wisely**. |
| 81 | + |
| 82 | +When reloading **form views**, be aware that if a user is currently |
| 83 | +editing a record, **their unsaved updates may be lost**. |
| 84 | + |
| 85 | +**Table of contents** |
| 86 | + |
| 87 | +.. contents:: |
| 88 | + :local: |
| 89 | + |
| 90 | +Usage |
| 91 | +===== |
| 92 | + |
| 93 | +🧩 Example Usage |
| 94 | +---------------- |
| 95 | + |
| 96 | +Below is a code snippet showing how to use the ``reload_views`` helper |
| 97 | +function. |
| 98 | + |
| 99 | +.. code:: python |
| 100 | +
|
| 101 | + # Reload the kanban and form views for all salespeople when an opportunity is won |
| 102 | + # Will reload views only if the current opportunity is being displayed |
| 103 | +
|
| 104 | + group_id = self.env.ref("sales_team.group_sale_salesman").id |
| 105 | + users_to_reload = self.env["res.users"].search([("groups_id", "in", [group_id])]) |
| 106 | + users_to_reload.reload_views( |
| 107 | + model="crm.lead", |
| 108 | + view_types=["kanban", "form"], |
| 109 | + rec_ids=[self.id], |
| 110 | + ) |
| 111 | +
|
| 112 | +Bug Tracker |
| 113 | +=========== |
| 114 | + |
| 115 | +Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_. |
| 116 | +In case of trouble, please check there if your issue has already been reported. |
| 117 | +If you spotted it first, help us to smash it by providing a detailed and welcomed |
| 118 | +`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**>`_. |
| 119 | + |
| 120 | +Do not contact contributors directly about support or help with technical issues. |
| 121 | + |
| 122 | +Credits |
| 123 | +======= |
| 124 | + |
| 125 | +Authors |
| 126 | +------- |
| 127 | + |
| 128 | +* Cetmix |
| 129 | + |
| 130 | +Contributors |
| 131 | +------------ |
| 132 | + |
| 133 | +- Cetmix |
| 134 | + |
| 135 | +Maintainers |
| 136 | +----------- |
| 137 | + |
| 138 | +This module is maintained by the OCA. |
| 139 | + |
| 140 | +.. image:: https://odoo-community.org/logo.png |
| 141 | + :alt: Odoo Community Association |
| 142 | + :target: https://odoo-community.org |
| 143 | + |
| 144 | +OCA, or the Odoo Community Association, is a nonprofit organization whose |
| 145 | +mission is to support the collaborative development of Odoo features and |
| 146 | +promote its widespread use. |
| 147 | + |
| 148 | +This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_refresh_from_backend>`_ project on GitHub. |
| 149 | + |
| 150 | +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
0 commit comments