3
0
Fork 0

[MIG] web_widget_domain_editor_dialog: Migration to v13.0

14.0
Carlos Roca 2020-10-08 14:50:55 +02:00 committed by hkapatel
parent ce7ab5f9f0
commit 6d68bdad15
6 changed files with 48 additions and 67 deletions

View File

@ -14,13 +14,13 @@ Web Widget Domain Editor Dialog
: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/12.0/web_widget_domain_editor_dialog
:target: https://github.com/OCA/web/tree/13.0/web_widget_domain_editor_dialog
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_widget_domain_editor_dialog
:target: https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_widget_domain_editor_dialog
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/162/12.0
:target: https://runbot.odoo-community.org/runbot/162/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -57,7 +57,7 @@ with a user filter:
You can still edit the filter with Odoo's widget after that.
.. figure:: https://raw.githubusercontent.com/OCA/web/12.0/web_widget_domain_editor_dialog/static/src/img/behaviour.png
.. figure:: https://raw.githubusercontent.com/OCA/web/13.0/web_widget_domain_editor_dialog/static/src/img/behaviour.png
:align: center
:width: 600 px
@ -67,7 +67,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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_domain_editor_dialog%0Aversion:%2012.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_domain_editor_dialog%0Aversion:%2013.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.
@ -84,8 +84,9 @@ Contributors
* `Tecnativa <https://www.tecnativa.com>`_
* David Vidal <david.vidal@tecnativa.com>
* Jairo Llopis <jairo.llopis@tecnativa.com>
* David Vidal
* Jairo Llopis
* Carlos Roca
* Darshan Patel <darshan.barcelona@gmail.com>
@ -102,6 +103,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/12.0/web_widget_domain_editor_dialog>`_ project on GitHub.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/13.0/web_widget_domain_editor_dialog>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -3,7 +3,7 @@
{
"name": "Web Widget Domain Editor Dialog",
"summary": "Recovers the Domain Editor Dialog functionality",
"version": "12.0.1.0.0",
"version": "13.0.1.0.0",
"category": "Web",
"author": "Tecnativa," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",

View File

@ -1,6 +1,7 @@
* `Tecnativa <https://www.tecnativa.com>`_
* David Vidal <david.vidal@tecnativa.com>
* Jairo Llopis <jairo.llopis@tecnativa.com>
* David Vidal
* Jairo Llopis
* Carlos Roca
* Darshan Patel <darshan.barcelona@gmail.com>

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! 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/12.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" href="https://translation.odoo-community.org/projects/web-12-0/web-12-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" href="https://runbot.odoo-community.org/runbot/162/12.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/13.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" href="https://translation.odoo-community.org/projects/web-13-0/web-13-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" href="https://runbot.odoo-community.org/runbot/162/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Since v11 introduced the new domain editor widget its not possible to edit
the selected records from the current domain.</p>
<p>This module reintroduces that dialog to complement the current widget with the
@ -408,7 +408,7 @@ records and those unfolded groups will be set as filters to.</li>
</blockquote>
<p>You can still edit the filter with Odoos widget after that.</p>
<div class="figure align-center">
<img alt="https://raw.githubusercontent.com/OCA/web/12.0/web_widget_domain_editor_dialog/static/src/img/behaviour.png" src="https://raw.githubusercontent.com/OCA/web/12.0/web_widget_domain_editor_dialog/static/src/img/behaviour.png" style="width: 600px;" />
<img alt="https://raw.githubusercontent.com/OCA/web/13.0/web_widget_domain_editor_dialog/static/src/img/behaviour.png" src="https://raw.githubusercontent.com/OCA/web/13.0/web_widget_domain_editor_dialog/static/src/img/behaviour.png" style="width: 600px;" />
</div>
</div>
<div class="section" id="bug-tracker">
@ -416,7 +416,7 @@ records and those unfolded groups will be set as filters to.</li>
<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 smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_domain_editor_dialog%0Aversion:%2012.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_domain_editor_dialog%0Aversion:%2013.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">
@ -431,8 +431,9 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a><ul>
<li>David Vidal &lt;<a class="reference external" href="mailto:david.vidal&#64;tecnativa.com">david.vidal&#64;tecnativa.com</a>&gt;</li>
<li>Jairo Llopis &lt;<a class="reference external" href="mailto:jairo.llopis&#64;tecnativa.com">jairo.llopis&#64;tecnativa.com</a>&gt;</li>
<li>David Vidal</li>
<li>Jairo Llopis</li>
<li>Carlos Roca</li>
</ul>
</li>
<li>Darshan Patel &lt;<a class="reference external" href="mailto:darshan.barcelona&#64;gmail.com">darshan.barcelona&#64;gmail.com</a>&gt;</li>
@ -445,7 +446,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<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/12.0/web_widget_domain_editor_dialog">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/13.0/web_widget_domain_editor_dialog">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>

View File

@ -4,19 +4,19 @@
odoo.define("web_widget_domain_editor_dialog.basic_fields", function(require) {
"use strict";
var core = require("web.core");
var basic_fields = require("web.basic_fields");
var DomainEditorDialog = require("web_widget_domain_editor_dialog.DomainEditorDialog");
var _t = core._t;
const core = require("web.core");
const basic_fields = require("web.basic_fields");
const DomainEditorDialog = require("web_widget_domain_editor_dialog.DomainEditorDialog");
const _t = core._t;
basic_fields.FieldDomain.include({
_onShowSelectionButtonClick: function(event) {
event.preventDefault();
var _this = this;
const _this = this;
if (this.mode === "readonly") {
return this._super.apply(this, arguments);
}
var dialog = new DomainEditorDialog(this, {
const dialog = new DomainEditorDialog(this, {
title: _t("Select records..."),
res_model: this._domainModel,
default_domain: this.value,

View File

@ -4,65 +4,43 @@
odoo.define("web_widget_domain_editor_dialog.DomainEditorDialog", function(require) {
"use strict";
var core = require("web.core");
var view_dialogs = require("web.view_dialogs");
var SearchView = require("web.SearchView");
var _t = core._t;
const core = require("web.core");
const view_dialogs = require("web.view_dialogs");
const Domain = require("web.Domain");
const _t = core._t;
var DomainEditorDialog = view_dialogs.SelectCreateDialog.extend({
const DomainEditorDialog = view_dialogs.SelectCreateDialog.extend({
init: function() {
this._super.apply(this, arguments);
var _this = this;
const _this = this;
this.options = _.defaults(this.options, {
initial_facet: {
category: _t("Custom Filter"),
icon: "fa-circle",
field: {
get_context: function() {
return _this.options.context;
},
get_groupby: function() {
return [];
},
get_domain: function() {
return _this.options.default_domain;
},
dynamicFilters: [
{
description: _.str.sprintf(_t("Selected domain")),
domain: Domain.prototype.stringToArray(
_this.options.default_domain
),
},
values: [{label: _t("Selected domain"), value: null}],
},
],
});
},
start: function() {
var search_view = _.find(this.getChildren(), function(x) {
return x instanceof SearchView;
});
if (this.options.initial_facet && search_view) {
search_view.query.reset([this.options.initial_facet], {
preventSearch: true,
});
search_view.do_search();
}
this._super.apply(this, arguments);
},
get_domain: function(selected_ids) {
var group_domain = [];
var search_data = this.list_controller.renderer.state;
var domain = search_data.domain;
let group_domain = [];
const search_data = this.viewController.renderer.state;
let domain = search_data.domain;
if (this.$(".o_list_record_selector input").prop("checked")) {
if (search_data.groupedBy.length) {
group_domain = _.filter(search_data.data, function(x) {
group_domain = _.filter(search_data.data, x => {
return x.res_ids.length;
}).map(function(x) {
}).map(x => {
return x.domain;
});
group_domain = _.flatten(group_domain, true);
// Compute domain difference
_.each(domain, function(d) {
_.each(domain, d => {
group_domain = _.without(
group_domain,
_.filter(group_domain, function(x) {
_.filter(group_domain, x => {
return _.isEqual(x, d);
})[0]
);
@ -76,7 +54,7 @@ odoo.define("web_widget_domain_editor_dialog.DomainEditorDialog", function(requi
).concat(group_domain);
}
} else {
var ids = selected_ids.map(function(x) {
const ids = selected_ids.map(x => {
return x.id;
});
domain = domain.concat([["id", "in", ids]]);
@ -84,7 +62,7 @@ odoo.define("web_widget_domain_editor_dialog.DomainEditorDialog", function(requi
return domain.concat(group_domain);
},
on_view_list_loaded: function() {
on_view_list_loaded: () => {
this.$(".o_list_record_selector input").prop("checked", true);
this.$footer
.find(".o_selectcreatepopup_search_select")