From b5b480a7a74c44cf037bc4a9818ee029dc00562d Mon Sep 17 00:00:00 2001 From: "Amit (OpenERP)" Date: Thu, 31 May 2012 13:34:06 +0530 Subject: [PATCH 01/29] [FIX] osv_execption raised from report service gives a error lp bug: https://launchpad.net/bugs/941124 fixed bzr revid: amp@tinyerp.com-20120531080406-k0ue29zympib1qu9 --- addons/web/common/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/common/http.py b/addons/web/common/http.py index 9294808fda4..0af64a18e5a 100644 --- a/addons/web/common/http.py +++ b/addons/web/common/http.py @@ -593,7 +593,7 @@ class LocalConnector(openerplib.Connector): except Exception,e: # TODO change the except to raise LibException instead of their emulated xmlrpc fault if isinstance(e, openerp.osv.osv.except_osv): - fault = xmlrpclib.Fault('warning -- ' + e.name + '\n\n' + e.value, '') + fault = xmlrpclib.Fault('warning -- ' + e.name + '\n\n' + str(e.value), '') elif isinstance(e, openerp.exceptions.Warning): fault = xmlrpclib.Fault('warning -- Warning\n\n' + str(e), '') elif isinstance(e, openerp.exceptions.AccessError): From 53597dc1922184adc950b92796562f22baad35f6 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 31 May 2012 11:41:00 +0200 Subject: [PATCH 02/29] Small inconsistency in m2mtags bzr revid: nicolas.vanhoren@openerp.com-20120531094100-ynh1zz5koclrkxbd --- 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 ca1d576a8e5..7d52ccf2599 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3168,7 +3168,7 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(_. }); self.tags = self.$text.textext()[0].tags(); $("textarea", this.$element).focusout(function() { - $("textarea", this.$element).val(""); + self.$text.trigger("setInputData", ""); }).keydown(function(e) { if (event.keyCode === 9 && self._drop_shown) { self.$text.textext()[0].autocomplete().selectFromDropdown(); From d5daf869daf13a900a85499e3577703b9eaac811 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 31 May 2012 11:46:47 +0200 Subject: [PATCH 03/29] Changed buttons in quick create bzr revid: nicolas.vanhoren@openerp.com-20120531094647-by15fj5di9a2m9kv --- addons/web_kanban/static/src/css/kanban.css | 3 --- addons/web_kanban/static/src/xml/web_kanban.xml | 6 ++++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/web_kanban/static/src/css/kanban.css b/addons/web_kanban/static/src/css/kanban.css index dd376ef44e5..aba80c203bc 100644 --- a/addons/web_kanban/static/src/css/kanban.css +++ b/addons/web_kanban/static/src/css/kanban.css @@ -107,9 +107,6 @@ box-sizing: border-box; width: 100%; } -.openerp .oe_kanban_view .oe_kanban_quick_create button { - float: right; -} .openerp .oe_kanban_view .oe_kanban_vignette { padding: 8px; min-height: 100px; diff --git a/addons/web_kanban/static/src/xml/web_kanban.xml b/addons/web_kanban/static/src/xml/web_kanban.xml index cabe9cb52fb..736c64f90b8 100644 --- a/addons/web_kanban/static/src/xml/web_kanban.xml +++ b/addons/web_kanban/static/src/xml/web_kanban.xml @@ -66,8 +66,10 @@
- - +
+ + or Cancel +
From c257e6f1bf45d750fce9c25700f4673bb8d75090 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 31 May 2012 12:01:09 +0200 Subject: [PATCH 04/29] Corrected bug with quick create in group mode bzr revid: nicolas.vanhoren@openerp.com-20120531100109-qekw54w6s7xoebzn --- addons/web_kanban/static/src/css/kanban.css | 3 +++ addons/web_kanban/static/src/js/kanban.js | 6 +++--- addons/web_kanban/static/src/xml/web_kanban.xml | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/web_kanban/static/src/css/kanban.css b/addons/web_kanban/static/src/css/kanban.css index aba80c203bc..c341475c169 100644 --- a/addons/web_kanban/static/src/css/kanban.css +++ b/addons/web_kanban/static/src/css/kanban.css @@ -107,6 +107,9 @@ box-sizing: border-box; width: 100%; } +.openerp .oe_kanban_view .oe_kanban_quick_create .oe_kanban_quick_create_buttons { + margin-bottom: 10px; +} .openerp .oe_kanban_view .oe_kanban_vignette { padding: 8px; min-height: 100px; diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 4a4e385cd1b..9a8e23bc515 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -417,7 +417,7 @@ instance.web_kanban.KanbanGroup = instance.web.OldWidget.extend({ this.quick.destroy(); delete this.quick; }); - self.quick.appendTo(self.$element.find('.oe_kanban_header')); + self.quick.appendTo($(".oe_kanban_group_list_header", self.$records)); self.quick.focus(); }); this.$records.find('.oe_kanban_show_more').click(this.do_show_more); @@ -466,7 +466,7 @@ instance.web_kanban.KanbanGroup = instance.web.OldWidget.extend({ rec.insertBefore(self.$records.find('.oe_kanban_show_more')); self.records.push(rec); } else { - rec.prependTo(self.$records); + rec.insertAfter($(".oe_kanban_group_list_header", self.$records)); self.records.unshift(rec); } }); @@ -502,7 +502,7 @@ instance.web_kanban.KanbanGroup = instance.web.OldWidget.extend({ this.dataset.read_ids([id], this.view.fields_keys) .then(function (records) { self.view.dataset.ids.push(id); - self.do_add_records(records, 'prepend'); + self.do_add_records(records, true); }); } }); diff --git a/addons/web_kanban/static/src/xml/web_kanban.xml b/addons/web_kanban/static/src/xml/web_kanban.xml index 736c64f90b8..18922fefa71 100644 --- a/addons/web_kanban/static/src/xml/web_kanban.xml +++ b/addons/web_kanban/static/src/xml/web_kanban.xml @@ -48,6 +48,7 @@ +
@@ -66,7 +67,7 @@
-
+
or Cancel
From 8afd115acab38f2c7698eef1e498ae6fa30d6886 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 31 May 2012 12:02:17 +0200 Subject: [PATCH 05/29] Changed text bzr revid: nicolas.vanhoren@openerp.com-20120531100217-87yxss40g0ebcsr0 --- addons/web_kanban/static/src/xml/web_kanban.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web_kanban/static/src/xml/web_kanban.xml b/addons/web_kanban/static/src/xml/web_kanban.xml index 18922fefa71..b50c2910e3c 100644 --- a/addons/web_kanban/static/src/xml/web_kanban.xml +++ b/addons/web_kanban/static/src/xml/web_kanban.xml @@ -65,7 +65,7 @@
- +
From 3eafe0a6be1ab577e149a6c02d9151947e13a32e Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 31 May 2012 12:05:03 +0200 Subject: [PATCH 06/29] Added esc button handling bzr revid: nicolas.vanhoren@openerp.com-20120531100503-bvn4jz3ztoscww55 --- addons/web_kanban/static/src/js/kanban.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 9a8e23bc515..360a9dd169a 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -774,6 +774,11 @@ instance.web_kanban.QuickCreate = instance.web.Widget.extend({ $(".oe-kanban-quick_create_close", this.$element).click(function () { self.trigger('close'); }); + self.$input.keyup(function(e) { + if (e.keyCode == 27 && self._buttons) { + self.trigger('close'); + } + }); }, focus: function() { this.$element.find('input').focus(); From 587f3ff41da36c332e94c2552e61470e4199d717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Jun 2012 10:10:16 +0200 Subject: [PATCH 07/29] [ADD] mail.thread: added boolean field for read/unread. bzr revid: tde@openerp.com-20120604081016-3x21acf0zccgeyhv --- addons/mail/mail_thread.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index b1b6c68e4cc..b821edb5165 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -72,6 +72,8 @@ class mail_thread(osv.osv): _columns = { 'message_ids': fields.function(_get_message_ids, method=True, type='one2many', obj='mail.message', string='Temp messages', _fields_id = 'res_id'), + 'thread_read': fields.boolean('Read', + help="When checked, new messages require your attention."), } #------------------------------------------------------ From 72e17e620e0eeecf89a9da7c2c05c2c75292f3f6 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 4 Jun 2012 11:31:03 +0200 Subject: [PATCH 08/29] Added customization in kanban view to better fit o2m bzr revid: nicolas.vanhoren@openerp.com-20120604093103-lydwjek920m3zxoe --- addons/web/static/src/js/view_form.js | 3 +++ addons/web_kanban/static/src/js/kanban.js | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 809c707feb0..0889f7d8dee 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2744,9 +2744,12 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ } view.options.not_interactible_on_create = true; } else if (view.view_type === "kanban") { + view.options.confirm_on_delete = false; if (self.get("effective_readonly")) { view.options.action_buttons = false; view.options.quick_creatable = false; + view.options.creatable = false; + view.options.read_only_mode = true; } } views.push(view); diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 13fd9547376..96487fa8b7e 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -14,7 +14,13 @@ instance.web_kanban.KanbanView = instance.web.View.extend({ number_of_color_schemes: 10, init: function (parent, dataset, view_id, options) { this._super(parent, dataset, view_id, options); - _.defaults(this.options, {"quick_creatable": true, "creatable": true, "create_text": undefined}); + _.defaults(this.options, { + "quick_creatable": true, + "creatable": true, + "create_text": undefined, + "read_only_mode": false, + "confirm_on_delete": true, + }); this.fields_view = {}; this.fields_keys = []; this.group_by = null; @@ -550,7 +556,8 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({ render: function() { this.qweb_context = { record: this.record, - widget: this + widget: this, + read_only_mode: this.view.options.read_only_mode, }; for (var p in this) { if (_.str.startsWith(p, 'kanban_')) { @@ -653,12 +660,18 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({ }, do_action_delete: function($action) { var self = this; - if (confirm(_t("Are you sure you want to delete this record ?"))) { - return $.when(this.view.dataset.unlink([this.id])).then(function() { + function do_it() { + return $.when(self.view.dataset.unlink([self.id])).then(function() { self.group.remove_record(self.id); self.destroy(); }); - } + }; + if (this.view.options.confirm_on_delete) { + if (confirm(_t("Are you sure you want to delete this record ?"))) { + return do_it(); + } + } else + return do_it(); }, do_action_edit: function($action) { var self = this; From fcf07cc65f9dfe618c38ccf9e107c2ab85d539a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Jun 2012 11:33:24 +0200 Subject: [PATCH 09/29] [IMP] mail_thread: thread_read -> thread_is_read; added API methods to mark read/unread; small code cleaning. bzr revid: tde@openerp.com-20120604093324-x3mtl4lu4883lqz0 --- addons/mail/mail_thread.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index b821edb5165..3deb7f25769 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -71,8 +71,9 @@ class mail_thread(osv.osv): # OpenChatter: message_ids is a dummy field that should not be used _columns = { 'message_ids': fields.function(_get_message_ids, method=True, - type='one2many', obj='mail.message', string='Temp messages', _fields_id = 'res_id'), - 'thread_read': fields.boolean('Read', + type='one2many', obj='mail.message', string='Temp messages', _fields_id = 'res_id', + help="Functional field holding messages related to the current document."), + 'thread_is_read': fields.boolean('Read', help="When checked, new messages require your attention."), } @@ -81,10 +82,11 @@ class mail_thread(osv.osv): #------------------------------------------------------ def create(self, cr, uid, vals, context=None): - """Automatically subscribe the creator""" - thread_id = super(mail_thread, self).create(cr, uid, vals, context=context); - self.message_subscribe(cr, uid, [thread_id], [uid], context=context) - return thread_id; + """Automatically subscribe the creator """ + thread_id = super(mail_thread, self).create(cr, uid, vals, context=context) + if thread_id: + self.message_subscribe(cr, uid, [thread_id], [uid], context=context) + return thread_id def write(self, cr, uid, ids, vals, context=None): """Automatically subscribe the writer""" @@ -103,8 +105,6 @@ class mail_thread(osv.osv): a foreign key with a 'cascade' ondelete attribute. Notifications will be deleted with messages """ - if context is None: - context = {} subscr_obj = self.pool.get('mail.subscription') msg_obj = self.pool.get('mail.message') # delete subscriptions @@ -121,13 +121,14 @@ class mail_thread(osv.osv): #------------------------------------------------------ def message_create(self, cr, uid, thread_id, vals, context=None): - """OpenSocial: wrapper of mail.message create method + """ OpenChatter: wrapper of mail.message create method - creates the mail.message - automatically subscribe the message writer - push the message to subscribed users """ if context is None: context = {} + message_obj = self.pool.get('mail.message') subscription_obj = self.pool.get('mail.subscription') notification_obj = self.pool.get('mail.notification') @@ -793,4 +794,15 @@ class mail_thread(osv.osv): to_del_notif_ids = notif_obj.search(cr, uid, ['&', ('user_id', '=', uid), ('message_id', 'in', notif_msg_ids)], context=context) return notif_obj.unlink(cr, uid, to_del_notif_ids, context=context) + #------------------------------------------------------ + # Thread_state + #------------------------------------------------------ + + def message_mark_as_read(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'thread_is_read': True}, context=context) + + def message_mark_as_unread(self, cr, uid, ids, context=None): + return self.write(cr, uid, ids, {'thread_is_read': False}, context=context) + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 9aacbba3da01710a369bc13c81c8b1f929e8ed36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Jun 2012 12:20:49 +0200 Subject: [PATCH 10/29] [IMP] crm_lead: updated mail_gateway, removed state update as this will be managed by mail.thread. bzr revid: tde@openerp.com-20120604102049-0ytmcv3dy8t2pc97 --- addons/crm/crm_lead.py | 116 ++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 59 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 0b58975bca2..93c6ac48d29 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -756,64 +756,6 @@ class crm_lead(base_stage, osv.osv): 'type': 'ir.actions.act_window', } - - def message_new(self, cr, uid, msg, custom_values=None, context=None): - """Automatically calls when new email message arrives""" - res_id = super(crm_lead, self).message_new(cr, uid, msg, custom_values=custom_values, context=context) - subject = msg.get('subject') or _("No Subject") - body = msg.get('body_text') - - msg_from = msg.get('from') - priority = msg.get('priority') - vals = { - 'name': subject, - 'email_from': msg_from, - 'email_cc': msg.get('cc'), - 'description': body, - 'user_id': False, - } - if priority: - vals['priority'] = priority - vals.update(self.message_partner_by_email(cr, uid, msg.get('from', False))) - self.write(cr, uid, [res_id], vals, context) - return res_id - - def message_update(self, cr, uid, ids, msg, vals=None, default_act='pending', context=None): - if isinstance(ids, (str, int, long)): - ids = [ids] - if vals == None: - vals = {} - super(crm_lead, self).message_update(cr, uid, ids, msg, context=context) - - if msg.get('priority') in dict(crm.AVAILABLE_PRIORITIES): - vals['priority'] = msg.get('priority') - maps = { - 'cost':'planned_cost', - 'revenue': 'planned_revenue', - 'probability':'probability' - } - vls = {} - for line in msg['body_text'].split('\n'): - line = line.strip() - res = tools.misc.command_re.match(line) - if res and maps.get(res.group(1).lower()): - key = maps.get(res.group(1).lower()) - vls[key] = res.group(2).lower() - vals.update(vls) - - # Unfortunately the API is based on lists - # but we want to update the state based on the - # previous state, so we have to loop: - for case in self.browse(cr, uid, ids, context=context): - values = dict(vals) - if case.state in CRM_LEAD_PENDING_STATES: - #re-open - values.update(state=crm.AVAILABLE_STATES[1][0]) - if not case.date_open: - values['date_open'] = time.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT) - res = self.write(cr, uid, [case.id], values, context=context) - return res - def action_makeMeeting(self, cr, uid, ids, context=None): """ This opens Meeting's calendar view to schedule meeting on current Opportunity @@ -868,7 +810,63 @@ class crm_lead(base_stage, osv.osv): if stage.on_change: vals['probability'] = stage.probability return super(crm_lead,self).write(cr, uid, ids, vals, context) - + + # ---------------------------------------- + # Mail Gateway + # ---------------------------------------- + + def message_new(self, cr, uid, msg, custom_values=None, context=None): + """ mail_thread message_new that is called by the mailgateway: + - create a new record of the related model + - add the message to the thread + This override also updates the lead according to the email. + """ + res_id = super(crm_lead, self).message_new(cr, uid, msg, custom_values=custom_values, context=context) + + name = msg.get('subject') or _("No Subject") + description = msg.get('body') + email_from = msg.get('from') + email_cc = msg.get('cc') + vals = { + 'name': name, + 'email_from': email_from, + 'email_cc': email_cc, + 'description': description, + 'user_id': False, + } + if msg.get('priority') in dict(crm.AVAILABLE_PRIORITIES): + vals['priority'] = msg.get('priority') + vals.update(self.message_partner_by_email(cr, uid, msg.get('from', False), context=context)) + self.write(cr, uid, [res_id], vals, context=context) + return res_id + + def message_update(self, cr, uid, ids, msg, vals=None, default_act='pending', context=None): + """ mail_thread message_update that is called by the mailgateway: + - add the message to the thread + This override also updates the lead according to the email. + """ + if isinstance(ids, (str, int, long)): + ids = [ids] + if vals == None: + vals = {} + update_res = super(crm_lead, self).message_update(cr, uid, ids, msg, context=context) + + if msg.get('priority') in dict(crm.AVAILABLE_PRIORITIES): + vals['priority'] = msg.get('priority') + maps = { + 'cost':'planned_cost', + 'revenue': 'planned_revenue', + 'probability':'probability' + } + for line in msg['body_text'].split('\n'): + line = line.strip() + res = tools.misc.command_re.match(line) + if res and maps.get(res.group(1).lower()): + key = maps.get(res.group(1).lower()) + vals[key] = res.group(2).lower() + self.write(cr, uid, ids, vals, context=context) + return update_res + # ---------------------------------------- # OpenChatter methods and notifications # ---------------------------------------- From 445b690488e3aeb7ddf87c3692008b033c54496c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Jun 2012 12:24:35 +0200 Subject: [PATCH 11/29] [IMP] mail_thread: message_process now automatically set the thread as unread. bzr revid: tde@openerp.com-20120604102435-hcdo3i6oqdhu6j8j --- addons/mail/mail_thread.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 3deb7f25769..d52804308a3 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -535,6 +535,8 @@ class mail_thread(osv.osv): res_id = create_record(msg) #To forward the email to other followers self.message_forward(cr, uid, model, [res_id], msg_txt, context=context) + # Set as Unread + self.message_mark_as_unreadcr, uid, [res_id], context=context) return res_id def message_new(self, cr, uid, msg_dict, custom_values=None, context=None): From 0bf38a496c6bd4c8f84c0881b63ecb9f91441e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Jun 2012 12:27:51 +0200 Subject: [PATCH 12/29] [FIX] mail_thread: added forgotten '\('. bzr revid: tde@openerp.com-20120604102751-b61hsx03guhpbye0 --- addons/mail/mail_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index d52804308a3..bfe0bc9559a 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -536,7 +536,7 @@ class mail_thread(osv.osv): #To forward the email to other followers self.message_forward(cr, uid, model, [res_id], msg_txt, context=context) # Set as Unread - self.message_mark_as_unreadcr, uid, [res_id], context=context) + self.message_mark_as_unread(cr, uid, [res_id], context=context) return res_id def message_new(self, cr, uid, msg_dict, custom_values=None, context=None): From e304cd68ebcf1af7613633efcb41417b8de7bc98 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 4 Jun 2012 12:37:35 +0200 Subject: [PATCH 13/29] Customization of kanban view for m2m bzr revid: nicolas.vanhoren@openerp.com-20120604103735-qrxlou2p8kdm2vq8 --- addons/web/static/src/js/view_form.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 0889f7d8dee..db055879051 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3410,6 +3410,8 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( 'create_text': _t("Add"), 'creatable': self.get("effective_readonly") ? false : true, 'quick_creatable': self.get("effective_readonly") ? false : true, + 'read_only_mode': self.get("effective_readonly") ? true : false, + 'confirm_on_delete': false, }); var embedded = (this.field.views || {}).kanban; if (embedded) { From 344a602f31bbae22ef228fccdf27db1e8a66136c Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 4 Jun 2012 14:36:09 +0200 Subject: [PATCH 14/29] fixed some problems for m2m_kanban bzr revid: nicolas.vanhoren@openerp.com-20120604123609-yo00px9dvr6mj2cc --- addons/web/static/src/js/view_form.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index db055879051..66586472462 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3558,6 +3558,7 @@ instance.web.form.Many2ManyQuickCreate = instance.web.Widget.extend({ var self = this; self.$text.val(""); self.trigger('added', id); + this.m2m.dataset_changed(); }, }); } @@ -3612,7 +3613,7 @@ instance.web.form.AbstractFormPopup = instance.web.OldWidget.extend({ width: '90%', min_width: '800px', close: function() { - self.check_exit(); + self.check_exit(true); }, title: this.options.title || "", }, this.$element).open(); @@ -3670,9 +3671,10 @@ instance.web.form.AbstractFormPopup = instance.web.OldWidget.extend({ }, on_select_elements: function(element_ids) { }, - check_exit: function() { + check_exit: function(no_destroy) { if (this.created_elements.length > 0) { this.on_select_elements(this.created_elements); + this.created_elements = []; } this.destroy(); }, From 6ce3b6aeefd9c1fb1ead1e775942b8af29433a2d Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 4 Jun 2012 14:45:43 +0200 Subject: [PATCH 15/29] Removed ability to click to link in m2m_tags bzr revid: nicolas.vanhoren@openerp.com-20120604124543-tc39k033k5ny1k42 --- addons/web/static/src/css/base.css | 3 +-- addons/web/static/src/css/base.sass | 1 - addons/web/static/src/js/view_form.js | 26 +------------------------- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index e2879011a72..1f568df46e8 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1,4 +1,4 @@ -@charset "UTF-8"; +@charset "utf-8"; @font-face { font-family: "mnmliconsRegular"; src: url("/web/static/src/font/mnmliconsv21-webfont.eot") format("eot"); @@ -1787,7 +1787,6 @@ color: black; padding: 0px 3px 0px 3px; margin: 0 2px 2px 0; - cursor: pointer; height: 16px; font: 11px "lucida grande", tahoma, verdana, arial, sans-serif; } diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index eda410aa6ca..72cef4f52f7 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1429,7 +1429,6 @@ $colour4: #8a89ba color: black padding: 0px 3px 0px 3px margin: 0 2px 2px 0 - cursor: pointer height: 16px font: 11px "lucida grande", tahoma, verdana, arial, sans-serif .text-core .text-wrap .text-dropdown .text-list .text-suggestion em diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 66586472462..ec4861956b5 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3099,7 +3099,7 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(_. if (this.get("effective_readonly")) return; var self = this; - self. $text = $("textarea", this.$element); + self.$text = $("textarea", this.$element); self.$text.textext({ plugins : 'tags arrow autocomplete', autocomplete: { @@ -3151,19 +3151,6 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(_. return _.extend(el, {index:i}); })}); }); - }).bind('tagClick', function(e, tag, value, callback) { - var pop = new instance.web.form.FormOpenPopup(self.view); - pop.show_element( - self.field.relation, - value.id, - self.build_context(), - { - title: _t("Open: ") + (self.string || self.name) - } - ); - pop.on_write_completed.add_last(function() { - self.render_value(); - }); }).bind('hideDropdown', function() { self._drop_shown = false; }).bind('showDropdown', function() { @@ -3207,17 +3194,6 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(_. self.tags.addTags(_.map(data, function(el) {return {name: el[1], id:el[0]};})); } else { self.$element.html(QWeb.render("FieldMany2ManyTags.box", {elements: data})); - $(".oe_form_field_many2manytags_box", self.$element).click(function() { - var index = Number($(this).data("index")); - self.do_action({ - type: 'ir.actions.act_window', - res_model: self.field.relation, - res_id: self.get("value")[index], - context: self.build_context(), - views: [[false, 'form']], - target: 'current' - }); - }); } }; if (! self.get('values') || self.get('values').length > 0) { From bb5f7d384d574461fc031de1cf41181a5bd6a90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 4 Jun 2012 16:12:54 +0200 Subject: [PATCH 16/29] [IMP] crm_lead, crm_claim, crm_fundraising, crm_helpdesk, hr_recruitment, project_issue, project_mailgate: cleaned and updated message_new and message_update to have a cleaner mailgate. Deleted references to state update. bzr revid: tde@openerp.com-20120604141254-4m2tnzwi88w8h2aj --- addons/crm/crm_lead.py | 58 +++++++--------- addons/crm/crm_lead_view.xml | 6 ++ addons/crm_claim/crm_claim.py | 66 ++++++++---------- addons/crm_fundraising/crm_fundraising.py | 29 ++++---- addons/crm_helpdesk/crm_helpdesk.py | 61 ++++++++-------- addons/hr_recruitment/hr_recruitment.py | 65 +++++++++-------- addons/mail/mail_thread.py | 33 ++++++--- addons/project_issue/project_issue.py | 77 +++++++++------------ addons/project_mailgate/project_mailgate.py | 43 ++++++------ 9 files changed, 216 insertions(+), 222 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 93c6ac48d29..71432c284ae 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -262,11 +262,10 @@ class crm_lead(base_stage, osv.osv): def get_needaction_user_ids(self, cr, uid, ids, context=None): result = dict.fromkeys(ids, []) for obj in self.browse(cr, uid, ids, context=context): - # salesman must perform an action when in draft mode - if obj.state == 'draft' and obj.user_id: + if obj.thread_is_read == False and hasattr(obj, 'user_id') and obj.user_id: result[obj.id] = [obj.user_id.id] return result - + def create(self, cr, uid, vals, context=None): obj_id = super(crm_lead, self).create(cr, uid, vals, context) self.create_send_note(cr, uid, [obj_id], context=context) @@ -816,56 +815,47 @@ class crm_lead(base_stage, osv.osv): # ---------------------------------------- def message_new(self, cr, uid, msg, custom_values=None, context=None): - """ mail_thread message_new that is called by the mailgateway: - - create a new record of the related model - - add the message to the thread - This override also updates the lead according to the email. + """ Overrides mail_thread message_new that is called by the mailgateway + through message_process. + This override updates the document according to the email. """ - res_id = super(crm_lead, self).message_new(cr, uid, msg, custom_values=custom_values, context=context) - - name = msg.get('subject') or _("No Subject") - description = msg.get('body') - email_from = msg.get('from') - email_cc = msg.get('cc') - vals = { - 'name': name, - 'email_from': email_from, - 'email_cc': email_cc, - 'description': description, + if custom_values is None: custom_values = {} + custom_values.update({ + 'name': msg.get('subject') or _("No Subject"), + 'description': msg.get('body_text'), + 'email_from': msg.get('from'), + 'email_cc': msg.get('cc'), 'user_id': False, - } + }) if msg.get('priority') in dict(crm.AVAILABLE_PRIORITIES): - vals['priority'] = msg.get('priority') - vals.update(self.message_partner_by_email(cr, uid, msg.get('from', False), context=context)) - self.write(cr, uid, [res_id], vals, context=context) - return res_id + custom_values['priority'] = msg.get('priority') + custom_values.update(self.message_partner_by_email(cr, uid, msg.get('from', False), context=context)) + return super(crm_lead, self).message_new(cr, uid, msg, custom_values=custom_values, context=context) - def message_update(self, cr, uid, ids, msg, vals=None, default_act='pending', context=None): - """ mail_thread message_update that is called by the mailgateway: - - add the message to the thread - This override also updates the lead according to the email. + def message_update(self, cr, uid, ids, msg, update_vals=None, context=None): + """ Overrides mail_thread message_update that is called by the mailgateway + through message_process. + This method updates the document according to the email. """ if isinstance(ids, (str, int, long)): ids = [ids] - if vals == None: - vals = {} - update_res = super(crm_lead, self).message_update(cr, uid, ids, msg, context=context) + if update_vals is None: update_vals = {} if msg.get('priority') in dict(crm.AVAILABLE_PRIORITIES): vals['priority'] = msg.get('priority') maps = { 'cost':'planned_cost', 'revenue': 'planned_revenue', - 'probability':'probability' + 'probability':'probability', } - for line in msg['body_text'].split('\n'): + for line in msg.get('body_text', '').split('\n'): line = line.strip() res = tools.misc.command_re.match(line) if res and maps.get(res.group(1).lower()): key = maps.get(res.group(1).lower()) vals[key] = res.group(2).lower() - self.write(cr, uid, ids, vals, context=context) - return update_res + + return super(crm_lead, self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context) # ---------------------------------------- # OpenChatter methods and notifications diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 07e295d4e4c..3308e080a57 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -70,6 +70,10 @@ states="cancel"/>