From 766a2fba22aa547fe08a5f32d217c1b394a985a3 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 15 Jun 2023 13:58:45 +0200 Subject: [PATCH] [13.0][MIG] web_ir_actions_act_window_page --- .../addons/web_ir_actions_act_window_page | 1 + setup/web_ir_actions_act_window_page/setup.py | 6 + web_ir_actions_act_window_page/README.md | 68 --- web_ir_actions_act_window_page/README.rst | 98 ++++ web_ir_actions_act_window_page/__init__.py | 1 - .../__manifest__.py | 29 +- .../demo/demo_action.xml | 36 +- .../readme/CONTRIBUTORS.rst | 2 + .../readme/DESCRIPTION.rst | 15 + .../readme/USAGE.rst | 2 + .../static/description/index.html | 442 ++++++++++++++++++ .../src/js/web_ir_actions_act_window_page.js | 49 +- .../views/assets.xml | 16 +- 13 files changed, 637 insertions(+), 128 deletions(-) create mode 120000 setup/web_ir_actions_act_window_page/odoo/addons/web_ir_actions_act_window_page create mode 100644 setup/web_ir_actions_act_window_page/setup.py delete mode 100644 web_ir_actions_act_window_page/README.md create mode 100644 web_ir_actions_act_window_page/README.rst create mode 100644 web_ir_actions_act_window_page/readme/CONTRIBUTORS.rst create mode 100644 web_ir_actions_act_window_page/readme/DESCRIPTION.rst create mode 100644 web_ir_actions_act_window_page/readme/USAGE.rst create mode 100644 web_ir_actions_act_window_page/static/description/index.html diff --git a/setup/web_ir_actions_act_window_page/odoo/addons/web_ir_actions_act_window_page b/setup/web_ir_actions_act_window_page/odoo/addons/web_ir_actions_act_window_page new file mode 120000 index 000000000..f96e80a05 --- /dev/null +++ b/setup/web_ir_actions_act_window_page/odoo/addons/web_ir_actions_act_window_page @@ -0,0 +1 @@ +../../../../web_ir_actions_act_window_page \ No newline at end of file diff --git a/setup/web_ir_actions_act_window_page/setup.py b/setup/web_ir_actions_act_window_page/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_ir_actions_act_window_page/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_ir_actions_act_window_page/README.md b/web_ir_actions_act_window_page/README.md deleted file mode 100644 index 6818c5869..000000000 --- a/web_ir_actions_act_window_page/README.md +++ /dev/null @@ -1,68 +0,0 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: https://www.gnu.org/licenses/agpl - :alt: License: AGPL-3 - -================== -Client side paging -================== - -This addon allows a developer to return the following action types:: - -{'type': 'ir.actions.act_window.page.next'} - -or:: - -{'type': 'ir.actions.act_window.page.prev'} - -which trigger the form's controller to page into the requested direction on the -client side. - -A use case could be the case of a validation flow. As a developer, you set up a tree view with a domain on records to be validated. The user opens the first record in a form view and validates the record. The validation method returns the 'next' action type so that the browser window of the user is presented with the next record in the form view. - -Usage -===== - -See the 'Previous Partner' and 'Next Partner' buttons that this module's demo data adds to the partner form view. - -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/162/10.0 - -Bug Tracker -=========== - -Bugs are tracked on `GitHub Issues -`_. In case of trouble, please -check there if your issue has already been reported. If you spotted it first, -help us smash it by providing detailed and welcomed feedback. - -Credits -======= - -Images ------- - -* Odoo Community Association: `Icon `_. - -Contributors ------------- - -* Holger Brunn -* Stefan Rijnhart - -Do not contact contributors directly about support or help with technical issues. - -Maintainer ----------- - -.. image:: https://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: https://odoo-community.org - -This module is maintained by the OCA. - -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. - -To contribute to this module, please visit https://odoo-community.org. diff --git a/web_ir_actions_act_window_page/README.rst b/web_ir_actions_act_window_page/README.rst new file mode 100644 index 000000000..166357c37 --- /dev/null +++ b/web_ir_actions_act_window_page/README.rst @@ -0,0 +1,98 @@ +===================================== +Window actions for client side paging +===================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:6377a2a15c2f7418c0ffb06a0e658928913944755f511c116abbdc64cce831fd + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/13.0/web_ir_actions_act_window_page + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_ir_actions_act_window_page + :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=13.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This addon allows a developer to return the following action types:: + +{'type': 'ir.actions.act_window.page.next'} + +or:: + +{'type': 'ir.actions.act_window.page.prev'} + +which trigger the form's controller to page into the requested direction on the client +side. + +A use case could be the case of a validation flow. As a developer, you set up a tree +view with a domain on records to be validated. The user opens the first record in a form +view and validates the record. The validation method returns the 'next' action type so +that the browser window of the user is presented with the next record in the form view. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +See the 'Previous Partner' and 'Next Partner' buttons that this module's demo data adds +to the partner form view. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Hunki Enterprises BV +* Therp BV + +Contributors +~~~~~~~~~~~~ + +* Holger Brunn (https://hunki-enterprises.com) +* Stefan Rijnhart (https://opener.amsterdam) + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_ir_actions_act_window_page/__init__.py b/web_ir_actions_act_window_page/__init__.py index f69741171..1cb6c52ec 100644 --- a/web_ir_actions_act_window_page/__init__.py +++ b/web_ir_actions_act_window_page/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution diff --git a/web_ir_actions_act_window_page/__manifest__.py b/web_ir_actions_act_window_page/__manifest__.py index f7ead113d..a4586f9e2 100644 --- a/web_ir_actions_act_window_page/__manifest__.py +++ b/web_ir_actions_act_window_page/__manifest__.py @@ -1,23 +1,18 @@ -# coding: utf-8 # © 2013-2015 Therp BV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) { "name": "Window actions for client side paging", - "summary": ("Allows a developer to trigger a pager to show the previous " - "or next next record in the form view"), - "author": "Therp BV,Odoo Community Association (OCA)", - "version": "10.0.1.0.0", + "summary": ( + "Allows a developer to trigger a pager to show the previous " + "or next next record in the form view" + ), + "author": "Hunki Enterprises BV, Therp BV,Odoo Community Association (OCA)", + "version": "13.0.1.0.0", "category": "Technical", - "depends": [ - 'web', - ], - 'data': [ - 'views/assets.xml', - ], - 'demo': [ - 'demo/demo_action.xml', - ], - 'installable': True, - 'license': 'AGPL-3', - 'url': 'https://github.com/oca/web', + "depends": ["web"], + "data": ["views/assets.xml"], + "demo": ["demo/demo_action.xml"], + "installable": True, + "license": "AGPL-3", + "website": "https://github.com/OCA/web", } diff --git a/web_ir_actions_act_window_page/demo/demo_action.xml b/web_ir_actions_act_window_page/demo/demo_action.xml index 094abbc06..7ad1f2c7c 100644 --- a/web_ir_actions_act_window_page/demo/demo_action.xml +++ b/web_ir_actions_act_window_page/demo/demo_action.xml @@ -1,33 +1,41 @@ - + Previous partner - - action = {"type": "ir_actions_act_window_page_prev"} + + code + action = {"type": "ir.actions.act_window.page.prev"} Next partner - - action = {"type": "ir_actions_act_window_page_next"} + + code + action = {"type": "ir.actions.act_window.page.next"} res.partner - +
-
diff --git a/web_ir_actions_act_window_page/readme/CONTRIBUTORS.rst b/web_ir_actions_act_window_page/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..94a367e80 --- /dev/null +++ b/web_ir_actions_act_window_page/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Holger Brunn (https://hunki-enterprises.com) +* Stefan Rijnhart (https://opener.amsterdam) diff --git a/web_ir_actions_act_window_page/readme/DESCRIPTION.rst b/web_ir_actions_act_window_page/readme/DESCRIPTION.rst new file mode 100644 index 000000000..3f37f2e84 --- /dev/null +++ b/web_ir_actions_act_window_page/readme/DESCRIPTION.rst @@ -0,0 +1,15 @@ +This addon allows a developer to return the following action types:: + +{'type': 'ir.actions.act_window.page.next'} + +or:: + +{'type': 'ir.actions.act_window.page.prev'} + +which trigger the form's controller to page into the requested direction on the client +side. + +A use case could be the case of a validation flow. As a developer, you set up a tree +view with a domain on records to be validated. The user opens the first record in a form +view and validates the record. The validation method returns the 'next' action type so +that the browser window of the user is presented with the next record in the form view. diff --git a/web_ir_actions_act_window_page/readme/USAGE.rst b/web_ir_actions_act_window_page/readme/USAGE.rst new file mode 100644 index 000000000..0a69dadc6 --- /dev/null +++ b/web_ir_actions_act_window_page/readme/USAGE.rst @@ -0,0 +1,2 @@ +See the 'Previous Partner' and 'Next Partner' buttons that this module's demo data adds +to the partner form view. diff --git a/web_ir_actions_act_window_page/static/description/index.html b/web_ir_actions_act_window_page/static/description/index.html new file mode 100644 index 000000000..f109ad811 --- /dev/null +++ b/web_ir_actions_act_window_page/static/description/index.html @@ -0,0 +1,442 @@ + + + + + + +Window actions for client side paging + + + +
+

Window actions for client side paging

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

This addon allows a developer to return the following action types:

+
+{'type': 'ir.actions.act_window.page.next'}
+
+

or:

+
+{'type': 'ir.actions.act_window.page.prev'}
+
+

which trigger the form’s controller to page into the requested direction on the client +side.

+

A use case could be the case of a validation flow. As a developer, you set up a tree +view with a domain on records to be validated. The user opens the first record in a form +view and validates the record. The validation method returns the ‘next’ action type so +that the browser window of the user is presented with the next record in the form view.

+

Table of contents

+ +
+

Usage

+

See the ‘Previous Partner’ and ‘Next Partner’ buttons that this module’s demo data adds +to the partner form view.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Hunki Enterprises BV
  • +
  • Therp BV
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

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

+
+
+
+ + diff --git a/web_ir_actions_act_window_page/static/src/js/web_ir_actions_act_window_page.js b/web_ir_actions_act_window_page/static/src/js/web_ir_actions_act_window_page.js index b9fbe4fd0..d4950207c 100644 --- a/web_ir_actions_act_window_page/static/src/js/web_ir_actions_act_window_page.js +++ b/web_ir_actions_act_window_page/static/src/js/web_ir_actions_act_window_page.js @@ -1,33 +1,38 @@ -// coding: utf-8 -// © 2013-2015 Therp BV () +// Coding: utf-8 +// (c) 2013-2015 Therp BV () +// (c) 2023 Hunki Enterprises BV () // License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) -odoo.define('web.ir_actions_act_window_page', function(require) { - - var ActionManager = require('web.ActionManager'); +odoo.define("web.ir_actions_act_window_page", function(require) { + "use strict"; + var ActionManager = require("web.ActionManager"); ActionManager.include({ - ir_actions_act_window_page_prev: function(action, options) - { - if(this.inner_widget && this.inner_widget.active_view.type == 'form' && - this.inner_widget.active_view) - { - this.inner_widget.active_view.controller.pager.previous(); + _handleAction: function(action, options) { + if (action.type === "ir.actions.act_window.page.prev") { + return this._executeWindowActionPage(action, options, -1); } - if(options && options.on_close) - { - options.on_close(); + if (action.type === "ir.actions.act_window.page.next") { + return this._executeWindowActionPage(action, options, 1); } + return this._super.apply(this, arguments); }, - ir_actions_act_window_page_next: function(action, options) - { - if(this.inner_widget && this.inner_widget.active_view.type == 'form' && - this.inner_widget.active_view) - { - this.inner_widget.active_view.controller.pager.next(); + _executeWindowActionPage: function(action, options, direction) { + const controller = this.getCurrentController(); + if (controller && controller.widget && controller.widget.pager) { + if ( + this.controllerStack.length > 1 && + controller.widget.pager.state.size === 0 + ) { + // If whatever happened in the button action made the last record inaccessible + // switch back to the tree view + return this._restoreController(this.controllerStack.at(-2)); + } + controller.widget.pager[direction > 0 ? "next" : "previous"](); } - if(options && options.on_close) - { + if (options && options.on_close && options.on_close.name !== "reload") { + // Suppress reloads as the pager does it options.on_close(); } + return Promise.resolve(); }, }); }); diff --git a/web_ir_actions_act_window_page/views/assets.xml b/web_ir_actions_act_window_page/views/assets.xml index f045d63ac..0febb1e93 100644 --- a/web_ir_actions_act_window_page/views/assets.xml +++ b/web_ir_actions_act_window_page/views/assets.xml @@ -1,11 +1,15 @@ - + -