mirror of https://github.com/OCA/web.git
[MIG] web_widget_dropdown_dynamic: Migration to 18.0
parent
20a9a82076
commit
a8789ec0f0
|
@ -17,22 +17,22 @@ Dynamic Dropdown Widget
|
|||
: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/17.0/web_widget_dropdown_dynamic
|
||||
:target: https://github.com/OCA/web/tree/18.0/web_widget_dropdown_dynamic
|
||||
:alt: OCA/web
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_widget_dropdown_dynamic
|
||||
:target: https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_widget_dropdown_dynamic
|
||||
: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=17.0
|
||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0
|
||||
:alt: Try me on Runboat
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
Dynamic dropdown widget that supports resolving options from backend of:
|
||||
|
||||
- ``fields.Char``
|
||||
- ``fields.Integer``
|
||||
- ``fields.Selection``
|
||||
- ``fields.Char``
|
||||
- ``fields.Integer``
|
||||
- ``fields.Selection``
|
||||
|
||||
**NOTE:** This widget is not intended to *extend* ``fields.Selection``,
|
||||
but to filter selection values. For fully-dynamic set of options, use
|
||||
|
@ -84,7 +84,7 @@ 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_widget_dropdown_dynamic%0Aversion:%2017.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_widget_dropdown_dynamic%0Aversion:%2018.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.
|
||||
|
||||
|
@ -99,23 +99,25 @@ Authors
|
|||
Contributors
|
||||
------------
|
||||
|
||||
- `CorporateHub <https://corporatehub.eu/>`__
|
||||
- `CorporateHub <https://corporatehub.eu/>`__
|
||||
|
||||
- Alexey Pelykh <alexey.pelykh@corphub.eu>
|
||||
- Alexey Pelykh <alexey.pelykh@corphub.eu>
|
||||
|
||||
- `Therp BV <https://therp.nl/>`__
|
||||
- `Therp BV <https://therp.nl/>`__
|
||||
|
||||
- Ronald Portier <ronald@therp.nl>
|
||||
- Ronald Portier <ronald@therp.nl>
|
||||
|
||||
- Thanakrit Pintana <thanakrit.p39@gmail.com>
|
||||
- Thanakrit Pintana <thanakrit.p39@gmail.com>
|
||||
|
||||
- `Trobz <https://trobz.com>`__:
|
||||
- `Trobz <https://trobz.com>`__:
|
||||
|
||||
- Son Ho <sonho@trobz.com>
|
||||
- Son Ho <sonho@trobz.com>
|
||||
|
||||
- `Tecnativa <https://www.tecnativa.com>`__:
|
||||
- `Tecnativa <https://www.tecnativa.com>`__:
|
||||
|
||||
- Carlos Roca
|
||||
- Carlos Roca
|
||||
|
||||
- ``Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>``\ \_
|
||||
|
||||
Other credits
|
||||
-------------
|
||||
|
@ -136,6 +138,6 @@ 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/17.0/web_widget_dropdown_dynamic>`_ project on GitHub.
|
||||
This module is part of the `OCA/web <https://github.com/OCA/web/tree/18.0/web_widget_dropdown_dynamic>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"name": "Dynamic Dropdown Widget",
|
||||
"summary": "This module adds support for dynamic dropdown widget",
|
||||
"category": "Web",
|
||||
"version": "17.0.1.0.0",
|
||||
"version": "18.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"author": "CorporateHub, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/web",
|
||||
|
|
|
@ -14,3 +14,4 @@
|
|||
|
||||
- [Tecnativa](https://www.tecnativa.com):
|
||||
- Carlos Roca
|
||||
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`_
|
||||
|
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
|||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:cd8f2fbb81d5981346094e7fb21bd25632e10536593177a28be1aca666f715a5
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/web/tree/17.0/web_widget_dropdown_dynamic"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_widget_dropdown_dynamic"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=17.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 image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/web/tree/18.0/web_widget_dropdown_dynamic"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_widget_dropdown_dynamic"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p>Dynamic dropdown widget that supports resolving options from backend of:</p>
|
||||
<blockquote>
|
||||
<ul class="simple">
|
||||
|
@ -431,7 +431,7 @@ and Two.</p>
|
|||
<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.
|
||||
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_widget_dropdown_dynamic%0Aversion:%2017.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_widget_dropdown_dynamic%0Aversion:%2018.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>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
|
@ -469,6 +469,8 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|||
<li>Carlos Roca</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p class="first"><tt class="docutils literal">Heliconia Solutions Pvt. Ltd. <span class="pre"><https://www.heliconia.io></span></tt>_</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="other-credits">
|
||||
|
@ -485,7 +487,7 @@ by Camptocamp</p>
|
|||
<p>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.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/17.0/web_widget_dropdown_dynamic">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/18.0/web_widget_dropdown_dynamic">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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
/** @odoo-module **/
|
||||
import {_lt} from "@web/core/l10n/translation";
|
||||
import {_t} from "@web/core/l10n/translation";
|
||||
import {registry} from "@web/core/registry";
|
||||
import {standardFieldProps} from "@web/views/fields/standard_field_props";
|
||||
import {Component, onWillStart, onWillUpdateProps} from "@odoo/owl";
|
||||
import {useOwnedDialogs} from "@web/core/utils/hooks";
|
||||
|
||||
export class FieldDynamicDropdown extends Component {
|
||||
static template = "web.SelectionField";
|
||||
|
@ -12,6 +13,8 @@ export class FieldDynamicDropdown extends Component {
|
|||
context: {type: Object},
|
||||
};
|
||||
setup() {
|
||||
super.setup();
|
||||
this.dialogs = useOwnedDialogs();
|
||||
this.type = this.props.record.fields[this.props.name].type;
|
||||
onWillStart(async () => {
|
||||
this.specialData = await this._fetchSpecialData(this.props);
|
||||
|
@ -34,8 +37,8 @@ export class FieldDynamicDropdown extends Component {
|
|||
return specialDataCaches[key];
|
||||
}
|
||||
get options() {
|
||||
var field_type = this.type || "";
|
||||
if (["char", "integer", "selection"].includes(field_type)) {
|
||||
const fieldType = this.type || "";
|
||||
if (["char", "integer", "selection"].includes(fieldType)) {
|
||||
if (
|
||||
this.props.record.data[this.props.name] &&
|
||||
!this.specialData
|
||||
|
@ -58,8 +61,8 @@ export class FieldDynamicDropdown extends Component {
|
|||
* @param {Event} ev
|
||||
*/
|
||||
onChange(ev) {
|
||||
var isInvalid = false;
|
||||
var value = JSON.parse(ev.target.value);
|
||||
let isInvalid = false;
|
||||
let value = JSON.parse(ev.target.value);
|
||||
if (this.type === "integer") {
|
||||
value = Number(value);
|
||||
if (!value) {
|
||||
|
@ -79,11 +82,11 @@ export class FieldDynamicDropdown extends Component {
|
|||
}
|
||||
export const dynamicDropdownField = {
|
||||
component: FieldDynamicDropdown,
|
||||
displayName: _lt("Dynamic Dropdown"),
|
||||
displayName: _t("Dynamic Dropdown"),
|
||||
supportedTypes: ["char", "integer", "selection"],
|
||||
extractProps: (fieldInfo, dynamicInfo) => ({
|
||||
method: fieldInfo.options?.values,
|
||||
context: dynamicInfo.context,
|
||||
extractProps: ({options}, {context}) => ({
|
||||
method: options?.values,
|
||||
context,
|
||||
}),
|
||||
};
|
||||
registry.category("fields").add("dynamic_dropdown", dynamicDropdownField);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import {editInput, getFixture} from "@web/../tests/helpers/utils";
|
||||
import {makeView, setupViewRegistries} from "@web/../tests/views/helpers";
|
||||
const {QUnit} = window;
|
||||
import {QUnit} from "@web/static/lib/qunit/qunit";
|
||||
|
||||
let serverData = {};
|
||||
let target = getFixture();
|
||||
|
@ -93,8 +93,6 @@ QUnit.module("web_widget_dropdown_dynamic", (hooks) => {
|
|||
});
|
||||
QUnit.test("values are fetched w/o context (char)", async (assert) => {
|
||||
assert.expect(6);
|
||||
console.log("Start assert", serverData);
|
||||
console.log("Start makeView");
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "sale.order",
|
||||
|
@ -122,8 +120,6 @@ QUnit.module("web_widget_dropdown_dynamic", (hooks) => {
|
|||
"option[value='\"value b\"']",
|
||||
"got `value b` "
|
||||
);
|
||||
|
||||
console.log("Ending makeView", target);
|
||||
});
|
||||
|
||||
QUnit.test("values are fetched w/o context (integer)", async (assert) => {
|
||||
|
|
Loading…
Reference in New Issue