3
0
Fork 0

[16.0][MIG] web_ir_actions_act_window_page

16.0
Holger Brunn 2023-06-28 21:55:11 +02:00
parent 766a2fba22
commit 06c146091a
9 changed files with 89 additions and 84 deletions

View File

@ -7,7 +7,7 @@ Window actions for client side paging
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6377a2a15c2f7418c0ffb06a0e658928913944755f511c116abbdc64cce831fd !! source digest: sha256:07dae326aca4830ca73888e3107f5c46bf00000bbc6c5b32be9494b495c21719
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@ -17,13 +17,13 @@ Window actions for client side paging
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github .. |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 :target: https://github.com/OCA/web/tree/16.0/web_ir_actions_act_window_page
:alt: OCA/web :alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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 :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_ir_actions_act_window_page
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png .. |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 :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
:alt: Try me on Runboat :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -61,7 +61,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_. 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. 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 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_ir_actions_act_window_page%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/web/issues/new?body=module:%20web_ir_actions_act_window_page%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. Do not contact contributors directly about support or help with technical issues.
@ -93,6 +93,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/13.0/web_ir_actions_act_window_page>`_ project on GitHub. This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_ir_actions_act_window_page>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -1,19 +1,3 @@
############################################################################## # Copyright 2023 Hunki Enterprises BV
# # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
# OpenERP, Open Source Management Solution from . import models
# This module copyright (C) 2013 Therp BV (<http://therp.nl>).
#
# 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/>.
#
##############################################################################

View File

@ -7,10 +7,14 @@
"or next next record in the form view" "or next next record in the form view"
), ),
"author": "Hunki Enterprises BV, Therp BV,Odoo Community Association (OCA)", "author": "Hunki Enterprises BV, Therp BV,Odoo Community Association (OCA)",
"version": "13.0.1.0.0", "version": "16.0.1.0.0",
"category": "Technical", "category": "Technical",
"depends": ["web"], "depends": ["web"],
"data": ["views/assets.xml"], "assets": {
"web.assets_backend": [
"web_ir_actions_act_window_page/static/src/web_ir_actions_act_window_page.esm.js",
]
},
"demo": ["demo/demo_action.xml"], "demo": ["demo/demo_action.xml"],
"installable": True, "installable": True,
"license": "AGPL-3", "license": "AGPL-3",

View File

@ -0,0 +1,3 @@
# Copyright 2023 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import ir_actions_act_window_page

View File

@ -0,0 +1,27 @@
# Copyright 2023 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models
class IrActionsActWindowPagePrev(models.AbstractModel):
_name = "ir.actions.act_window.page.prev"
_description = "Action to page to the previous record from a form view button"
def _get_readable_fields(self):
return set() # pragma: no cover
class IrActionsActWindowPageNext(models.AbstractModel):
_name = "ir.actions.act_window.page.next"
_description = "Action to page to the next record from a form view button"
def _get_readable_fields(self):
return set() # pragma: no cover
class IrActionsActWindowPageList(models.AbstractModel):
_name = "ir.actions.act_window.page.list"
_description = "Action to switch to the list view"
def _get_readable_fields(self):
return set() # pragma: no cover

View File

@ -367,9 +367,9 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6377a2a15c2f7418c0ffb06a0e658928913944755f511c116abbdc64cce831fd !! source digest: sha256:07dae326aca4830ca73888e3107f5c46bf00000bbc6c5b32be9494b495c21719
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/13.0/web_ir_actions_act_window_page"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_ir_actions_act_window_page"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=13.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_ir_actions_act_window_page"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_ir_actions_act_window_page"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This addon allows a developer to return the following action types:</p> <p>This addon allows a developer to return the following action types:</p>
<pre class="literal-block"> <pre class="literal-block">
{'type': 'ir.actions.act_window.page.next'} {'type': 'ir.actions.act_window.page.next'}
@ -407,7 +407,7 @@ to the partner form view.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_ir_actions_act_window_page%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_ir_actions_act_window_page%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -433,7 +433,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/13.0/web_ir_actions_act_window_page">OCA/web</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_ir_actions_act_window_page">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@ -1,38 +0,0 @@
// Coding: utf-8
// (c) 2013-2015 Therp BV (<http://therp.nl>)
// (c) 2023 Hunki Enterprises BV (<https://hunki-enterprises.com>)
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
odoo.define("web.ir_actions_act_window_page", function(require) {
"use strict";
var ActionManager = require("web.ActionManager");
ActionManager.include({
_handleAction: function(action, options) {
if (action.type === "ir.actions.act_window.page.prev") {
return this._executeWindowActionPage(action, options, -1);
}
if (action.type === "ir.actions.act_window.page.next") {
return this._executeWindowActionPage(action, options, 1);
}
return this._super.apply(this, arguments);
},
_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 && options.on_close.name !== "reload") {
// Suppress reloads as the pager does it
options.on_close();
}
return Promise.resolve();
},
});
});

View File

@ -0,0 +1,40 @@
/** @odoo-module **/
// (c) 2013-2015 Therp BV (<http://therp.nl>)
// (c) 2023 Hunki Enterprises BV (<https://hunki-enterprises.com>)
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import {Pager} from "@web/core/pager/pager";
import {patch} from "@web/core/utils/patch";
import {registry} from "@web/core/registry";
import {useBus} from "@web/core/utils/hooks";
const actionHandlersRegistry = registry.category("action_handlers");
async function executeWindowActionPage({env}, direction) {
return env.bus.trigger("pager:navigate", {direction});
}
async function executeWindowActionList({env}) {
return env.services.action.switchView("list");
}
actionHandlersRegistry.add("ir.actions.act_window.page.prev", async (params) =>
executeWindowActionPage(params, -1)
);
actionHandlersRegistry.add("ir.actions.act_window.page.next", async (params) =>
executeWindowActionPage(params, 1)
);
actionHandlersRegistry.add("ir.actions.act_window.page.list", async (params) =>
executeWindowActionList(params)
);
patch(Pager.prototype, "navigate event listener", {
setup() {
this._super.apply();
const handleNavigate = (ev) => this._handleNavigate(ev);
useBus(this.env.bus, "pager:navigate", handleNavigate);
},
_handleNavigate(ev) {
return this.navigate(ev.detail.direction);
},
});

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template
id="assets_backend"
name="web_ir_actions_act_window_page assets"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/web_ir_actions_act_window_page/static/src/js/web_ir_actions_act_window_page.js"
/>
</xpath>
</template>
</odoo>