Skip to content

Commit bf8d581

Browse files
committed
[MIG] web_widget_domain_editor_dialog: Migration to 16.0
1 parent 9faa5e9 commit bf8d581

File tree

7 files changed

+134
-156
lines changed

7 files changed

+134
-156
lines changed

web_widget_domain_editor_dialog/README.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Web Widget Domain Editor Dialog
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:d65154dd6473cf94aca066e7ee90fd83de2f10290940733267e9bc0e44177281
10+
!! source digest: sha256:556e58fec03e10a766775e9fcf51a71af99cd84efaa2ee47cd937bee7ef9312f
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,13 @@ Web Widget Domain Editor Dialog
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
20-
:target: https://github.com/OCA/web/tree/15.0/web_widget_domain_editor_dialog
20+
:target: https://github.com/OCA/web/tree/16.0/web_widget_domain_editor_dialog
2121
:alt: OCA/web
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_widget_domain_editor_dialog
23+
:target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_widget_domain_editor_dialog
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=15.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -60,7 +60,7 @@ with a user filter:
6060

6161
You can still edit the filter with Odoo's widget after that.
6262

63-
.. figure:: https://raw.githubusercontent.com/OCA/web/15.0/web_widget_domain_editor_dialog/static/src/img/behaviour.gif
63+
.. figure:: https://raw.githubusercontent.com/OCA/web/16.0/web_widget_domain_editor_dialog/static/src/img/behaviour.gif
6464
:align: center
6565
:width: 600 px
6666

@@ -70,7 +70,7 @@ Bug Tracker
7070
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
7171
In case of trouble, please check there if your issue has already been reported.
7272
If you spotted it first, help us to smash it by providing a detailed and welcomed
73-
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_domain_editor_dialog%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
73+
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_domain_editor_dialog%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
7474

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

@@ -108,6 +108,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
108108
mission is to support the collaborative development of Odoo features and
109109
promote its widespread use.
110110

111-
This module is part of the `OCA/web <https://github.com/OCA/web/tree/15.0/web_widget_domain_editor_dialog>`_ project on GitHub.
111+
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_widget_domain_editor_dialog>`_ project on GitHub.
112112

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

web_widget_domain_editor_dialog/__manifest__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
{
44
"name": "Web Widget Domain Editor Dialog",
55
"summary": "Recovers the Domain Editor Dialog functionality",
6-
"version": "15.0.1.0.1",
6+
"version": "16.0.1.0.0",
77
"category": "Web",
88
"author": "Tecnativa," "Odoo Community Association (OCA)",
99
"website": "https://github.com/OCA/web",
1010
"license": "AGPL-3",
1111
"depends": ["web"],
1212
"assets": {
1313
"web.assets_backend": [
14-
"/web_widget_domain_editor_dialog/static/src/js/*.js",
14+
"/web_widget_domain_editor_dialog/static/src/js/*.esm.js",
1515
],
1616
},
1717
"installable": True,

web_widget_domain_editor_dialog/static/description/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ <h1 class="title">Web Widget Domain Editor Dialog</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:d65154dd6473cf94aca066e7ee90fd83de2f10290940733267e9bc0e44177281
370+
!! source digest: sha256:556e58fec03e10a766775e9fcf51a71af99cd84efaa2ee47cd937bee7ef9312f
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<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/15.0/web_widget_domain_editor_dialog"><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-15-0/web-15-0-web_widget_domain_editor_dialog"><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&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<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/16.0/web_widget_domain_editor_dialog"><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-16-0/web-16-0-web_widget_domain_editor_dialog"><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&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>Since v11 introduced the new domain editor widget it’s not possible to edit
374374
the selected records from the current domain.</p>
375375
<p>This module reintroduces that dialog to complement the current widget with the
@@ -410,15 +410,15 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
410410
</blockquote>
411411
<p>You can still edit the filter with Odoo’s widget after that.</p>
412412
<div class="figure align-center">
413-
<img alt="https://raw.githubusercontent.com/OCA/web/15.0/web_widget_domain_editor_dialog/static/src/img/behaviour.gif" src="https://raw.githubusercontent.com/OCA/web/15.0/web_widget_domain_editor_dialog/static/src/img/behaviour.gif" style="width: 600px;" />
413+
<img alt="https://raw.githubusercontent.com/OCA/web/16.0/web_widget_domain_editor_dialog/static/src/img/behaviour.gif" src="https://raw.githubusercontent.com/OCA/web/16.0/web_widget_domain_editor_dialog/static/src/img/behaviour.gif" style="width: 600px;" />
414414
</div>
415415
</div>
416416
<div class="section" id="bug-tracker">
417417
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
418418
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
419419
In case of trouble, please check there if your issue has already been reported.
420420
If you spotted it first, help us to smash it by providing a detailed and welcomed
421-
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_domain_editor_dialog%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
421+
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_domain_editor_dialog%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
422422
<p>Do not contact contributors directly about support or help with technical issues.</p>
423423
</div>
424424
<div class="section" id="credits">
@@ -450,7 +450,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
450450
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
451451
mission is to support the collaborative development of Odoo features and
452452
promote its widespread use.</p>
453-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_widget_domain_editor_dialog">OCA/web</a> project on GitHub.</p>
453+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_widget_domain_editor_dialog">OCA/web</a> project on GitHub.</p>
454454
<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>
455455
</div>
456456
</div>

web_widget_domain_editor_dialog/static/src/js/basic_fields.js

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/** @odoo-module **/
2+
/* Copyright 2019 Tecnativa - David Vidal
3+
* Copyright 2024 Tecnativa - Carlos Roca
4+
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
5+
import {DomainField} from "@web/views/fields/domain/domain_field";
6+
import {DomainEditorDialog} from "./widget_domain_editor_dialog.esm";
7+
import {patch} from "@web/core/utils/patch";
8+
9+
patch(DomainField.prototype, "web_widget_domain_editor_dialog.DomainField", {
10+
onButtonClick(ev) {
11+
ev.preventDefault();
12+
const self = this;
13+
if (this.props.readonly) {
14+
return this._super.apply(this, arguments);
15+
}
16+
if (!this.props.value) {
17+
this.props.value = "[]";
18+
}
19+
this.addDialog(DomainEditorDialog, {
20+
title: this.env._t("Select records..."),
21+
noCreate: true,
22+
multiSelect: true,
23+
resModel: this.getResModel(this.props),
24+
dynamicFilters: [
25+
{
26+
description: this.env._t("Selected domain"),
27+
domain:
28+
this.getDomain(this.props.value).toList(
29+
this.getContext(this.props)
30+
) || [],
31+
},
32+
],
33+
context: this.getContext(this.props) || {},
34+
onSelected: function (resIds) {
35+
self.update(this.get_domain(resIds));
36+
},
37+
});
38+
},
39+
});
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/** @odoo-module **/
2+
/* Copyright 2019 Tecnativa - David Vidal
3+
* Copyright 2024 Tecnativa - Carlos Roca
4+
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
5+
import {SelectCreateDialog} from "@web/views/view_dialogs/select_create_dialog";
6+
import {Domain} from "@web/core/domain";
7+
8+
export function findChildren(comp, predicate = (e) => e) {
9+
const queue = [];
10+
[].unshift.apply(queue, Object.values(comp.__owl__.children));
11+
12+
while (queue.length > 0) {
13+
const curNode = queue.pop();
14+
if (predicate(curNode)) {
15+
return curNode;
16+
}
17+
[].unshift.apply(queue, Object.values(curNode.component.__owl__.children));
18+
}
19+
}
20+
21+
export class DomainEditorDialog extends SelectCreateDialog {
22+
/**
23+
* Bind this to allow call get_domain from onSelected function definition.
24+
*
25+
* @override
26+
*/
27+
async select(resIds) {
28+
if (this.props.onSelected) {
29+
const onselected = this.props.onSelected.bind(this);
30+
await onselected(resIds);
31+
this.props.close();
32+
}
33+
}
34+
35+
_getDomainOfGroups(groups, domain) {
36+
const groups_unfolded = _.filter(groups, (g) => !g.isFolded);
37+
var groups_domain = [];
38+
for (var group of groups_unfolded) {
39+
var group_list = group.list;
40+
if (group_list.groupBy.length) {
41+
groups_domain.push(this._getDomainOfGroups(group_list.groups, domain));
42+
} else {
43+
var group_domain = group_list.domain;
44+
_.each(domain, (d) => {
45+
group_domain = _.without(
46+
group_domain,
47+
_.filter(group_domain, (x) => {
48+
return _.isEqual(x, d);
49+
})[0]
50+
);
51+
});
52+
group_domain = _.without(group_domain, "&");
53+
groups_domain.push(group_domain);
54+
}
55+
}
56+
return Domain.or(groups_domain).toList();
57+
}
58+
59+
get_domain(resIds) {
60+
const dynamicList = findChildren(
61+
this,
62+
(node) =>
63+
node.component &&
64+
node.component.model &&
65+
node.component.model.root &&
66+
["DynamicGroupList", "DynamicRecordList"].includes(
67+
node.component.model.root.constructor.name
68+
)
69+
).component.model.root;
70+
let domain = dynamicList.domain;
71+
let group_domain = [];
72+
if ($(".o_list_record_selector input").prop("checked")) {
73+
if (dynamicList.groupBy.length) {
74+
group_domain = this._getDomainOfGroups(dynamicList.groups, domain);
75+
}
76+
} else {
77+
domain = domain.concat([["id", "in", resIds]]);
78+
}
79+
return JSON.stringify(domain.concat(group_domain));
80+
}
81+
}

web_widget_domain_editor_dialog/static/src/js/widget_domain_editor_dialog.js

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)