From ed66b02fe67e714bf0a90e46cdafc742047cb3bc Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 31 Oct 2012 11:19:59 +0100 Subject: [PATCH 1/6] [IMP] view form: add many2many_tag_email widget bzr revid: chm@openerp.com-20121031101959-t4o6qusszamx5qgu --- addons/web/static/src/js/view_form.js | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 5ecad26e5df..a6fcd2c46cb 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3955,6 +3955,41 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in }, }); + +/** + * Extend of FieldMany2ManyTags widget method. + * When the user add a partner and the partner don't have an email, open a popup to purpose to add an email. + * The user can choose to add an email or cancel and close the popup. + */ +instance.web.form.FieldMany2ManyTagsEmail = instance.web.form.FieldMany2ManyTags.extend({ + add_id: function(id) { + this._super.apply(this, arguments); + + var self = this; + new instance.web.Model('res.partner').call("read", [id, ["email"]], {context: this.build_context()}).pipe(function (dict) { + if (!dict.email) { + if (! confirm(_t("This partner don't have email.\nDo you want to complete the partner's informations?"))) { return false; } + self.on_complete_informations(dict); + } + }); + }, + + on_complete_informations: function (dict) { + var self = this; + + var pop = new instance.web.form.FormOpenPopup(self); + pop.show_element( + 'res.partner', + dict.id, + self.build_context(), + { + title: _t("Complete partner's informations"), + } + ); + }, + +}); + /** widget options: - reload_on_button: Reload the whole form view if click on a button in a list view. @@ -5141,6 +5176,7 @@ instance.web.form.widgets = new instance.web.Registry({ 'many2one' : 'instance.web.form.FieldMany2One', 'many2many' : 'instance.web.form.FieldMany2Many', 'many2many_tags' : 'instance.web.form.FieldMany2ManyTags', + 'many2many_tags_email' : 'instance.web.form.FieldMany2ManyTagsEmail', 'many2many_kanban' : 'instance.web.form.FieldMany2ManyKanban', 'one2many' : 'instance.web.form.FieldOne2Many', 'one2many_list' : 'instance.web.form.FieldOne2Many', From 8526bf26b30be8063c1a072e8b34c46c2a3420fe Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 31 Oct 2012 11:56:04 +0100 Subject: [PATCH 2/6] [IMP] view form: no question to complete informations in many2many_tag_email widget bzr revid: chm@openerp.com-20121031105604-952pxf2rhlvupsx1 --- addons/web/static/src/js/view_form.js | 45 +++++++++++++-------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index a6fcd2c46cb..575e22751af 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3963,31 +3963,30 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in */ instance.web.form.FieldMany2ManyTagsEmail = instance.web.form.FieldMany2ManyTags.extend({ add_id: function(id) { - this._super.apply(this, arguments); - var self = this; - new instance.web.Model('res.partner').call("read", [id, ["email"]], {context: this.build_context()}).pipe(function (dict) { - if (!dict.email) { - if (! confirm(_t("This partner don't have email.\nDo you want to complete the partner's informations?"))) { return false; } - self.on_complete_informations(dict); - } - }); + new instance.web.Model('res.partner').call("read", [id, ["email", "notification_email_send"]], {context: this.build_context()}) + .pipe(function (dict) { + if (!dict.email && (dict.notification_email_send == 'all' || dict.notification_email_send == 'comment')) { + var pop = new instance.web.form.FormOpenPopup(self); + pop.show_element( + 'res.partner', + dict.id, + self.build_context(), + { + title: _t("Complete partner's informations"), + } + ); + pop.on('write_completed', self, function () { + self._add_id(dict.id) + }); + } else { + self._add_id(dict.id); + } + }); }, - - on_complete_informations: function (dict) { - var self = this; - - var pop = new instance.web.form.FormOpenPopup(self); - pop.show_element( - 'res.partner', - dict.id, - self.build_context(), - { - title: _t("Complete partner's informations"), - } - ); - }, - + _add_id: function (id) { + this.set({'value': _.uniq(this.get('value').concat([id]))}); + } }); /** From 9ee814ca950564e6163ed2865f2e24a07ae26fc9 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 31 Oct 2012 17:44:05 +0100 Subject: [PATCH 3/6] [IMP] view form: many2many tag email : message please complete bzr revid: chm@openerp.com-20121031164405-sym3w0cnzszr7i0d --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 575e22751af..e8d05296625 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3973,7 +3973,7 @@ instance.web.form.FieldMany2ManyTagsEmail = instance.web.form.FieldMany2ManyTags dict.id, self.build_context(), { - title: _t("Complete partner's informations"), + title: _t("Please complete partner's informations and Email"), } ); pop.on('write_completed', self, function () { From d3e5d953b1384e92e61fa51ad7b7a75d9c76c913 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 6 Nov 2012 10:57:00 +0100 Subject: [PATCH 4/6] [IMP] web: field many2many_tags_email moved to mail addon bzr revid: chm@openerp.com-20121106095700-q5gtxandi7o0jn6o --- addons/web/static/src/js/view_form.js | 35 --------------------------- 1 file changed, 35 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index e8d05296625..5ecad26e5df 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3955,40 +3955,6 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in }, }); - -/** - * Extend of FieldMany2ManyTags widget method. - * When the user add a partner and the partner don't have an email, open a popup to purpose to add an email. - * The user can choose to add an email or cancel and close the popup. - */ -instance.web.form.FieldMany2ManyTagsEmail = instance.web.form.FieldMany2ManyTags.extend({ - add_id: function(id) { - var self = this; - new instance.web.Model('res.partner').call("read", [id, ["email", "notification_email_send"]], {context: this.build_context()}) - .pipe(function (dict) { - if (!dict.email && (dict.notification_email_send == 'all' || dict.notification_email_send == 'comment')) { - var pop = new instance.web.form.FormOpenPopup(self); - pop.show_element( - 'res.partner', - dict.id, - self.build_context(), - { - title: _t("Please complete partner's informations and Email"), - } - ); - pop.on('write_completed', self, function () { - self._add_id(dict.id) - }); - } else { - self._add_id(dict.id); - } - }); - }, - _add_id: function (id) { - this.set({'value': _.uniq(this.get('value').concat([id]))}); - } -}); - /** widget options: - reload_on_button: Reload the whole form view if click on a button in a list view. @@ -5175,7 +5141,6 @@ instance.web.form.widgets = new instance.web.Registry({ 'many2one' : 'instance.web.form.FieldMany2One', 'many2many' : 'instance.web.form.FieldMany2Many', 'many2many_tags' : 'instance.web.form.FieldMany2ManyTags', - 'many2many_tags_email' : 'instance.web.form.FieldMany2ManyTagsEmail', 'many2many_kanban' : 'instance.web.form.FieldMany2ManyKanban', 'one2many' : 'instance.web.form.FieldOne2Many', 'one2many_list' : 'instance.web.form.FieldOne2Many', From af2c38f4c9a7da9ae0de7652ca098910cbaee09e Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 6 Nov 2012 13:52:06 +0100 Subject: [PATCH 5/6] [IMP] web: trigger closing for popup bzr revid: chm@openerp.com-20121106125206-icm2s8fvb13m40w9 --- addons/web/static/src/js/view_form.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 5ecad26e5df..435384bfe60 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4427,6 +4427,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ this.destroy(); }, destroy: function () { + this.trigger('closing'); this.$el.dialog('close'); this._super(); }, From a006b078ed4fa9fa668ee3a4b25b926e56e1b09a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 6 Nov 2012 15:59:40 +0100 Subject: [PATCH 6/6] [REVIEW] trigger closing -> trigger closed, to match the code guidelines. bzr revid: tde@openerp.com-20121106145940-cji6varovqtgneiz --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 6447c2241cf..6a853c4bef9 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4420,7 +4420,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ this.destroy(); }, destroy: function () { - this.trigger('closing'); + this.trigger('closed'); this.$el.dialog('close'); this._super(); },