From baae1df60369d26995c5c37aaf14e44a9dadd7b6 Mon Sep 17 00:00:00 2001 From: Jamin Shah Date: Sat, 20 Feb 2016 12:37:36 +0530 Subject: [PATCH] [MIG]Migrated web widget many2many_tags multi selection in v9 --- .../README.rst | 1 + .../__openerp__.py | 4 +- .../static/src/js/view_form.js | 55 ++++++++++--------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/web_widget_many2many_tags_multi_selection/README.rst b/web_widget_many2many_tags_multi_selection/README.rst index c165633c..5133aa04 100644 --- a/web_widget_many2many_tags_multi_selection/README.rst +++ b/web_widget_many2many_tags_multi_selection/README.rst @@ -29,6 +29,7 @@ Contributors ------------ * Sylvain Calador +* Jamin Shah Maintainer ---------- diff --git a/web_widget_many2many_tags_multi_selection/__openerp__.py b/web_widget_many2many_tags_multi_selection/__openerp__.py index 667764c4..00a8d2bc 100644 --- a/web_widget_many2many_tags_multi_selection/__openerp__.py +++ b/web_widget_many2many_tags_multi_selection/__openerp__.py @@ -21,8 +21,8 @@ { 'name': 'Tags multiple selection', - 'version': '8.0.0.1.0', - 'author': 'Akretion, Odoo Community Association (OCA)', + 'version': '9.0.1.1.0', + 'author': 'Akretion, Odoo Community Association (OCA), Jamin Shah', 'depends': [ 'web', ], diff --git a/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js b/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js index 1d073fe6..c432ef96 100644 --- a/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js +++ b/web_widget_many2many_tags_multi_selection/static/src/js/view_form.js @@ -1,38 +1,39 @@ -openerp.web_widget_many2many_tags_multi_selection = function(instance, local) { +odoo.define('web_widget_many2many_tags_multi_selection.multiple_tags', function (require) { + "use strict"; - var _t = instance.web._t; + var FormCommon = require('web.form_common'); + var core = require('web.core'); + var data = require('web.data'); + var _t = core._t; - instance.web.form.CompletionFieldMixin._search_create_popup = function(view, ids, context) { + FormCommon.CompletionFieldMixin._search_create_popup = function(view, ids, context) { var self = this; - var pop = new instance.web.form.SelectCreatePopup(this); + new FormCommon.SelectCreateDialog(this, { + res_model: self.field.relation, + domain: self.build_domain(), + context: new data.CompoundContext(self.build_context(), context || {}), + title: (view === 'search' ? _t("Search: ") : _t("Create: ")) + this.string, + initial_ids: ids ? _.map(ids, function(x) {return x[0];}) : undefined, + initial_view: view, + disable_multiple_selection: this.field.type != 'many2many', + on_selected: function(element_ids) { + for(var i=0, len=element_ids.length; i 0) { - domain = new instance.web.CompoundDomain(domain, ["!", ["id", "in", selected_ids]]); + domain = new data.CompoundDomain(domain, ["!", ["id", "in", selected_ids]]); } } - pop.select_element( - self.field.relation, - { - title: (view === 'search' ? _t("Search: ") : _t("Create: ")) + this.string, - initial_ids: ids ? _.map(ids, function(x) {return x[0];}) : undefined, - initial_view: view, - disable_multiple_selection: this.field.type != 'many2many', - }, - domain, - new instance.web.CompoundContext(self.build_context(), context || {}) - ); - pop.on("elements_selected", self, function(element_ids) { - for(var i=0, len=element_ids.length; i