Merge lp:~openerp-dev/openobject-addons/7.0-fix-mail-checkbox-chm into lp:openobject-addons/7.0

Proposed by Christophe Matthieu (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-fix-mail-checkbox-chm
Merge into: lp:openobject-addons/7.0
Diff against target: 74 lines (+24/-13)
1 file modified
mail/static/src/js/mail.js (+24/-13)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-fix-mail-checkbox-chm
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+165085@code.launchpad.net
To post a comment you must log in.
9148. By Christophe Matthieu (OpenERP)

[FIX] mail: now user can change email inside the create partner popup

Unmerged revisions

9148. By Christophe Matthieu (OpenERP)

[FIX] mail: now user can change email inside the create partner popup

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mail/static/src/js/mail.js'
2--- mail/static/src/js/mail.js 2013-05-08 11:39:52 +0000
3+++ mail/static/src/js/mail.js 2013-05-22 15:28:45 +0000
4@@ -614,8 +614,6 @@
5 var names_to_find = _.pluck(recipients_to_find, 'full_name');
6 var recipients_to_check = _.filter(recipients, function (recipient) { return (recipient.partner_id && ! recipient.email_address) });
7 var recipient_ids = _.pluck(_.filter(recipients, function (recipient) { return recipient.partner_id && recipient.email_address }), 'partner_id');
8- var names_to_remove = [];
9- var recipient_ids_to_remove = [];
10
11 // have unknown names -> call message_get_partner_info_from_emails to try to find partner_id
12 var find_done = $.Deferred();
13@@ -632,7 +630,11 @@
14 // for unknown names + incomplete partners -> open popup - cancel = remove from recipients
15 $.when(find_done).pipe(function (result) {
16 var emails_deferred = [];
17- var recipient_popups = result.concat(recipients_to_check);
18+ var recipient_popups = recipients_to_check.slice();
19+ _.each(result, function (recipient) {
20+ recipient.find = true;
21+ recipient_popups.push(recipient);
22+ });
23
24 _.each(recipient_popups, function (partner_info) {
25 var deferred = $.Deferred()
26@@ -654,19 +656,29 @@
27 title: _t("Please complete partner's informations"),
28 }
29 );
30- pop.on('closed', self, function () {
31+ pop.on('closed', pop, function () {
32+ if (parsed_email[1] != this.view_form.datarecord.email) {
33+ partner_info.full_name = this.view_form.datarecord.email;
34+ }
35+ if (!partner_id) {
36+ partner_info.partner_id = this.dataset.ids[0];
37+ }
38 deferred.resolve();
39 });
40- pop.view_form.on('on_button_cancel', self, function () {
41- names_to_remove.push(partner_name);
42- if (partner_id) {
43- recipient_ids_to_remove.push(partner_id);
44- }
45+ pop.view_form.on('on_button_cancel', pop, function () {
46+ partner_info.remove = true;
47 });
48 });
49
50 $.when.apply($, emails_deferred).then(function () {
51- var new_names_to_find = _.difference(names_to_find, names_to_remove);
52+ var new_names_to_find = [];
53+ _.each(recipient_popups, function (recipient) {
54+ if (recipient.find && !recipient.remove) {
55+ new_names_to_find.push(recipient.full_name)
56+ }
57+ });
58+ recipient_popups = _.filter(recipient_popups, function (recipient) { return !recipient.find;});
59+
60 find_done = $.Deferred();
61 if (new_names_to_find.length > 0) {
62 var values = {
63@@ -679,9 +691,8 @@
64 find_done.resolve([]);
65 }
66 $.when(find_done).pipe(function (result) {
67- var recipient_popups = result.concat(recipients_to_check);
68- _.each(recipient_popups, function (partner_info) {
69- if (partner_info.partner_id && _.indexOf(partner_info.partner_id, recipient_ids_to_remove) == -1) {
70+ _.each(result.concat(recipient_popups), function (partner_info) {
71+ if (partner_info.partner_id && !partner_info.remove) {
72 recipient_ids.push(partner_info.partner_id);
73 }
74 });