3
0
Fork 0

[16.0][MIG] web_action_conditionable: Migration to 16.0

16.0
Jasper Jumelet 2023-03-09 11:57:48 +01:00 committed by Minh Chien
parent 4a8cf5e9d9
commit e08f0fc6a6
9 changed files with 85 additions and 64 deletions

View File

@ -0,0 +1 @@
../../../../web_action_conditionable

View File

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

View File

@ -14,14 +14,14 @@ web_action_conditionable
: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/15.0/web_action_conditionable :target: https://github.com/OCA/web/tree/16.0/web_action_conditionable
: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-15-0/web-15-0-web_action_conditionable :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_action_conditionable
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/162/15.0 :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/web&target_branch=16.0
:alt: Try me on Runbot :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -55,7 +55,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 smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_action_conditionable%0Aversion:%2015.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_action_conditionable%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.
@ -74,6 +74,14 @@ Contributors
* André Paramés <github@andreparames.com> (https://www.acsone.eu/) * André Paramés <github@andreparames.com> (https://www.acsone.eu/)
* Alexandre Díaz <alexandre.diaz@tecnativa.com> * Alexandre Díaz <alexandre.diaz@tecnativa.com>
* Sudhir Arya <sudhir@erpharbor.com> * Sudhir Arya <sudhir@erpharbor.com>
* Jasper Jumelet <jasper.jumelet@codeforward.nl>
* `Trobz <https://trobz.com>`_:
* Nguyễn Minh Chiến <chien@trobz.com>
Other credits
~~~~~~~~~~~~~
The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@ -88,6 +96,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/15.0/web_action_conditionable>`_ project on GitHub. This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_action_conditionable>`_ 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,7 +1,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "web_action_conditionable", "name": "web_action_conditionable",
"version": "15.0.1.0.0", "version": "16.0.1.0.0",
"depends": ["base", "web"], "depends": ["base", "web"],
"data": [], "data": [],
"author": "Cristian Salamea,Odoo Community Association (OCA)", "author": "Cristian Salamea,Odoo Community Association (OCA)",
@ -9,7 +9,7 @@
"license": "AGPL-3", "license": "AGPL-3",
"assets": { "assets": {
"web.assets_backend": [ "web.assets_backend": [
"web_action_conditionable/static/src/js/field_one2many.js", "web_action_conditionable/static/src/components/*",
], ],
}, },
"installable": True, "installable": True,

View File

@ -2,3 +2,6 @@
* André Paramés <github@andreparames.com> (https://www.acsone.eu/) * André Paramés <github@andreparames.com> (https://www.acsone.eu/)
* Alexandre Díaz <alexandre.diaz@tecnativa.com> * Alexandre Díaz <alexandre.diaz@tecnativa.com>
* Sudhir Arya <sudhir@erpharbor.com> * Sudhir Arya <sudhir@erpharbor.com>
* Jasper Jumelet <jasper.jumelet@codeforward.nl>
* `Trobz <https://trobz.com>`_:
* Nguyễn Minh Chiến <chien@trobz.com>

View File

@ -0,0 +1 @@
The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>web_action_conditionable</title> <title>web_action_conditionable</title>
<style type="text/css"> <style type="text/css">
@ -367,7 +367,7 @@ 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. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/15.0/web_action_conditionable"><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-15-0/web-15-0-web_action_conditionable"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-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_action_conditionable"><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_action_conditionable"><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/webui/builds.html?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>Add support for conditions on create and delete actions on One2Many fields.</p> <p>Add support for conditions on create and delete actions on One2Many fields.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
@ -377,7 +377,8 @@ ul.auto-toc {
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul> <li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li> <li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li> <li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li> <li><a class="reference internal" href="#other-credits" id="id6">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -399,7 +400,7 @@ ul.auto-toc {
<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 smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_action_conditionable%0Aversion:%2015.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_action_conditionable%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">
@ -417,16 +418,29 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>André Paramés &lt;<a class="reference external" href="mailto:github&#64;andreparames.com">github&#64;andreparames.com</a>&gt; (<a class="reference external" href="https://www.acsone.eu/">https://www.acsone.eu/</a>)</li> <li>André Paramés &lt;<a class="reference external" href="mailto:github&#64;andreparames.com">github&#64;andreparames.com</a>&gt; (<a class="reference external" href="https://www.acsone.eu/">https://www.acsone.eu/</a>)</li>
<li>Alexandre Díaz &lt;<a class="reference external" href="mailto:alexandre.diaz&#64;tecnativa.com">alexandre.diaz&#64;tecnativa.com</a>&gt;</li> <li>Alexandre Díaz &lt;<a class="reference external" href="mailto:alexandre.diaz&#64;tecnativa.com">alexandre.diaz&#64;tecnativa.com</a>&gt;</li>
<li>Sudhir Arya &lt;<a class="reference external" href="mailto:sudhir&#64;erpharbor.com">sudhir&#64;erpharbor.com</a>&gt;</li> <li>Sudhir Arya &lt;<a class="reference external" href="mailto:sudhir&#64;erpharbor.com">sudhir&#64;erpharbor.com</a>&gt;</li>
<li>Jasper Jumelet &lt;<a class="reference external" href="mailto:jasper.jumelet&#64;codeforward.nl">jasper.jumelet&#64;codeforward.nl</a>&gt;</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://trobz.com">Trobz</a>:</dt>
<dd><ul class="first last">
<li>Nguyễn Minh Chiến &lt;<a class="reference external" href="mailto:chien&#64;trobz.com">chien&#64;trobz.com</a>&gt;</li>
</ul>
</dd>
</dl>
</li>
</ul> </ul>
</div> </div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#id6">Other credits</a></h2>
<p>The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp</p>
</div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2> <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p> <p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<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/15.0/web_action_conditionable">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_action_conditionable">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

@ -0,0 +1,37 @@
/** @odoo-module **/
import {X2ManyField} from "@web/views/fields/x2many/x2many_field";
import {XMLParser} from "@web/core/utils/xml";
import {evaluateExpr} from "@web/core/py_js/py";
import {patch} from "@web/core/utils/patch";
patch(X2ManyField.prototype, "web_action_conditionable_FieldOne2Many", {
get rendererProps() {
this.updateActiveActions();
return this._super(...arguments);
},
updateActiveActions() {
if (this.viewMode === "list" && this.activeActions.type === "one2many") {
const self = this;
const parser = new XMLParser();
const archInfo = this.activeField.views[this.viewMode];
const xmlDoc = parser.parseXML(archInfo.__rawArch);
["create", "delete"].forEach(function (item) {
if (self.activeActions[item] && _.has(xmlDoc.attributes, item)) {
const expr = xmlDoc.getAttribute(item);
try {
self.activeActions[item] = evaluateExpr(
expr,
self.props.record.data
);
} catch (ignored) {
console.log(
"[web_action_conditionable] unrecognized expr '" +
expr +
"', ignoring"
);
}
}
});
}
},
});

View File

@ -1,49 +0,0 @@
/* global py */
/* Copyright 2019 Alexandre Díaz
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
odoo.define("web.web_action_conditionable", function (require) {
"use strict";
var FieldOne2Many = require("web.relational_fields").FieldOne2Many;
FieldOne2Many.include({
init: function () {
var self = this;
try {
return this._super.apply(this, arguments);
} catch (error) {
var arch = this.view && this.view.arch;
if (arch) {
["create", "delete"].forEach(function (item) {
if (!_.has(arch.attrs, item)) {
self.activeActions[item] = arch.attrs[item]
? Boolean(JSON.parse(arch.attrs[item]))
: true;
return;
}
var expr = arch.attrs[item];
try {
self.activeActions[item] = py
.evaluate(py.parse(py.tokenize(expr)), self.recordData)
.toJSON();
} catch (ignored) {
console.log(
"[web_action_conditionable] unrecognized expr '" +
expr +
"', ignoring"
);
}
});
this.editable = arch.attrs.editable;
this._canQuickEdit = arch.tag === "tree";
} else {
this._canQuickEdit = false;
}
this._computeAvailableActions(self.record);
if (this.attrs.columnInvisibleFields) {
this._processColumnInvisibleFields();
}
}
},
});
});