Christophe Matthieu (OpenERP) has proposed merging 
lp:~openerp-dev/openerp-web/trunk-many2many-email-chm into lp:openerp-web.

Requested reviews:
  OpenERP R&D Web Team (openerp-dev-web)

For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-many2many-email-chm/+merge/132313
-- 
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-many2many-email-chm/+merge/132313
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openerp-web/trunk-many2many-email-chm.
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js	2012-10-31 10:32:33 +0000
+++ addons/web/static/src/js/view_form.js	2012-10-31 12:35:31 +0000
@@ -3955,6 +3955,40 @@
     },
 });
 
+
+/**
+ * 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("Complete partner's informations"),
+                        }
+                    );
+                    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.
@@ -5141,6 +5175,7 @@
     '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',

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to