From 003ac3c0535949190c7d264e87d5c101b47c63b5 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 30 Jul 2012 12:24:35 +0530 Subject: [PATCH 001/175] [ADD] Add mail.message.subtype model in mail bzr revid: fka@tinyerp.com-20120730065435-u586t9y9gtfmx5tl --- addons/mail/__init__.py | 1 + addons/mail/__openerp__.py | 1 + 2 files changed, 2 insertions(+) diff --git a/addons/mail/__init__.py b/addons/mail/__init__.py index 805c27386f3..bac92a833ff 100644 --- a/addons/mail/__init__.py +++ b/addons/mail/__init__.py @@ -19,6 +19,7 @@ # ############################################################################## +import mail_message_subtype import mail_message import mail_thread import mail_group diff --git a/addons/mail/__openerp__.py b/addons/mail/__openerp__.py index ee22b0c153f..b8b359b8922 100644 --- a/addons/mail/__openerp__.py +++ b/addons/mail/__openerp__.py @@ -62,6 +62,7 @@ The main features of the module are: 'depends': ['base', 'base_tools'], 'data': [ 'wizard/mail_compose_message_view.xml', + 'mail_message_subtype.xml', 'mail_message_view.xml', 'mail_subscription_view.xml', 'mail_thread_view.xml', From cb473c4ffccfbf680d5bcbb6b64753315beeeac4 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 30 Jul 2012 12:33:29 +0530 Subject: [PATCH 002/175] [ADD] mail_message_subtype files added in mail bzr revid: fka@tinyerp.com-20120730070329-0iyb0r1908a8y86r --- addons/mail/mail_message_subtype.py | 41 ++++++++++++++++++++ addons/mail/mail_message_subtype.xml | 56 ++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 addons/mail/mail_message_subtype.py create mode 100644 addons/mail/mail_message_subtype.xml diff --git a/addons/mail/mail_message_subtype.py b/addons/mail/mail_message_subtype.py new file mode 100644 index 00000000000..0a167a0f1d9 --- /dev/null +++ b/addons/mail/mail_message_subtype.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2009-today OpenERP SA () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see +# +############################################################################## + +from osv import osv +from osv import fields + +class mail_message_subtype(osv.osv): + + _name = 'mail.message.subtype' + _description = 'mail_message_subtype' + _columns = { + 'name': fields.char(' Message Subtype ', size = 128, + required = True, select = 1, + help = 'Subtype Of Message'), + 'model_ids': fields.many2many('ir.model', + 'mail_message_subtyp_message_rel', + 'message_subtype_id', 'model_id', 'Model', + help = "link some subtypes to several models, for projet/task"), + 'default': fields.boolean('Default', help = "When subscribing to the document, users will receive by default messages related to this subtype unless they uncheck this subtype"), + } + _defaults = { + 'default': True, + } diff --git a/addons/mail/mail_message_subtype.xml b/addons/mail/mail_message_subtype.xml new file mode 100644 index 00000000000..8de3224470f --- /dev/null +++ b/addons/mail/mail_message_subtype.xml @@ -0,0 +1,56 @@ + + + + + + + + mail.message.subtype.tree + mail.message.subtype + tree + 10 + + + + + + + + + + + mail.message.subtype.form + mail.message.subtype + form + +
+ + + + + + + + + + + + +
+
+
+ + + Subtypes + mail.message.subtype + form + tree,form + + + + +
+
From b5c3a5327fcceb6d6c8843cd148e2f72d728ca08 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 30 Jul 2012 14:38:04 +0530 Subject: [PATCH 003/175] [ADD] Add many2many subtype_id field in mail.subscription bzr revid: fka@tinyerp.com-20120730090804-x3lpju3fq11hg703 --- addons/mail/mail_subscription.py | 4 ++++ addons/mail/mail_subscription_view.xml | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/addons/mail/mail_subscription.py b/addons/mail/mail_subscription.py index fc82af879a9..a3baa024ef0 100644 --- a/addons/mail/mail_subscription.py +++ b/addons/mail/mail_subscription.py @@ -42,6 +42,10 @@ class mail_subscription(osv.osv): help='Id of the followed resource'), 'user_id': fields.many2one('res.users', string='Related User', ondelete='cascade', required=True, select=1), + 'subtype_ids': fields.many2many('mail.message.subtype', + 'mail_message_subtyp_rel', + 'subscription_id', 'subtype_id', 'Subtype', + help = "linking some subscription to several subtype for projet/task"), } class mail_notification(osv.osv): diff --git a/addons/mail/mail_subscription_view.xml b/addons/mail/mail_subscription_view.xml index c3d79d48308..b88b8c25258 100644 --- a/addons/mail/mail_subscription_view.xml +++ b/addons/mail/mail_subscription_view.xml @@ -20,6 +20,27 @@ + + mail.subscription.form + mail.subscription + form + +
+ + + + + + + + + + + + +
+
+
From c494b78f7776f64bde8d4cdefa82f7cdda867548 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 30 Jul 2012 15:05:50 +0530 Subject: [PATCH 004/175] [ADD] Add many2one subtype_id field in mail.message bzr revid: fka@tinyerp.com-20120730093550-h9xnithn5h3eq5nk --- addons/mail/mail_message.py | 1 + addons/mail/mail_message_view.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index b96b6e3791e..14de51b39ab 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -230,6 +230,7 @@ class mail_message(osv.Model): select=True, ondelete='set null', help="Parent message, used for displaying as threads with hierarchy"), 'child_ids': fields.one2many('mail.message', 'parent_id', 'Child Messages'), + 'subtype_id': fields.many2one('mail.message.subtype', 'Subtype', select = True), } _defaults = { diff --git a/addons/mail/mail_message_view.xml b/addons/mail/mail_message_view.xml index 986bb4bef38..374b97624b1 100644 --- a/addons/mail/mail_message_view.xml +++ b/addons/mail/mail_message_view.xml @@ -152,6 +152,7 @@ + From 24264e759d42ab47f0b4b7f11a1341a3108c08b8 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Mon, 6 Aug 2012 16:10:15 +0530 Subject: [PATCH 005/175] [IMP] make changes into thread file bzr revid: rma@tinyerp.com-20120806104015-et9znlwd5lrqggfn --- addons/mail/mail_message.py | 3 ++- addons/mail/mail_thread.py | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 14de51b39ab..8b88647b108 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -275,6 +275,7 @@ class mail_message(osv.Model): def create(self, cr, uid, values, context=None): self.check(cr, uid, [], mode='create', context=context, values=values) return super(mail_message, self).create(cr, uid, values, context) + def read(self, cr, uid, ids, fields_to_read=None, context=None, load='_classic_read'): self.check(cr, uid, ids, 'read', context=context) @@ -392,7 +393,7 @@ class mail_message(osv.Model): def cancel(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'state':'cancel'}, context=context) - + def process_email_queue(self, cr, uid, ids=None, context=None): """Send immediately queued messages, committing after each message is sent - this is not transactional and should diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 1655ab98afb..0afddc747d6 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -176,7 +176,7 @@ class mail_thread(osv.Model): email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context=context) return msg_id - + #TODO :in message creation: in push method: push only if user is subscriber (current case) and if user is sucscribed to the subtype (to add) def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, context=None): subscription_obj = self.pool.get('mail.subscription') # get body @@ -327,7 +327,7 @@ class mail_thread(osv.Model): if partner_ids is None: partner_ids = [] mail_partner_ids = [(6, 0, partner_ids)] - + data = { 'subject': subject, 'body_text': body_text or (hasattr(thread, 'description') and thread.description or ''), @@ -363,7 +363,6 @@ class mail_thread(osv.Model): new_msg_ids.append(self.message_create(cr, uid, thread.id, data, context=context)) return new_msg_ids - def message_append_dict(self, cr, uid, ids, msg_dict, context=None): """Creates a new mail.message attached to the given threads (``ids``), with the contents of ``msg_dict``, by calling ``message_append`` @@ -874,6 +873,10 @@ class mail_thread(osv.Model): :param user_ids: a list of user_ids; if not set, subscribe uid instead """ + # TODO:Update Massage Subscribe and add paramenter subtype_ids + # if subtype_ids is False: add default ones (res_model = self._name, default = True) + # in method: if user_id already subscriber, update its subscription with subtype_ids + subscription_obj = self.pool.get('mail.subscription') to_subscribe_uids = [uid] if user_ids is None else user_ids create_ids = [] @@ -883,7 +886,8 @@ class mail_thread(osv.Model): if user_id in already_subscribed_user_ids: continue create_ids.append(subscription_obj.create(cr, uid, {'res_model': self._name, 'res_id': id, 'user_id': user_id}, context=context)) return create_ids - + #TODO : Add method : add message_subscribe_udpate_subtypes(..., user_id, subtype_ids): + def message_unsubscribe(self, cr, uid, ids, user_ids = None, context=None): """ Unsubscribe the user (or user_ids) from the current document. @@ -900,7 +904,8 @@ class mail_thread(osv.Model): if not to_delete_sub_ids: return False return subscription_obj.unlink(cr, uid, to_delete_sub_ids, context=context) - + #TODO : Add Method : add message_subscribeption_remove_subtype(..., user_id, subtype_id): + #TODO : Add method : add message_subscription_remove_subtype_name(.., user_id, subtype_name) #------------------------------------------------------ # Notification API #------------------------------------------------------ From d00b0a9d0e9f81f89fb5a222add0b55884fa917f Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 8 Aug 2012 17:58:12 +0530 Subject: [PATCH 006/175] [IMP] improve mail_thread bzr revid: fka@tinyerp.com-20120808122812-v0hw80phlnb9es75 --- addons/mail/mail_thread.py | 315 ++++++++++++++++++++----------------- 1 file changed, 171 insertions(+), 144 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 0afddc747d6..3e5bfabe350 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -62,33 +62,33 @@ class mail_thread(osv.Model): _name = 'mail.thread' _description = 'Email Thread' - def _get_message_ids(self, cr, uid, ids, name, args, context=None): + def _get_message_ids(self, cr, uid, ids, name, args, context = None): res = {} for id in ids: - message_ids = self.message_search(cr, uid, [id], context=context) - subscriber_ids = self.message_get_subscribers(cr, uid, [id], context=context) + message_ids = self.message_search(cr, uid, [id], context = context) + subscriber_ids = self.message_get_subscribers(cr, uid, [id], context = context) res[id] = { 'message_ids': message_ids, 'message_summary': "9 %d + %d" % (len(message_ids), len(subscriber_ids)), } return res - def _search_message_ids(self, cr, uid, obj, name, args, context=None): + def _search_message_ids(self, cr, uid, obj, name, args, context = None): msg_obj = self.pool.get('mail.message') - msg_ids = msg_obj.search(cr, uid, ['&', ('res_id', 'in', args[0][2]), ('model', '=', self._name)], context=context) + msg_ids = msg_obj.search(cr, uid, ['&', ('res_id', 'in', args[0][2]), ('model', '=', self._name)], context = context) return [('id', 'in', msg_ids)] _columns = { - 'message_ids': fields.function(_get_message_ids, method=True, - fnct_search=_search_message_ids, - type='one2many', obj='mail.message', _fields_id = 'res_id', - string='Temp messages', multi="_get_message_ids", - help="Functional field holding messages related to the current document."), + 'message_ids': fields.function(_get_message_ids, method = True, + fnct_search = _search_message_ids, + type = 'one2many', obj = 'mail.message', _fields_id = 'res_id', + string = 'Temp messages', multi = "_get_message_ids", + help = "Functional field holding messages related to the current document."), 'message_state': fields.boolean('Read', - help="When checked, new messages require your attention."), - 'message_summary': fields.function(_get_message_ids, method=True, - type='text', string='Summary', multi="_get_message_ids", - help="Holds the Chatter summary (number of messages, ...). "\ + help = "When checked, new messages require your attention."), + 'message_summary': fields.function(_get_message_ids, method = True, + type = 'text', string = 'Summary', multi = "_get_message_ids", + help = "Holds the Chatter summary (number of messages, ...). "\ "This summary is directly in html format in order to "\ "be inserted in kanban views."), } @@ -101,23 +101,23 @@ class mail_thread(osv.Model): # Automatic subscription when creating/reading #------------------------------------------------------ - def create(self, cr, uid, vals, context=None): + def create(self, cr, uid, vals, context = None): """Automatically subscribe the creator """ - thread_id = super(mail_thread, self).create(cr, uid, vals, context=context) + 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) + self.message_subscribe(cr, uid, [thread_id], [uid], context = context) return thread_id - def write(self, cr, uid, ids, vals, context=None): + def write(self, cr, uid, ids, vals, context = None): """Automatically subscribe the writer""" if isinstance(ids, (int, long)): ids = [ids] - write_res = super(mail_thread, self).write(cr, uid, ids, vals, context=context); + write_res = super(mail_thread, self).write(cr, uid, ids, vals, context = context); if write_res: - self.message_subscribe(cr, uid, ids, [uid], context=context) + self.message_subscribe(cr, uid, ids, [uid], context = context) return write_res; - def unlink(self, cr, uid, ids, context=None): + def unlink(self, cr, uid, ids, context = None): """Override unlink, to automatically delete - subscriptions - messages @@ -128,19 +128,19 @@ class mail_thread(osv.Model): subscr_obj = self.pool.get('mail.subscription') msg_obj = self.pool.get('mail.message') # delete subscriptions - subscr_to_del_ids = subscr_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context=context) - subscr_obj.unlink(cr, uid, subscr_to_del_ids, context=context) + subscr_to_del_ids = subscr_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context = context) + subscr_obj.unlink(cr, uid, subscr_to_del_ids, context = context) # delete messages and notifications - msg_to_del_ids = msg_obj.search(cr, uid, [('model', '=', self._name), ('res_id', 'in', ids)], context=context) - msg_obj.unlink(cr, uid, msg_to_del_ids, context=context) + msg_to_del_ids = msg_obj.search(cr, uid, [('model', '=', self._name), ('res_id', 'in', ids)], context = context) + msg_obj.unlink(cr, uid, msg_to_del_ids, context = context) - return super(mail_thread, self).unlink(cr, uid, ids, context=context) + return super(mail_thread, self).unlink(cr, uid, ids, context = context) #------------------------------------------------------ # mail.message wrappers and tools #------------------------------------------------------ - def message_create(self, cr, uid, thread_id, vals, context=None): + def message_create(self, cr, uid, thread_id, vals, context = None): """ OpenChatter: wrapper of mail.message create method - creates the mail.message - automatically subscribe the message writer @@ -155,57 +155,58 @@ class mail_thread(osv.Model): # automatically subscribe the writer of the message if vals['user_id']: - self.message_subscribe(cr, uid, [thread_id], [vals['user_id']], context=context) + self.message_subscribe(cr, uid, [thread_id], [vals['user_id']], context = context) # create message - msg_id = message_obj.create(cr, uid, vals, context=context) + msg_id = message_obj.create(cr, uid, vals, context = context) # Set as unread if writer is not the document responsible - self.message_create_set_unread(cr, uid, [thread_id], context=context) + self.message_create_set_unread(cr, uid, [thread_id], context = context) # special: if install mode, do not push demo data if context.get('install_mode', False): return msg_id # get users that will get a notification pushed - user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context=context) + user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context = context) for id in user_to_push_ids: - notification_obj.create(cr, uid, {'user_id': id, 'message_id': msg_id}, context=context) + notification_obj.create(cr, uid, {'user_id': id, 'message_id': msg_id}, context = context) # create the email to send - email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context=context) + email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context = context) return msg_id + #TODO :in message creation: in push method: push only if user is subscriber (current case) and if user is sucscribed to the subtype (to add) - def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, context=None): + def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, context = None): subscription_obj = self.pool.get('mail.subscription') # get body body = new_msg_vals.get('body_html', '') if new_msg_vals.get('content_subtype') == 'html' else new_msg_vals.get('body_text', '') # get subscribers - notif_user_ids = self.message_get_subscribers(cr, uid, thread_ids, context=context) + notif_user_ids = self.message_get_subscribers(cr, uid, thread_ids, context = context) # add users requested via parsing message (@login) - notif_user_ids += self.message_parse_users(cr, uid, body, context=context) + notif_user_ids += self.message_parse_users(cr, uid, body, context = context) # add users requested to perform an action (need_action mechanism) if hasattr(self, 'get_needaction_user_ids'): - user_ids_dict = self.get_needaction_user_ids(cr, uid, thread_ids, context=context) + user_ids_dict = self.get_needaction_user_ids(cr, uid, thread_ids, context = context) for id, user_ids in user_ids_dict.iteritems(): notif_user_ids += user_ids # add users notified of the parent messages (because: if parent message contains @login, login must receive the replies) if new_msg_vals.get('parent_id'): notif_obj = self.pool.get('mail.notification') - parent_notif_ids = notif_obj.search(cr, uid, [('message_id', '=', new_msg_vals.get('parent_id'))], context=context) - parent_notifs = notif_obj.read(cr, uid, parent_notif_ids, context=context) + parent_notif_ids = notif_obj.search(cr, uid, [('message_id', '=', new_msg_vals.get('parent_id'))], context = context) + parent_notifs = notif_obj.read(cr, uid, parent_notif_ids, context = context) notif_user_ids += [parent_notif['user_id'][0] for parent_notif in parent_notifs] # remove duplicate entries notif_user_ids = list(set(notif_user_ids)) return notif_user_ids - def message_parse_users(self, cr, uid, string, context=None): + def message_parse_users(self, cr, uid, string, context = None): """Parse message content - if find @login -(^|\s)@((\w|@|\.)*)-: returns the related ids this supports login that are emails (such as @raoul@grobedon.net) @@ -213,14 +214,14 @@ class mail_thread(osv.Model): regex = re.compile('(^|\s)@((\w|@|\.)*)') login_lst = [item[1] for item in regex.findall(string)] if not login_lst: return [] - user_ids = self.pool.get('res.users').search(cr, uid, [('login', 'in', login_lst)], context=context) + user_ids = self.pool.get('res.users').search(cr, uid, [('login', 'in', login_lst)], context = context) return user_ids #------------------------------------------------------ # Generic message api #------------------------------------------------------ - def message_capable_models(self, cr, uid, context=None): + def message_capable_models(self, cr, uid, context = None): ret_dict = {} for model_name in self.pool.obj_list(): model = self.pool.get(model_name) @@ -228,13 +229,13 @@ class mail_thread(osv.Model): ret_dict[model_name] = model._description return ret_dict - def message_append(self, cr, uid, threads, subject, body_text=None, body_html=None, - type='email', email_date=None, parent_id=False, - content_subtype='plain', state=None, - partner_ids=None, email_from=False, email_to=False, - email_cc=None, email_bcc=None, reply_to=None, - headers=None, message_id=False, references=None, - attachments=None, original=None, context=None): + def message_append(self, cr, uid, threads, subject, body_text = None, body_html = None, + type = 'email', subtype_id = False, email_date = None, parent_id = False, + content_subtype = 'plain', state = None, + partner_ids = None, email_from = False, email_to = False, + email_cc = None, email_bcc = None, reply_to = None, + headers = None, message_id = False, references = None, + attachments = None, original = None, context = None): """ Creates a new mail.message through message_create. The new message is attached to the current mail.thread, containing all the details passed as parameters. All attachments will be attached to the @@ -298,7 +299,7 @@ class mail_thread(osv.Model): if all(isinstance(thread_id, (int, long)) for thread_id in threads): model = context.get('thread_model') or self._name model_pool = self.pool.get(model) - threads = model_pool.browse(cr, uid, threads, context=context) + threads = model_pool.browse(cr, uid, threads, context = context) ir_attachment = self.pool.get('ir.attachment') mail_message = self.pool.get('mail.message') @@ -318,7 +319,7 @@ class mail_thread(osv.Model): 'res_model': thread._name, 'res_id': thread.id, } - to_attach.append(ir_attachment.create(cr, uid, data_attach, context=context)) + to_attach.append(ir_attachment.create(cr, uid, data_attach, context = context)) # find related partner: partner_id column in thread object, or self is res.partner model partner_id = ('partner_id' in thread._columns.keys()) and (thread.partner_id and thread.partner_id.id or False) or False if not partner_id and thread._name == 'res.partner': @@ -361,9 +362,10 @@ class mail_thread(osv.Model): 'reply_to': reply_to, 'original': original, }) - new_msg_ids.append(self.message_create(cr, uid, thread.id, data, context=context)) + new_msg_ids.append(self.message_create(cr, uid, thread.id, data, context = context)) return new_msg_ids - def message_append_dict(self, cr, uid, ids, msg_dict, context=None): + + def message_append_dict(self, cr, uid, ids, msg_dict, context = None): """Creates a new mail.message attached to the given threads (``ids``), with the contents of ``msg_dict``, by calling ``message_append`` with the mail details. All attachments in msg_dict will be @@ -382,9 +384,10 @@ class mail_thread(osv.Model): return self.message_append(cr, uid, ids, subject = msg_dict.get('subject'), body_text = msg_dict.get('body_text'), - body_html= msg_dict.get('body_html'), + body_html = msg_dict.get('body_html'), parent_id = msg_dict.get('parent_id', False), type = msg_dict.get('type', 'email'), + subtype_id = msg_dict.get('subtype_id', False), content_subtype = msg_dict.get('content_subtype'), state = msg_dict.get('state'), partner_ids = msg_dict.get('partner_ids'), @@ -406,7 +409,7 @@ class mail_thread(osv.Model): # Message loading #------------------------------------------------------ - def _message_search_ancestor_ids(self, cr, uid, ids, child_ids, ancestor_ids, context=None): + def _message_search_ancestor_ids(self, cr, uid, ids, child_ids, ancestor_ids, context = None): """ Given message child_ids ids, find their ancestors until ancestor_ids using their parent_id relationship. @@ -425,13 +428,13 @@ class mail_thread(osv.Model): ] message_obj = self.pool.get('mail.message') - messages_temp = message_obj.read(cr, uid, child_ids, ['id', 'parent_id'], context=context) + messages_temp = message_obj.read(cr, uid, child_ids, ['id', 'parent_id'], context = context) parent_ids = _get_parent_ids(messages_temp, ancestor_ids, child_ids) child_ids += parent_ids cur_iter = 0; max_iter = 100; # avoid infinite loop while (parent_ids and (cur_iter < max_iter)): cur_iter += 1 - messages_temp = message_obj.read(cr, uid, parent_ids, ['id', 'parent_id'], context=context) + messages_temp = message_obj.read(cr, uid, parent_ids, ['id', 'parent_id'], context = context) parent_ids = _get_parent_ids(messages_temp, ancestor_ids, child_ids) child_ids += parent_ids if (cur_iter > max_iter): @@ -440,7 +443,7 @@ class mail_thread(osv.Model): "message graph, leading to a curious error. Have fun.") return child_ids - def message_search_get_domain(self, cr, uid, ids, context=None): + def message_search_get_domain(self, cr, uid, ids, context = None): """ OpenChatter feature: get the domain to search the messages related to a document. mail.thread defines the default behavior as being messages with model = self._name, id in ids. @@ -449,8 +452,8 @@ class mail_thread(osv.Model): """ return ['&', ('res_id', 'in', ids), ('model', '=', self._name)] - def message_search(self, cr, uid, ids, fetch_ancestors=False, ancestor_ids=None, - limit=100, offset=0, domain=None, count=False, context=None): + def message_search(self, cr, uid, ids, fetch_ancestors = False, ancestor_ids = None, + limit = 100, offset = 0, domain = None, count = False, context = None): """ OpenChatter feature: return thread messages ids according to the search domain given by ``message_search_get_domain``. @@ -477,17 +480,17 @@ class mail_thread(osv.Model): default domain. :param limit, offset, count, context: as usual """ - search_domain = self.message_search_get_domain(cr, uid, ids, context=context) + search_domain = self.message_search_get_domain(cr, uid, ids, context = context) if domain: search_domain += domain message_obj = self.pool.get('mail.message') - message_res = message_obj.search(cr, uid, search_domain, limit=limit, offset=offset, count=count, context=context) + message_res = message_obj.search(cr, uid, search_domain, limit = limit, offset = offset, count = count, context = context) if not count and fetch_ancestors: - message_res += self._message_search_ancestor_ids(cr, uid, ids, message_res, ancestor_ids, context=context) + message_res += self._message_search_ancestor_ids(cr, uid, ids, message_res, ancestor_ids, context = context) return message_res - def message_read(self, cr, uid, ids, fetch_ancestors=False, ancestor_ids=None, - limit=100, offset=0, domain=None, context=None): + def message_read(self, cr, uid, ids, fetch_ancestors = False, ancestor_ids = None, + limit = 100, offset = 0, domain = None, context = None): """ OpenChatter feature: read the messages related to some threads. This method is used mainly the Chatter widget, to directly have read result instead of searching then reading. @@ -495,8 +498,8 @@ class mail_thread(osv.Model): Please see message_search for more information about the parameters. """ message_ids = self.message_search(cr, uid, ids, fetch_ancestors, ancestor_ids, - limit, offset, domain, context=context) - messages = self.pool.get('mail.message').read(cr, uid, message_ids, context=context) + limit, offset, domain, context = context) + messages = self.pool.get('mail.message').read(cr, uid, message_ids, context = context) """ Retrieve all attachments names """ map_id_to_name = dict((attachment_id, '') for message in messages for attachment_id in message['attachment_ids']) @@ -506,7 +509,7 @@ class mail_thread(osv.Model): map_id_to_name[attach_id] = '' # use empty string as a placeholder ids = map_id_to_name.keys() - names = self.pool.get('ir.attachment').name_get(cr, uid, ids, context=context) + names = self.pool.get('ir.attachment').name_get(cr, uid, ids, context = context) # convert the list of tuples into a dictionnary for name in names: @@ -520,13 +523,13 @@ class mail_thread(osv.Model): msg["attachments"].append({'id': attach_id, 'name': map_id_to_name[attach_id]}) # Set the threads as read - self.message_check_and_set_read(cr, uid, ids, context=context) + self.message_check_and_set_read(cr, uid, ids, context = context) # Sort and return the messages - messages = sorted(messages, key=lambda d: (-d['id'])) + messages = sorted(messages, key = lambda d: (-d['id'])) return messages - def message_get_pushed_messages(self, cr, uid, ids, fetch_ancestors=False, ancestor_ids=None, - limit=100, offset=0, msg_search_domain=[], context=None): + def message_get_pushed_messages(self, cr, uid, ids, fetch_ancestors = False, ancestor_ids = None, + limit = 100, offset = 0, msg_search_domain = [], context = None): """ OpenChatter: wall: get the pushed notifications and used them to fetch messages to display on the wall. @@ -550,13 +553,13 @@ class mail_thread(osv.Model): # compose final domain domain = [('user_id', '=', uid)] + msg_search_domain # get notifications - notification_ids = notification_obj.search(cr, uid, domain, limit=limit, offset=offset, context=context) - notifications = notification_obj.browse(cr, uid, notification_ids, context=context) + notification_ids = notification_obj.search(cr, uid, domain, limit = limit, offset = offset, context = context) + notifications = notification_obj.browse(cr, uid, notification_ids, context = context) msg_ids = [notification.message_id.id for notification in notifications] # get messages - msg_ids = msg_obj.search(cr, uid, [('id', 'in', msg_ids)], context=context) - if (fetch_ancestors): msg_ids = self._message_search_ancestor_ids(cr, uid, ids, msg_ids, ancestor_ids, context=context) - msgs = msg_obj.read(cr, uid, msg_ids, context=context) + msg_ids = msg_obj.search(cr, uid, [('id', 'in', msg_ids)], context = context) + if (fetch_ancestors): msg_ids = self._message_search_ancestor_ids(cr, uid, ids, msg_ids, ancestor_ids, context = context) + msgs = msg_obj.read(cr, uid, msg_ids, context = context) return msgs #------------------------------------------------------ @@ -564,9 +567,9 @@ class mail_thread(osv.Model): #------------------------------------------------------ # message_process will call either message_new or message_update. - def message_process(self, cr, uid, model, message, custom_values=None, - save_original=False, strip_attachments=False, - context=None): + def message_process(self, cr, uid, model, message, custom_values = None, + save_original = False, strip_attachments = False, + context = None): """Process an incoming RFC2822 email message related to the given thread model, relying on ``mail.message.parse()`` for the parsing operation, and then calling ``message_new`` @@ -606,7 +609,7 @@ class mail_thread(osv.Model): if isinstance(message, unicode): message = message.encode('utf-8') msg_txt = email.message_from_string(message) - msg = mail_message.parse_message(msg_txt, save_original=save_original, context=context) + msg = mail_message.parse_message(msg_txt, save_original = save_original, context = context) # update state msg['state'] = 'received' @@ -619,7 +622,7 @@ class mail_thread(osv.Model): if hasattr(model_pool, 'message_new'): return model_pool.message_new(cr, uid, msg, custom_values, - context=context) + context = context) res_id = False if msg.get('references') or msg.get('in-reply-to'): references = msg.get('references') or msg.get('in-reply-to') @@ -640,19 +643,19 @@ class mail_thread(osv.Model): res_id = res_id if model_pool.exists(cr, uid, res_id): if hasattr(model_pool, 'message_update'): - model_pool.message_update(cr, uid, [res_id], msg, {}, context=context) + model_pool.message_update(cr, uid, [res_id], msg, {}, context = context) else: # referenced thread was not found, we'll have to create a new one res_id = False if not res_id: res_id = create_record(msg) # To forward the email to other followers - self.message_forward(cr, uid, model, [res_id], msg_txt, context=context) + self.message_forward(cr, uid, model, [res_id], msg_txt, context = context) # Set as Unread - model_pool.message_mark_as_unread(cr, uid, [res_id], context=context) + model_pool.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): + def message_new(self, cr, uid, msg_dict, custom_values = None, context = None): """Called by ``message_process`` when a new message is received for a given thread model, if the message did not belong to an existing thread. @@ -681,17 +684,17 @@ class mail_thread(osv.Model): context = {} model = context.get('thread_model') or self._name model_pool = self.pool.get(model) - fields = model_pool.fields_get(cr, uid, context=context) - data = model_pool.default_get(cr, uid, fields, context=context) + fields = model_pool.fields_get(cr, uid, context = context) + data = model_pool.default_get(cr, uid, fields, context = context) if 'name' in fields and not data.get('name'): data['name'] = msg_dict.get('from', '') if custom_values and isinstance(custom_values, dict): data.update(custom_values) - res_id = model_pool.create(cr, uid, data, context=context) - self.message_append_dict(cr, uid, [res_id], msg_dict, context=context) + res_id = model_pool.create(cr, uid, data, context = context) + self.message_append_dict(cr, uid, [res_id], msg_dict, context = context) return res_id - def message_update(self, cr, uid, ids, msg_dict, update_vals=None, context=None): + def message_update(self, cr, uid, ids, msg_dict, update_vals = None, context = None): """ Called by ``message_process`` when a new message is received for an existing thread. The default behavior is to create a new mail.message in the given thread (by calling @@ -711,10 +714,10 @@ class mail_thread(osv.Model): update (instead of the current model). """ if update_vals: - self.write(cr, uid, ids, update_vals, context=context) - return self.message_append_dict(cr, uid, ids, msg_dict, context=context) + self.write(cr, uid, ids, update_vals, context = context) + return self.message_append_dict(cr, uid, ids, msg_dict, context = context) - def message_thread_followers(self, cr, uid, ids, context=None): + def message_thread_followers(self, cr, uid, ids, context = None): """ Returns a list of email addresses of the people following this thread, including the sender of each mail, and the people who were in CC of the messages, if any. @@ -722,7 +725,7 @@ class mail_thread(osv.Model): res = {} if isinstance(ids, (str, int, long)): ids = [long(ids)] - for thread in self.browse(cr, uid, ids, context=context): + for thread in self.browse(cr, uid, ids, context = context): l = set() for message in thread.message_ids: l.add((message.user_id and message.user_id.user_email) or '') @@ -731,7 +734,7 @@ class mail_thread(osv.Model): res[thread.id] = filter(None, l) return res - def message_forward(self, cr, uid, model, thread_ids, msg, email_error=False, context=None): + def message_forward(self, cr, uid, model, thread_ids, msg, email_error = False, context = None): """Sends an email to all people following the given threads. The emails are forwarded immediately, not queued for sending, and not archived. @@ -746,7 +749,7 @@ class mail_thread(osv.Model): model_pool = self.pool.get(model) smtp_server_obj = self.pool.get('ir.mail_server') mail_message = self.pool.get('mail.message') - for res in model_pool.browse(cr, uid, thread_ids, context=context): + for res in model_pool.browse(cr, uid, thread_ids, context = context): if hasattr(model_pool, 'message_thread_followers'): followers = model_pool.message_thread_followers(cr, uid, [res.id])[res.id] else: @@ -765,7 +768,7 @@ class mail_thread(osv.Model): smtp_from, = to_email(msg['from']) msg['from'] = smtp_from - msg['to'] = ", ".join(forward_to) + msg['to'] = ", ".join(forward_to) msg['message-id'] = tools.generate_tracking_message_id(res.id) if not smtp_server_obj.send_email(cr, uid, msg) and email_error: subj = msg['subject'] @@ -775,7 +778,7 @@ class mail_thread(osv.Model): smtp_server_obj.send_email(cr, uid, msg) return True - def message_partner_by_email(self, cr, uid, email, context=None): + def message_partner_by_email(self, cr, uid, email, context = None): """Attempts to return the id of a partner address matching the given ``email``, and the corresponding partner id. Can be used by classes using the ``mail.thread`` mixin @@ -811,16 +814,16 @@ class mail_thread(osv.Model): # Note specific #------------------------------------------------------ - def log(self, cr, uid, id, message, secondary=False, context=None): + def log(self, cr, uid, id, message, secondary = False, context = None): _logger.warning("log() is deprecated. As this module inherit from \ mail.thread, the message will be managed by this \ module instead of by the res.log mechanism. Please \ use the mail.thread OpenChatter API instead of the \ now deprecated res.log.") - self.message_append_note(cr, uid, [id], 'res.log', message, context=context) + self.message_append_note(cr, uid, [id], 'res.log', message, context = context) - def message_append_note(self, cr, uid, ids, subject=None, body=None, parent_id=False, - type='notification', content_subtype='html', context=None): + def message_append_note(self, cr, uid, ids, subject = None, body = None, parent_id = False, + type = 'notification', subtype_id = False, content_subtype = 'html', context = None): if content_subtype == 'html': body_html = body body_text = body @@ -828,14 +831,14 @@ class mail_thread(osv.Model): body_html = body body_text = body return self.message_append(cr, uid, ids, subject, body_html, body_text, - type, parent_id=parent_id, - content_subtype=content_subtype, context=context) + type, subtype_id = subtype_id, parent_id = parent_id, + content_subtype = content_subtype, context = context) #------------------------------------------------------ # Subscription mechanism #------------------------------------------------------ - def message_get_subscribers(self, cr, uid, ids, context=None): + def message_get_subscribers(self, cr, uid, ids, context = None): """ Returns the current document followers. Basically this method checks in mail.subscription for entries with matching res_model, res_id. @@ -844,18 +847,18 @@ class mail_thread(osv.Model): ids returned by this method. """ subscr_obj = self.pool.get('mail.subscription') - subscr_ids = subscr_obj.search(cr, uid, ['&', ('res_model', '=', self._name), ('res_id', 'in', ids)], context=context) - return [sub['user_id'][0] for sub in subscr_obj.read(cr, uid, subscr_ids, ['user_id'], context=context)] + subscr_ids = subscr_obj.search(cr, uid, ['&', ('res_model', '=', self._name), ('res_id', 'in', ids)], context = context) + return [sub['user_id'][0] for sub in subscr_obj.read(cr, uid, subscr_ids, ['user_id'], context = context)] - def message_read_subscribers(self, cr, uid, ids, fields=['id', 'name', 'avatar'], context=None): + def message_read_subscribers(self, cr, uid, ids, fields = ['id', 'name', 'avatar'], context = None): """ Returns the current document followers as a read result. Used mainly for Chatter having only one method to call to have details about users. """ - user_ids = self.message_get_subscribers(cr, uid, ids, context=context) - return self.pool.get('res.users').read(cr, uid, user_ids, fields=fields, context=context) + user_ids = self.message_get_subscribers(cr, uid, ids, context = context) + return self.pool.get('res.users').read(cr, uid, user_ids, fields = fields, context = context) - def message_is_subscriber(self, cr, uid, ids, user_id = None, context=None): + def message_is_subscriber(self, cr, uid, ids, user_id = None, context = None): """ Check if uid or user_id (if set) is a subscriber to the current document. @@ -863,16 +866,17 @@ class mail_thread(osv.Model): check is done on uid """ sub_user_id = uid if user_id is None else user_id - if sub_user_id in self.message_get_subscribers(cr, uid, ids, context=context): + if sub_user_id in self.message_get_subscribers(cr, uid, ids, context = context): return True return False - def message_subscribe(self, cr, uid, ids, user_ids = None, context=None): + def message_subscribe(self, cr, uid, ids, user_ids = None, subtype_ids = None, context = None): """ Subscribe the user (or user_ids) to the current document. :param user_ids: a list of user_ids; if not set, subscribe uid instead """ + # TODO:Update Massage Subscribe and add paramenter subtype_ids # if subtype_ids is False: add default ones (res_model = self._name, default = True) # in method: if user_id already subscriber, update its subscription with subtype_ids @@ -881,14 +885,20 @@ class mail_thread(osv.Model): to_subscribe_uids = [uid] if user_ids is None else user_ids create_ids = [] for id in ids: - already_subscribed_user_ids = self.message_get_subscribers(cr, uid, [id], context=context) + already_subscribed_user_ids = self.message_get_subscribers(cr, uid, [id], context = context) for user_id in to_subscribe_uids: - if user_id in already_subscribed_user_ids: continue - create_ids.append(subscription_obj.create(cr, uid, {'res_model': self._name, 'res_id': id, 'user_id': user_id}, context=context)) + res = {'res_model': self._name, 'res_id': id, 'user_id': user_id} + res['subtype_ids'] = [0, 0, {'res_model': self._name, 'default': True}] + if user_id in already_subscribed_user_ids: + if subtype_ids: + res['subtype_ids'] = [(6, 0, subtype_ids)] + else: continue + create_ids.append(subscription_obj.create(cr, uid, res, context = context)) return create_ids + #TODO : Add method : add message_subscribe_udpate_subtypes(..., user_id, subtype_ids): - def message_unsubscribe(self, cr, uid, ids, user_ids = None, context=None): + def message_unsubscribe(self, cr, uid, ids, user_ids = None, context = None): """ Unsubscribe the user (or user_ids) from the current document. :param user_ids: a list of user_ids; if not set, subscribe @@ -900,17 +910,19 @@ class mail_thread(osv.Model): to_unsubscribe_uids = [uid] if user_ids is None else user_ids subscription_obj = self.pool.get('mail.subscription') to_delete_sub_ids = subscription_obj.search(cr, uid, - ['&', '&', ('res_model', '=', self._name), ('res_id', 'in', ids), ('user_id', 'in', to_unsubscribe_uids)], context=context) + ['&', '&', ('res_model', '=', self._name), ('res_id', 'in', ids), ('user_id', 'in', to_unsubscribe_uids)], context = context) if not to_delete_sub_ids: return False - return subscription_obj.unlink(cr, uid, to_delete_sub_ids, context=context) + + return subscription_obj.unlink(cr, uid, to_delete_sub_ids, context = context) #TODO : Add Method : add message_subscribeption_remove_subtype(..., user_id, subtype_id): #TODO : Add method : add message_subscription_remove_subtype_name(.., user_id, subtype_name) + #------------------------------------------------------ # Notification API #------------------------------------------------------ - def message_create_notify_by_email(self, cr, uid, new_msg_values, user_to_notify_ids, context=None): + def message_create_notify_by_email(self, cr, uid, new_msg_values, user_to_notify_ids, context = None): """ When creating a new message and pushing notifications, emails must be send if users have chosen to receive notifications by email via the notification_email_pref field. @@ -937,11 +949,11 @@ class mail_thread(osv.Model): user_to_notify_ids.remove(new_msg_values.get('user_id')) # get user_ids directly asked - user_to_push_from_parse_ids = self.message_parse_users(cr, uid, body, context=context) + user_to_push_from_parse_ids = self.message_parse_users(cr, uid, body, context = context) # try to find an email_to email_to = '' - for user in res_users_obj.browse(cr, uid, user_to_notify_ids, context=context): + for user in res_users_obj.browse(cr, uid, user_to_notify_ids, context = context): if not user.notification_email_pref == 'all' and \ not (user.notification_email_pref == 'to_me' and user.id in user_to_push_from_parse_ids): continue @@ -955,17 +967,17 @@ class mail_thread(osv.Model): return # try to find an email_from - current_user = res_users_obj.browse(cr, uid, [uid], context=context)[0] + current_user = res_users_obj.browse(cr, uid, [uid], context = context)[0] email_from = new_msg_values.get('email_from') if not email_from: email_from = current_user.user_email # get email content, create it (with mail_message.create) email_values = self.message_create_notify_get_email_dict(cr, uid, new_msg_values, email_from, email_to, context) - email_id = message_obj.create(cr, uid, email_values, context=context) + email_id = message_obj.create(cr, uid, email_values, context = context) return email_id - def message_create_notify_get_email_dict(self, cr, uid, new_msg_values, email_from, email_to, context=None): + def message_create_notify_get_email_dict(self, cr, uid, new_msg_values, email_from, email_to, context = None): values = dict(new_msg_values) body_html = new_msg_values.get('body_html', '') @@ -989,47 +1001,62 @@ class mail_thread(osv.Model): }) return values - def message_remove_pushed_notifications(self, cr, uid, ids, msg_ids, remove_childs=True, context=None): + def message_remove_pushed_notifications(self, cr, uid, ids, msg_ids, remove_childs = True, context = None): notif_obj = self.pool.get('mail.notification') msg_obj = self.pool.get('mail.message') if remove_childs: - notif_msg_ids = msg_obj.search(cr, uid, [('id', 'child_of', msg_ids)], context=context) + notif_msg_ids = msg_obj.search(cr, uid, [('id', 'child_of', msg_ids)], context = context) else: notif_msg_ids = msg_ids - 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) + 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_create_set_unread(self, cr, uid, ids, context=None): + def message_create_set_unread(self, cr, uid, ids, context = None): """ When creating a new message, set as unread if uid is not the object responsible. """ - for obj in self.browse(cr, uid, ids, context=context): + for obj in self.browse(cr, uid, ids, context = context): if obj.message_state and hasattr(obj, 'user_id') and (not obj.user_id or obj.user_id.id != uid): - self.message_mark_as_unread(cr, uid, [obj.id], context=context) + self.message_mark_as_unread(cr, uid, [obj.id], context = context) - def message_check_and_set_unread(self, cr, uid, ids, context=None): + def message_check_and_set_unread(self, cr, uid, ids, context = None): """ Set unread if uid is the object responsible or if the object has no responsible. """ - for obj in self.browse(cr, uid, ids, context=context): + for obj in self.browse(cr, uid, ids, context = context): if obj.message_state and hasattr(obj, 'user_id') and (not obj.user_id or obj.user_id.id == uid): - self.message_mark_as_unread(cr, uid, [obj.id], context=context) + self.message_mark_as_unread(cr, uid, [obj.id], context = context) - def message_mark_as_unread(self, cr, uid, ids, context=None): + def message_mark_as_unread(self, cr, uid, ids, context = None): """ Set as unread. """ - return self.write(cr, uid, ids, {'message_state': False}, context=context) + return self.write(cr, uid, ids, {'message_state': False}, context = context) - def message_check_and_set_read(self, cr, uid, ids, context=None): + def message_check_and_set_read(self, cr, uid, ids, context = None): """ Set read if uid is the object responsible. """ - for obj in self.browse(cr, uid, ids, context=context): + for obj in self.browse(cr, uid, ids, context = context): if not obj.message_state and hasattr(obj, 'user_id') and obj.user_id and obj.user_id.id == uid: - self.message_mark_as_read(cr, uid, [obj.id], context=context) + self.message_mark_as_read(cr, uid, [obj.id], context = context) - def message_mark_as_read(self, cr, uid, ids, context=None): + def message_mark_as_read(self, cr, uid, ids, context = None): """ Set as read. """ - return self.write(cr, uid, ids, {'message_state': True}, context=context) - + return self.write(cr, uid, ids, {'message_state': True}, context = context) + def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids): + subscription_obj = self.pool.get('mail.subscription') + subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) + return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [6, 0 , subtype_ids]}, context = context) #overright or add new one + + def message_subscription_remove_subtype(self, cr, uid, ids, user_id, subtype_id): + subscription_obj = self.pool.get('mail.subscription') + subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) + return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [3, subtype_id]}, context = context) # remove linl or record ? + + def message_subscription_remove_subtype_name(self, cr, uid, ids, user_id, subtype_name): + subtype_obj = self.pool.get('mail.message.subtype') + subtype_ids = subtype_obj.search(cr, uid, [('name', '=', subtype_name), ('model_ids', '=', self._name)]) + if not subtype_ids: + return False + self.message_subscription_remove_subtype(cr, uid, ids, user_id, subtype_ids) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From b942c562240d999c2f20ea154547ac46dde179a8 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 9 Aug 2012 14:52:56 +0530 Subject: [PATCH 007/175] [ADD] Add demo data in crm lead bzr revid: fka@tinyerp.com-20120809092256-r27t6y9nvndwnole --- addons/crm/crm_lead.py | 17 ++++++++++------- addons/crm/crm_lead_demo.xml | 32 ++++++++++++++++++++++++++++++++ addons/mail/mail_thread.py | 2 +- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index d5ec1309baa..675f41c94f4 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -275,6 +275,9 @@ class crm_lead(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(crm_lead, self).create(cr, uid, vals, context) + obj = self.browse(cr, uid, obj_id, context) + if obj.user_id: + self.message_subscribe(cr, uid, ids, obj.user_id.id, context = context) self.create_send_note(cr, uid, [obj_id], context=context) return obj_id @@ -849,13 +852,13 @@ class crm_lead(base_stage, osv.osv): # OpenChatter methods and notifications # ---------------------------------------- - def message_get_subscribers(self, cr, uid, ids, context=None): - """ Override to add the salesman. """ - user_ids = super(crm_lead, self).message_get_subscribers(cr, uid, ids, context=context) - for obj in self.browse(cr, uid, ids, context=context): - if obj.user_id and not obj.user_id.id in user_ids: - user_ids.append(obj.user_id.id) - return user_ids + #def message_get_subscribers(self, cr, uid, ids, context=None): + #""" Override to add the salesman. """ + #user_ids = super(crm_lead, self).message_get_subscribers(cr, uid, ids, context=context) + #for obj in self.browse(cr, uid, ids, context=context): + #if obj.user_id and not obj.user_id.id in user_ids: + #user_ids.append(obj.user_id.id) + #return user_ids def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ diff --git a/addons/crm/crm_lead_demo.xml b/addons/crm/crm_lead_demo.xml index 7ed3bc2a86b..b064a9adfb1 100644 --- a/addons/crm/crm_lead_demo.xml +++ b/addons/crm/crm_lead_demo.xml @@ -540,5 +540,37 @@ ref('crm_case_ericdubois4'), ref('crm_case_abcfuelcounits0')], {}" /> + + new + + + + + won + + + + lost + + + + stage change + + + + + other + + + + + email + + + + comment + + + diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 3e5bfabe350..21d123ec024 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1051,7 +1051,7 @@ class mail_thread(osv.Model): def message_subscription_remove_subtype(self, cr, uid, ids, user_id, subtype_id): subscription_obj = self.pool.get('mail.subscription') subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) - return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [3, subtype_id]}, context = context) # remove linl or record ? + return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [3, subtype_id]}, context = context) # remove link def message_subscription_remove_subtype_name(self, cr, uid, ids, user_id, subtype_name): subtype_obj = self.pool.get('mail.message.subtype') From dae19bc174b3962088bf4b9fd0701f80ab8f8e5e Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 9 Aug 2012 16:48:06 +0530 Subject: [PATCH 008/175] [IMP] improve crm_lead bzr revid: fka@tinyerp.com-20120809111806-k79sserip4oyzo1r --- addons/crm/crm_lead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 675f41c94f4..a3fccffb011 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -277,7 +277,7 @@ class crm_lead(base_stage, osv.osv): obj_id = super(crm_lead, self).create(cr, uid, vals, context) obj = self.browse(cr, uid, obj_id, context) if obj.user_id: - self.message_subscribe(cr, uid, ids, obj.user_id.id, context = context) + self.message_subscribe(cr, uid, [obj_id], [obj.user_id.id], context = context) self.create_send_note(cr, uid, [obj_id], context=context) return obj_id From 2b331ed5e35640a23e8417bbf24d20b9746e3c13 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Mon, 13 Aug 2012 16:37:46 +0530 Subject: [PATCH 009/175] [IMP]all followers of the task project are automatically followers of the task bzr revid: sgo@tinyerp.com-20120813110746-wqivckynrcqnf7y6 --- addons/project/project.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/project/project.py b/addons/project/project.py index 6f3b23f4746..879e9500874 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1209,6 +1209,9 @@ class task(base_stage, osv.osv): user_ids.append(obj.user_id.id) if obj.manager_id and not obj.manager_id.id in user_ids: user_ids.append(obj.manager_id.id) + if obj.project_id.followers: + for follower in obj.project_id.followers: + user_ids.append(follower.id) return user_ids def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): From 0e916d159242e46d3f4b2c914c0d8dc49e88ee03 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 13 Aug 2012 18:40:40 +0530 Subject: [PATCH 010/175] [IMP] improve mail_thread bzr revid: fka@tinyerp.com-20120813131040-32v2tcz3eltkx4fn --- addons/crm/crm_lead.py | 28 +++++++++++++++++++++------- addons/mail/mail_thread.py | 3 ++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index da845cc8e5f..b02369cce9f 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -865,7 +865,9 @@ class crm_lead(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), context=context) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_stage_change') + res_id = res[1] + return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_id=res_id,context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): @@ -875,33 +877,45 @@ class crm_lead(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): for id in ids: message = _("%s has been created.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_append_note(cr, uid, [id], body=message, context=context) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_new') + res_id = res[1] + self.message_append_note(cr, uid, [id], body=message, subtype_id=res_id, context=context) return True def case_mark_lost_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been lost.") - return self.message_append_note(cr, uid, ids, body=message, context=context) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_lost') + res_id = res[1] + return self.message_append_note(cr, uid, ids, body=message,subtype_id=res_id, context=context) def case_mark_won_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been won.") - return self.message_append_note(cr, uid, ids, body=message, context=context) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_won') + res_id = res[1] + return self.message_append_note(cr, uid, ids, body=message, subtype_id=res_id, context=context) def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None): phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0] if action == 'log': prefix = 'Logged' else: prefix = 'Scheduled' message = _("%s a call for the %s.") % (prefix, phonecall.date) - return self.message_append_note(cr, uid, ids, body=message, context=context) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other') + res_id = res[1] + return self.message_append_note(cr, uid, ids, body=message, subtype_id=res_id, context=context) def _lead_set_partner_send_note(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): message = _("%s partner is now set to %s." % (self.case_get_note_msg_prefix(cr, uid, lead, context=context), lead.partner_id.name)) - lead.message_append_note(body=message) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other') + res_id = res[1] + lead.message_append_note(body=message, subtype_id=res_id) return True def convert_opportunity_send_note(self, cr, uid, lead, context=None): message = _("Lead has been converted to an opportunity.") - lead.message_append_note(body=message) + res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other') + res_id = res[1] + lead.message_append_note(body=message, subtype_id=res_id) return True crm_lead() diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 79b734379d0..14e9138be55 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -335,6 +335,7 @@ class mail_thread(osv.Model): 'parent_id': parent_id, 'date': email_date or fields.datetime.now(), 'type': type, + 'subtype_id' : subtype_id, 'content_subtype': content_subtype, 'state': state, 'message_id': message_id, @@ -866,7 +867,7 @@ class mail_thread(osv.Model): now deprecated res.log.") self.message_append_note(cr, uid, [id], 'res.log', message, context=context) - def message_append_note(self, cr, uid, ids, subject=None, subtype_id=None, body=None, parent_id=False, + def message_append_note(self, cr, uid, ids, subject=None, subtype_id=False, body=None, parent_id=False, type='notification', content_subtype='html', context=None): if content_subtype == 'html': body_html = body From 9fac5651d55d44e4b6eb8d16fe0b802bc1df349d Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Tue, 14 Aug 2012 12:21:49 +0530 Subject: [PATCH 011/175] [IMP] improve as per suggetion bzr revid: fka@tinyerp.com-20120814065149-h1xf3we6t37bsyk3 --- addons/crm/crm_data.xml | 2 +- addons/crm/crm_lead.py | 28 +++++++--------------------- addons/mail/data/mail_group_data.xml | 2 +- addons/mail/mail_thread.py | 13 ++++++------- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/addons/crm/crm_data.xml b/addons/crm/crm_data.xml index 5e5f408673a..dfe2e4653c3 100644 --- a/addons/crm/crm_data.xml +++ b/addons/crm/crm_data.xml @@ -63,7 +63,7 @@ - + Module CRM has been installed From the top menu Sales, you can: trace leads and opportunities, get accurate forecast on your sales pipeline, plan meetings and phonecalls, get realtime statistics and efficiently organize the communication with your prospects. diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index b02369cce9f..976eb333ddd 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -865,9 +865,7 @@ class crm_lead(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_stage_change') - res_id = res[1] - return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_id=res_id,context=context) + return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_id="stage change",context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): @@ -877,45 +875,33 @@ class crm_lead(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): for id in ids: message = _("%s has been created.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_new') - res_id = res[1] - self.message_append_note(cr, uid, [id], body=message, subtype_id=res_id, context=context) + self.message_append_note(cr, uid, [id], body=message, subtype_id="new", context=context) return True def case_mark_lost_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been lost.") - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_lost') - res_id = res[1] - return self.message_append_note(cr, uid, ids, body=message,subtype_id=res_id, context=context) + return self.message_append_note(cr, uid, ids, body=message,subtype_id="lost", context=context) def case_mark_won_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been won.") - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_won') - res_id = res[1] - return self.message_append_note(cr, uid, ids, body=message, subtype_id=res_id, context=context) + return self.message_append_note(cr, uid, ids, body=message, subtype_id="won", context=context) def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None): phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0] if action == 'log': prefix = 'Logged' else: prefix = 'Scheduled' message = _("%s a call for the %s.") % (prefix, phonecall.date) - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other') - res_id = res[1] - return self.message_append_note(cr, uid, ids, body=message, subtype_id=res_id, context=context) + return self.message_append_note(cr, uid, ids, body=message, context=context) def _lead_set_partner_send_note(self, cr, uid, ids, context=None): for lead in self.browse(cr, uid, ids, context=context): message = _("%s partner is now set to %s." % (self.case_get_note_msg_prefix(cr, uid, lead, context=context), lead.partner_id.name)) - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other') - res_id = res[1] - lead.message_append_note(body=message, subtype_id=res_id) + lead.message_append_note(body=message) return True def convert_opportunity_send_note(self, cr, uid, lead, context=None): message = _("Lead has been converted to an opportunity.") - res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm', 'mail_subtype_lead_other') - res_id = res[1] - lead.message_append_note(body=message, subtype_id=res_id) + lead.message_append_note(body=message) return True crm_lead() diff --git a/addons/mail/data/mail_group_data.xml b/addons/mail/data/mail_group_data.xml index 09a6ca29a2d..3a2ad01fab8 100644 --- a/addons/mail/data/mail_group_data.xml +++ b/addons/mail/data/mail_group_data.xml @@ -16,7 +16,7 @@ - + Welcome to OpenERP! Your homepage is a summary of messages you received and key information about documents you follow. diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 14e9138be55..8d1259ea4ff 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -228,8 +228,8 @@ class mail_thread(osv.Model): ret_dict[model_name] = model._description return ret_dict - def message_append(self, cr, uid, threads, subject, body_text=None, body_html=None, - type = 'email', subtype_id = False, email_date = None, parent_id = False, + def message_append(self, cr, uid, threads, subject,subtype_id = "other", body_text=None, body_html=None, + type = 'email', email_date = None, parent_id = False, content_subtype='plain', state=None, partner_ids=None, email_from=False, email_to=False, email_cc=None, email_bcc=None, reply_to=None, @@ -335,7 +335,6 @@ class mail_thread(osv.Model): 'parent_id': parent_id, 'date': email_date or fields.datetime.now(), 'type': type, - 'subtype_id' : subtype_id, 'content_subtype': content_subtype, 'state': state, 'message_id': message_id, @@ -383,11 +382,11 @@ class mail_thread(osv.Model): """ return self.message_append(cr, uid, ids, subject = msg_dict.get('subject'), + subtype_id = msg_dict.get('subtype_id','other'), body_text = msg_dict.get('body_text'), body_html= msg_dict.get('body_html'), parent_id = msg_dict.get('parent_id', False), type = msg_dict.get('type', 'email'), - subtype_id = msg_dict.get('subtype_id', False), content_subtype = msg_dict.get('content_subtype'), state = msg_dict.get('state'), partner_ids = msg_dict.get('partner_ids'), @@ -867,7 +866,7 @@ class mail_thread(osv.Model): now deprecated res.log.") self.message_append_note(cr, uid, [id], 'res.log', message, context=context) - def message_append_note(self, cr, uid, ids, subject=None, subtype_id=False, body=None, parent_id=False, + def message_append_note(self, cr, uid, ids, subject=None, subtype_id='other', body=None, parent_id=False, type='notification', content_subtype='html', context=None): if content_subtype == 'html': body_html = body @@ -875,8 +874,8 @@ class mail_thread(osv.Model): else: body_html = body body_text = body - return self.message_append(cr, uid, ids, subject, body_html, body_text, - type, subtype_id = subtype_id, parent_id = parent_id, + return self.message_append(cr, uid, ids, subject,subtype_id, body_html, body_text, + type, parent_id = parent_id, content_subtype=content_subtype, context=context) #------------------------------------------------------ From 86768264f4e0027d62ac300410a8ef691e95d862 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Tue, 14 Aug 2012 12:49:19 +0530 Subject: [PATCH 012/175] [IMP] Add constraints in message subtype model bzr revid: fka@tinyerp.com-20120814071919-pk9wkepp7v1geswa --- addons/mail/mail_message_subtype.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/mail/mail_message_subtype.py b/addons/mail/mail_message_subtype.py index 0a167a0f1d9..0c4f5e7baa6 100644 --- a/addons/mail/mail_message_subtype.py +++ b/addons/mail/mail_message_subtype.py @@ -39,3 +39,6 @@ class mail_message_subtype(osv.osv): _defaults = { 'default': True, } + _sql_constraints = [ + ('name_uniq', 'unique (name)', 'The name of the message subtype must be unique !') + ] From b4b9ce7178494a5b414995d6236b255cc396caa2 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Tue, 14 Aug 2012 15:42:12 +0530 Subject: [PATCH 013/175] [IMP]improve code bzr revid: sgo@tinyerp.com-20120814101212-rjmlbtpmhdviick7 --- addons/project/project.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 879e9500874..f7309716429 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1209,9 +1209,10 @@ class task(base_stage, osv.osv): user_ids.append(obj.user_id.id) if obj.manager_id and not obj.manager_id.id in user_ids: user_ids.append(obj.manager_id.id) - if obj.project_id.followers: - for follower in obj.project_id.followers: - user_ids.append(follower.id) + if obj.project_id: + subscriber_ids = self.pool.get('project.project').message_get_subscribers(cr, uid, [obj.project_id.id], context=context) + for user_id in subscriber_ids: + user_ids.append(user_id) return user_ids def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): From 0ae13ed393ed42b1d6d3ef600556d526e7840a9d Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Tue, 14 Aug 2012 17:42:50 +0530 Subject: [PATCH 014/175] [IMP] improve message_create() in mail_thread bzr revid: fka@tinyerp.com-20120814121250-32fb4key3nt9lcaq --- addons/crm/crm_lead.py | 8 +++--- addons/mail/mail_thread.py | 55 ++++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 976eb333ddd..0ec901698df 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -865,7 +865,7 @@ class crm_lead(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_id="stage change",context=context) + return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change",context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): @@ -875,16 +875,16 @@ class crm_lead(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): for id in ids: message = _("%s has been created.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_append_note(cr, uid, [id], body=message, subtype_id="new", context=context) + self.message_append_note(cr, uid, [id], body=message, subtype="new", context=context) return True def case_mark_lost_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been lost.") - return self.message_append_note(cr, uid, ids, body=message,subtype_id="lost", context=context) + return self.message_append_note(cr, uid, ids, body=message,subtype="lost", context=context) def case_mark_won_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been won.") - return self.message_append_note(cr, uid, ids, body=message, subtype_id="won", context=context) + return self.message_append_note(cr, uid, ids, body=message, subtype="won", context=context) def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None): phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0] diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 8d1259ea4ff..4ffdac80116 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -153,29 +153,37 @@ class mail_thread(osv.Model): notification_obj = self.pool.get('mail.notification') body = vals.get('body_html', '') if vals.get('content_subtype') == 'html' else vals.get('body_text', '') + subtype_obj=self.pool.get('mail.message.subtype') + subtype_id=subtype_obj.search(cr, uid, [('name', '=', vals.get('subtype')), ('model_ids', '=', self._name)]) + vals['subtype_id'] = subtype_id[0] + user_subscribe=self.message_is_subscriber(cr, uid, [thread_id], vals['user_id'], context) # automatically subscribe the writer of the message if vals['user_id']: self.message_subscribe(cr, uid, [thread_id], [vals['user_id']], context=context) - # create message - msg_id = message_obj.create(cr, uid, vals, context=context) - - # Set as unread if writer is not the document responsible - self.message_create_set_unread(cr, uid, [thread_id], context=context) - - # special: if install mode, do not push demo data - if context.get('install_mode', False): - return msg_id - - # get users that will get a notification pushed - user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context=context) - for id in user_to_push_ids: - notification_obj.create(cr, uid, {'user_id': id, 'message_id': msg_id}, context=context) - - # create the email to send - email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context=context) - - return msg_id + for subtype_obj in subtype_obj.browse(cr,uid,subtype_id,context): + if subtype_obj.default and user_subscribe: + # create message + msg_id = message_obj.create(cr, uid, vals, context=context) + + # Set as unread if writer is not the document responsible + self.message_create_set_unread(cr, uid, [thread_id], context=context) + + # special: if install mode, do not push demo data + if context.get('install_mode', False): + return msg_id + + # get users that will get a notification pushed + user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context=context) + for id in user_to_push_ids: + notification_obj.create(cr, uid, {'user_id': id, 'message_id': msg_id}, context=context) + + # create the email to send + email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context=context) + + return msg_id + else: + return False def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, context=None): subscription_obj = self.pool.get('mail.subscription') @@ -228,7 +236,7 @@ class mail_thread(osv.Model): ret_dict[model_name] = model._description return ret_dict - def message_append(self, cr, uid, threads, subject,subtype_id = "other", body_text=None, body_html=None, + def message_append(self, cr, uid, threads, subject,subtype = "other", body_text=None, body_html=None, type = 'email', email_date = None, parent_id = False, content_subtype='plain', state=None, partner_ids=None, email_from=False, email_to=False, @@ -330,6 +338,7 @@ class mail_thread(osv.Model): data = { 'subject': subject, + 'subtype': subtype, 'body_text': body_text or (hasattr(thread, 'description') and thread.description or ''), 'body_html': body_html or '', 'parent_id': parent_id, @@ -382,7 +391,7 @@ class mail_thread(osv.Model): """ return self.message_append(cr, uid, ids, subject = msg_dict.get('subject'), - subtype_id = msg_dict.get('subtype_id','other'), + subtype = msg_dict.get('subtype','other'), body_text = msg_dict.get('body_text'), body_html= msg_dict.get('body_html'), parent_id = msg_dict.get('parent_id', False), @@ -866,7 +875,7 @@ class mail_thread(osv.Model): now deprecated res.log.") self.message_append_note(cr, uid, [id], 'res.log', message, context=context) - def message_append_note(self, cr, uid, ids, subject=None, subtype_id='other', body=None, parent_id=False, + def message_append_note(self, cr, uid, ids, subject=None, subtype='other', body=None, parent_id=False, type='notification', content_subtype='html', context=None): if content_subtype == 'html': body_html = body @@ -874,7 +883,7 @@ class mail_thread(osv.Model): else: body_html = body body_text = body - return self.message_append(cr, uid, ids, subject,subtype_id, body_html, body_text, + return self.message_append(cr, uid, ids, subject,subtype, body_html, body_text, type, parent_id = parent_id, content_subtype=content_subtype, context=context) From 40768f8fd838635737dc7a376a7282a49620d43e Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Tue, 14 Aug 2012 19:13:14 +0530 Subject: [PATCH 015/175] [IMP] improve mail_thread bzr revid: fka@tinyerp.com-20120814134314-lyen3a13a76db9sv --- addons/mail/mail_thread.py | 74 +++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 04cb5bc6bc6..5b2efb98fcc 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -140,7 +140,7 @@ class mail_thread(osv.Model): # mail.message wrappers and tools #------------------------------------------------------ - def message_create(self, cr, uid, thread_id, vals, context=None): + def message_create(self, cr, uid, thread_id, vals, context = None): """ OpenChatter: wrapper of mail.message create method - creates the mail.message - automatically subscribe the message writer @@ -151,40 +151,40 @@ class mail_thread(osv.Model): message_obj = self.pool.get('mail.message') notification_obj = self.pool.get('mail.notification') + subscription_obj = self.pool.get('mail.subscription') body = vals.get('body_html', '') if vals.get('content_subtype') == 'html' else vals.get('body_text', '') - subtype_obj=self.pool.get('mail.message.subtype') - subtype_id=subtype_obj.search(cr, uid, [('name', '=', vals.get('subtype')), ('model_ids', '=', self._name)]) - if subtype_id: - vals['subtype_id'] = subtype_id[0] - user_subscribe=self.message_is_subscriber(cr, uid, [thread_id], vals['user_id'], context) # automatically subscribe the writer of the message if vals['user_id']: - self.message_subscribe(cr, uid, [thread_id], [vals['user_id']], context=context) + self.message_subscribe(cr, uid, [thread_id], [vals['user_id']], context = context) - for subtype_obj in subtype_obj.browse(cr,uid,subtype_id,context): - if subtype_obj.default and user_subscribe: - # create message - msg_id = message_obj.create(cr, uid, vals, context=context) - - # Set as unread if writer is not the document responsible - self.message_create_set_unread(cr, uid, [thread_id], context=context) - - # special: if install mode, do not push demo data - if context.get('install_mode', False): - return msg_id - - # get users that will get a notification pushed - user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context=context) - for id in user_to_push_ids: - notification_obj.create(cr, uid, {'user_id': id, 'message_id': msg_id}, context=context) - - # create the email to send - email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context=context) - - return msg_id - else: - return False + # create message + msg_id = message_obj.create(cr, uid, vals, context = context) + + # Set as unread if writer is not the document responsible + self.message_create_set_unread(cr, uid, [thread_id], context = context) + + # special: if install mode, do not push demo data + if context.get('install_mode', False): + return msg_id + + # get users that will get a notification pushed + user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context = context) + subtype_id = vals.get('subtype', False) + subtype_ids = self.pool.get('mail.message.subtype').name_search(cr, uid, subtype_id) + subtype_id = len(subtype_ids) and subtype_ids[0][0] or False + for user_id in user_to_push_ids: + if subtype_id: + #TOCHECK: domain to find subscrition details of subtype + subscription_ids = subscription_obj.search(cr, uid, [('res_model','=',vals['model']),('res_id','=',vals['res_id']),('subtype_ids','in',subtype_id),('user_id','=',user_id)]) + if not subscription_ids: + continue + notification_obj.create(cr, uid, {'user_id': user_id, 'message_id': msg_id}, context = context) + + # create the email to send + email_id = self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context = context) + + return msg_id def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, context=None): subscription_obj = self.pool.get('mail.subscription') @@ -237,13 +237,13 @@ class mail_thread(osv.Model): ret_dict[model_name] = model._description return ret_dict - def message_append(self, cr, uid, threads, subject,subtype = "other", body_text=None, body_html=None, + def message_append(self, cr, uid, threads, subject, body_text=None, body_html=None, type = 'email', email_date = None, parent_id = False, content_subtype='plain', state=None, partner_ids=None, email_from=False, email_to=False, email_cc=None, email_bcc=None, reply_to=None, headers=None, message_id=False, references=None, - attachments=None, original=None, context=None): + attachments=None, original=None, subtype = "other", context=None): """ Creates a new mail.message through message_create. The new message is attached to the current mail.thread, containing all the details passed as parameters. All attachments will be attached to the @@ -392,7 +392,6 @@ class mail_thread(osv.Model): """ return self.message_append(cr, uid, ids, subject = msg_dict.get('subject'), - subtype = msg_dict.get('subtype','other'), body_text = msg_dict.get('body_text'), body_html= msg_dict.get('body_html'), parent_id = msg_dict.get('parent_id', False), @@ -412,6 +411,7 @@ class mail_thread(osv.Model): attachments = msg_dict.get('attachments'), headers = msg_dict.get('headers'), original = msg_dict.get('original'), + subtype = msg_dict.get('subtype','other'), context = context) #------------------------------------------------------ @@ -876,17 +876,17 @@ class mail_thread(osv.Model): now deprecated res.log.") self.message_append_note(cr, uid, [id], 'res.log', message, context=context) - def message_append_note(self, cr, uid, ids, subject=None, subtype='other', body=None, parent_id=False, - type='notification', content_subtype='html', context=None): + def message_append_note(self, cr, uid, ids, subject=None, body=None, parent_id=False, + type='notification', content_subtype='html', subtype='other', context=None): if content_subtype == 'html': body_html = body body_text = body else: body_html = body body_text = body - return self.message_append(cr, uid, ids, subject,subtype, body_html, body_text, + return self.message_append(cr, uid, ids, subject, body_text, body_html, type, parent_id = parent_id, - content_subtype=content_subtype, context=context) + content_subtype=content_subtype, subtype=subtype, context=context) #------------------------------------------------------ # Subscription mechanism From 95082105eba58087a461ed3af51e4302c3d7af78 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 16 Aug 2012 13:00:21 +0530 Subject: [PATCH 016/175] [IMP]improve code as per new changes bzr revid: sgo@tinyerp.com-20120816073021-p7wwjuoeegapjxjn --- addons/project/project.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/project/project.py b/addons/project/project.py index 1a8f8c8bfe5..c4b0472f5a1 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1122,6 +1122,10 @@ class task(base_stage, osv.osv): task_id = super(task, self).create(cr, uid, vals, context=context) self._store_history(cr, uid, [task_id], context=context) self.create_send_note(cr, uid, [task_id], context=context) + task_obj = self.browse(cr, uid, task_id, context=context) + if task_obj.project_id: + project_follower_ids = [follow.id for follow in task_obj.project_id.message_follower_ids] + self.message_subscribe(cr, uid, [task_id], project_follower_ids, context=context) return task_id # Overridden to reset the kanban_state to normal whenever From 1f60976cbc94ce1ad1500be21a7b98fdafbed0a7 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 16 Aug 2012 14:16:21 +0530 Subject: [PATCH 017/175] [IMP]minor changes in name bzr revid: sgo@tinyerp.com-20120816084621-s0v4o24o6hlqfrs0 --- addons/project/project.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index c4b0472f5a1..2815ec0f3ca 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1122,9 +1122,9 @@ class task(base_stage, osv.osv): task_id = super(task, self).create(cr, uid, vals, context=context) self._store_history(cr, uid, [task_id], context=context) self.create_send_note(cr, uid, [task_id], context=context) - task_obj = self.browse(cr, uid, task_id, context=context) - if task_obj.project_id: - project_follower_ids = [follow.id for follow in task_obj.project_id.message_follower_ids] + task_record = self.browse(cr, uid, task_id, context=context) + if task_record.project_id: + project_follower_ids = [follower.id for follower in task_record.project_id.message_follower_ids] self.message_subscribe(cr, uid, [task_id], project_follower_ids, context=context) return task_id From 64470badab104a2b934af0f7c64223e4f2baa439 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 16 Aug 2012 15:08:17 +0530 Subject: [PATCH 018/175] [IMP]:project:improved code bzr revid: apa@tinyerp.com-20120816093817-gxsvt8bdmjvb2bu8 --- addons/project/project.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 2815ec0f3ca..55dfd305189 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1120,12 +1120,12 @@ class task(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): task_id = super(task, self).create(cr, uid, vals, context=context) - self._store_history(cr, uid, [task_id], context=context) - self.create_send_note(cr, uid, [task_id], context=context) task_record = self.browse(cr, uid, task_id, context=context) if task_record.project_id: project_follower_ids = [follower.id for follower in task_record.project_id.message_follower_ids] self.message_subscribe(cr, uid, [task_id], project_follower_ids, context=context) + self._store_history(cr, uid, [task_id], context=context) + self.create_send_note(cr, uid, [task_id], context=context) return task_id # Overridden to reset the kanban_state to normal whenever From a929752e463204cd1b9c3c214edc25d6d6897d09 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 16 Aug 2012 16:33:06 +0530 Subject: [PATCH 019/175] [IMP]remove selectin subtype field & change name of obj bzr revid: fka@tinyerp.com-20120816110306-q0mrqa2tp8128nmv --- addons/crm/crm_lead.py | 6 +++--- addons/mail/mail_message.py | 2 +- addons/mail/mail_thread.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 2e6a3b5514d..0ecc7d9bee2 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -278,9 +278,9 @@ class crm_lead(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(crm_lead, self).create(cr, uid, vals, context) - obj = self.browse(cr, uid, obj_id, context) - if obj.user_id: - self.message_subscribe(cr, uid, [obj_id], [obj.user_id.id], context = context) + record = self.browse(cr, uid, obj_id, context) + if record.user_id: + self.message_subscribe(cr, uid, [obj_id], [record.user_id.id], context = context) self.create_send_note(cr, uid, [obj_id], context=context) return obj_id diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 3d0ea943d3a..a50d091f7ff 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -234,7 +234,7 @@ class mail_message(osv.Model): select=True, ondelete='set null', help="Parent message, used for displaying as threads with hierarchy"), 'child_ids': fields.one2many('mail.message', 'parent_id', 'Child Messages'), - 'subtype_id': fields.many2one('mail.message.subtype', 'Subtype', select = True), + 'subtype_id': fields.many2one('mail.message.subtype', 'Subtype'), } _defaults = { diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 840cfbaaa37..ddace0cf9b9 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -273,7 +273,7 @@ class mail_thread(osv.Model): followers_obj = self.pool.get('mail.followers') subtype_obj = self.pool.get('mail.message.subtype') subtype_name = vals.get('subtype') - sutype = False + subtype = False body = vals.get('body_html', '') if vals.get('content_subtype') == 'html' else vals.get('body_text', '') if subtype_name: subtypes = subtype_obj.name_search(cr, uid, subtype_name) From 1b2f6c7551ffeda6c17c7d9492aae08d85efe6e3 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Mon, 20 Aug 2012 10:42:22 +0530 Subject: [PATCH 020/175] [IMP]add message_subtype.yml bzr revid: rma@tinyerp.com-20120820051222-9dk4p47uz53j5nzo --- addons/crm/__openerp__.py | 3 +- .../crm/test/process/crm_message_subtype.yml | 54 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 addons/crm/test/process/crm_message_subtype.yml diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py index 643908c1098..f0f181c47da 100644 --- a/addons/crm/__openerp__.py +++ b/addons/crm/__openerp__.py @@ -129,7 +129,8 @@ Creates a dashboard for CRM that includes: 'test/process/segmentation.yml', 'test/ui/crm_demo.yml', 'test/ui/duplicate_lead.yml', - 'test/ui/delete_lead.yml' + 'test/ui/delete_lead.yml', + 'test/process/crm_message_subtype.yml', ], 'installable': True, 'application': True, diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml new file mode 100644 index 00000000000..a83c729ecd4 --- /dev/null +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -0,0 +1,54 @@ +- + I have add the sub_type name other with default false +- + !record {model: mail.message.subtype, id: mail_subtype_lead_won }: + name: won + model_ids: + - crm.model_crm_lead + default: False +- + I have add the sub_type name email with default true +- + !record {model: mail.message.subtype, id: mail_subtype_lead_email }: + name: email + model_ids: + - crm.model_crm_lead + default: True +- + I have add the sub_type name comment with default true +- + !record {model: mail.message.subtype, id: mail_subtype_lead_comment }: + name: comment + model_ids: + - crm.model_crm_lead + default: True + +- + I have search and write its subtype in followers +- + !python {model: mail.followers}: | + ids = self.search(cr, uid, [('res_model', '=', 'crm.lead'),('res_id', '=', ref('crm_case_1'))]) + self.write(cr, uid, ids, {'subtype_ids': [(6,0,[ref('mail_subtype_lead_won')])]}) +- + I have change the lead into mark won +- + !python {model: crm.lead}: | + self.convert_opportunity(cr, uid ,[ref("crm_case_1")], ref("base.res_partner_4")) + self.case_mark_won(cr, uid,[ref("crm_case_1")] ) +- + I have check the lead into mark won +- + !assert {model: crm.lead, id: crm_case_1 ,string: 'The record is not in won state'}: + - state == 'done' +- + I have check to if subtype is won then display notification. +- + !python {model: mail.message}: | + ids = self.search(cr, uid, [('model', '=','crm.lead'),('res_id', '=', ref('crm_case_1'))]) + browse = self.browse(cr,uid,ids) + + assert ids, 'lead is in won' + + + + From aef5236ba71e9150b56c6b74f4518d7362e6010b Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Mon, 20 Aug 2012 12:48:10 +0530 Subject: [PATCH 021/175] [FIX]make changes into crm_message_subtype.yml file bzr revid: rma@tinyerp.com-20120820071810-fn1wdg36syq1epd5 --- .../crm/test/process/crm_message_subtype.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index a83c729ecd4..705d3cc2fc4 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -22,9 +22,8 @@ model_ids: - crm.model_crm_lead default: True - - - I have search and write its subtype in followers + I have add the subtypes as won in feeds - !python {model: mail.followers}: | ids = self.search(cr, uid, [('res_model', '=', 'crm.lead'),('res_id', '=', ref('crm_case_1'))]) @@ -41,14 +40,9 @@ !assert {model: crm.lead, id: crm_case_1 ,string: 'The record is not in won state'}: - state == 'done' - - I have check to if subtype is won then display notification. + I have check the subtype as won in feeds - - !python {model: mail.message}: | - ids = self.search(cr, uid, [('model', '=','crm.lead'),('res_id', '=', ref('crm_case_1'))]) - browse = self.browse(cr,uid,ids) - - assert ids, 'lead is in won' - - - - + !python {model: mail.followers}: | + followers_ids =self.search(cr, uid, [('res_model', '=','crm.lead'),('res_id', '=', ref('crm_case_1')),('subtype_ids', 'in',[ref('mail_subtype_lead_won')])]) + if len(followers_ids): + assert followers_ids, 'lead is in won' From 82b2b3a626befc97c14591c80b4952c5eed99f6d Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Wed, 22 Aug 2012 11:57:22 +0530 Subject: [PATCH 022/175] [IMP]add name and checkbox on click of follow and make it work as add in subtype_ids in followers bzr revid: sgo@tinyerp.com-20120822062722-ru93dme523lnuko7 --- addons/mail/mail_thread.py | 6 ++-- addons/mail/static/src/js/mail_followers.js | 35 +++++++++++++++++-- addons/mail/static/src/xml/mail_followers.xml | 5 +++ 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index ddace0cf9b9..d552dc108a4 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1192,10 +1192,10 @@ class mail_thread(osv.Model): """ Set as read. """ return self.write(cr, uid, ids, {'message_state': True}, context=context) - def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids): + def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): subscription_obj = self.pool.get('mail.followers') - subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) - return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [6, 0 , subtype_ids]}, context = context) #overright or add new one + subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids),('user_id','=',user_id)]) + return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one def message_subscription_remove_subtype(self, cr, uid, ids, user_id, subtype_id): subscription_obj = self.pool.get('mail.followers') diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 0e920f73041..4e49919e7d2 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -31,6 +31,7 @@ openerp_mail_followers = function(session, mail) { this.params.display_control = this.node.attrs.display_control || false; this.params.display_actions = this.node.attrs.display_actions || false; this.ds_model = new session.web.DataSetSearch(this, this.view.model); + this.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype') this.ds_follow = new session.web.DataSetSearch(this, this.field.relation); }, @@ -42,8 +43,21 @@ openerp_mail_followers = function(session, mail) { this._check_visibility(); this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }); if (! this.params.display_control) { - this.$element.find('button.oe_mail_button_followers').hide(); } - this.$element.find('button.oe_mail_button_follow').click(function () { self.do_follow(); }) + this.$element.find('button.oe_mail_button_followers').hide(); + } + this.$element.find('ul.oe_mail_recthread_subtype').click(function () { + var sublist = new Array(); + _($(this).find('.oe_msg_subtype_check')).each(function (record){ + if($(record).is(':checked')) { + sublist.push(parseInt($(record).attr('id'))) + } + }); + self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,sublist]) + }) + this.$element.find('button.oe_mail_button_follow').click(function () { + self.add_subtype(); + self.do_follow(); + }) .mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); }) @@ -103,10 +117,25 @@ openerp_mail_followers = function(session, mail) { this.$element.find('button.oe_mail_button_follow').show(); this.$element.find('button.oe_mail_button_unfollow').hide(); } }, - + + subtype_value: function(value_) { + return this.sub_model.call('read', [value_ || this.get_value(),['name', 'default']]).then(this.proxy('read_subtype')); + }, + + read_subtype: function(records) { + this.reinit() + var subtype_list = this.$element.find('ul.oe_mail_recthread_subtype').empty(); + _(records).each(function (record) { + $(session.web.qweb.render('mail.subtype.ids', {'record': record})).appendTo(subtype_list); + }); + }, + do_follow: function () { return this.ds_model.call('message_subscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value')); }, + add_subtype: function () { + return this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]).pipe(this.proxy('subtype_value')); + }, do_unfollow: function () { return this.ds_model.call('message_unsubscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value')); diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 53c899b9569..9979aa9d6fa 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -16,6 +16,7 @@

    +
      @@ -27,5 +28,9 @@ +
    • + + +
    • From ecdab52f06551bca82a53544c52194970779a4e1 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Wed, 22 Aug 2012 14:53:17 +0530 Subject: [PATCH 023/175] [IMP]if subtype selected its write in follower and improve code bzr revid: sgo@tinyerp.com-20120822092317-4nlhfton4ltk1lcq --- addons/mail/static/src/js/mail_followers.js | 29 ++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 4e49919e7d2..2940ae54288 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -33,6 +33,7 @@ openerp_mail_followers = function(session, mail) { this.ds_model = new session.web.DataSetSearch(this, this.view.model); this.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype') this.ds_follow = new session.web.DataSetSearch(this, this.field.relation); + this.follow_model = new session.web.DataSetSearch(this,'mail.followers') }, start: function() { @@ -41,6 +42,8 @@ openerp_mail_followers = function(session, mail) { // any other method to know if the view is in create mode anymore this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); + self.add_subtype(); + this.$element.find('ul.oe_mail_recthread_subtype').hide() this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }); if (! this.params.display_control) { this.$element.find('button.oe_mail_button_followers').hide(); @@ -55,12 +58,13 @@ openerp_mail_followers = function(session, mail) { self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,sublist]) }) this.$element.find('button.oe_mail_button_follow').click(function () { - self.add_subtype(); self.do_follow(); + self.$element.find('ul.oe_mail_recthread_subtype').show() }) .mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); - this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); }) + this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); + self.$element.find('ul.oe_mail_recthread_subtype').hide() }) .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.reinit(); @@ -81,6 +85,7 @@ openerp_mail_followers = function(session, mail) { this.$element.find('button.oe_mail_button_followers').html('Hide followers') this.$element.find('button.oe_mail_button_follow').hide(); this.$element.find('button.oe_mail_button_unfollow').hide(); + this.$element.find('ul.oe_mail_recthread_subtype').hide() }, set_value: function(value_) { @@ -112,10 +117,12 @@ openerp_mail_followers = function(session, mail) { }); if (this.is_subscriber) { this.$element.find('button.oe_mail_button_follow').hide(); - this.$element.find('button.oe_mail_button_unfollow').show(); } + this.$element.find('button.oe_mail_button_unfollow').show(); + this.$element.find('ul.oe_mail_recthread_subtype').show()} else { this.$element.find('button.oe_mail_button_follow').show(); - this.$element.find('button.oe_mail_button_unfollow').hide(); } + this.$element.find('button.oe_mail_button_unfollow').hide(); + this.$element.find('ul.oe_mail_recthread_subtype').hide() } }, subtype_value: function(value_) { @@ -123,9 +130,19 @@ openerp_mail_followers = function(session, mail) { }, read_subtype: function(records) { - this.reinit() + var self = this var subtype_list = this.$element.find('ul.oe_mail_recthread_subtype').empty(); - _(records).each(function (record) { + var follow_ids = this.follow_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) + follow_ids.then(function (record){ + var msg_subtype = self.follow_model.call('read', [record,['subtype_ids']]); + if(msg_subtype){ + msg_subtype.then(function (subtype){ + _(subtype[0].subtype_ids).each(function (subtype_id){ + self.$element.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true + }); + })} + }); + _(records).each(function (record) { $(session.web.qweb.render('mail.subtype.ids', {'record': record})).appendTo(subtype_list); }); }, From 117e0dffa03fc8ca55254310fc02455fc0930276 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 23 Aug 2012 10:30:29 +0530 Subject: [PATCH 024/175] [IMP]improve code bzr revid: sgo@tinyerp.com-20120823050029-wz5ce5f8xsrsbqyq --- addons/mail/static/src/js/mail_followers.js | 48 ++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 2940ae54288..a468a0b25d9 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -42,21 +42,20 @@ openerp_mail_followers = function(session, mail) { // any other method to know if the view is in create mode anymore this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); - self.add_subtype(); + self.search_subtype(); this.$element.find('ul.oe_mail_recthread_subtype').hide() + this.$element.find('ul.oe_mail_recthread_subtype').click(function () { + var subtypelist = new Array(); + _($(this).find('.oe_msg_subtype_check')).each(function (record){ + if($(record).is(':checked')) { + subtypelist.push(parseInt($(record).attr('id')))} + }); + self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,subtypelist]) + }) this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }); if (! this.params.display_control) { this.$element.find('button.oe_mail_button_followers').hide(); } - this.$element.find('ul.oe_mail_recthread_subtype').click(function () { - var sublist = new Array(); - _($(this).find('.oe_msg_subtype_check')).each(function (record){ - if($(record).is(':checked')) { - sublist.push(parseInt($(record).attr('id'))) - } - }); - self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,sublist]) - }) this.$element.find('button.oe_mail_button_follow').click(function () { self.do_follow(); self.$element.find('ul.oe_mail_recthread_subtype').show() @@ -72,6 +71,7 @@ openerp_mail_followers = function(session, mail) { _check_visibility: function() { this.$element.toggle(this.view.get("actual_mode") !== "create"); + if(this.view.get("actual_mode") == "create"){this.search_subtype();} }, destroy: function () { @@ -132,25 +132,25 @@ openerp_mail_followers = function(session, mail) { read_subtype: function(records) { var self = this var subtype_list = this.$element.find('ul.oe_mail_recthread_subtype').empty(); - var follow_ids = this.follow_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) - follow_ids.then(function (record){ - var msg_subtype = self.follow_model.call('read', [record,['subtype_ids']]); - if(msg_subtype){ - msg_subtype.then(function (subtype){ - _(subtype[0].subtype_ids).each(function (subtype_id){ - self.$element.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true - }); - })} - }); - _(records).each(function (record) { + var follow_ids = this.follow_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) + follow_ids.then(function (record){ + var follow_read = self.follow_model.call('read', [record,['subtype_ids']]); + follow_read.then(function (follow_record){ + if(follow_record.length != 0){ + _(follow_record[0].subtype_ids).each(function (subtype_id){ + self.$element.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true + });} + }) + }); + _(records).each(function (record) { $(session.web.qweb.render('mail.subtype.ids', {'record': record})).appendTo(subtype_list); - }); - }, + }); + }, do_follow: function () { return this.ds_model.call('message_subscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value')); }, - add_subtype: function () { + search_subtype: function () { return this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]).pipe(this.proxy('subtype_value')); }, From 753e55c089e5faf1ff51e6790f82f1fffc83d5e6 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 23 Aug 2012 11:32:16 +0530 Subject: [PATCH 025/175] [IMP]improve code and naming convention bzr revid: sgo@tinyerp.com-20120823060216-sp10hvix2uw3wrg0 --- addons/mail/static/src/js/mail_followers.js | 42 +++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index a468a0b25d9..3ba080e19f0 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -33,7 +33,7 @@ openerp_mail_followers = function(session, mail) { this.ds_model = new session.web.DataSetSearch(this, this.view.model); this.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype') this.ds_follow = new session.web.DataSetSearch(this, this.field.relation); - this.follow_model = new session.web.DataSetSearch(this,'mail.followers') + this.follower_model = new session.web.DataSetSearch(this,'mail.followers') }, start: function() { @@ -42,7 +42,7 @@ openerp_mail_followers = function(session, mail) { // any other method to know if the view is in create mode anymore this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); - self.search_subtype(); + this.fetch_subtype(); this.$element.find('ul.oe_mail_recthread_subtype').hide() this.$element.find('ul.oe_mail_recthread_subtype').click(function () { var subtypelist = new Array(); @@ -71,7 +71,7 @@ openerp_mail_followers = function(session, mail) { _check_visibility: function() { this.$element.toggle(this.view.get("actual_mode") !== "create"); - if(this.view.get("actual_mode") == "create"){this.search_subtype();} + if(this.view.get("actual_mode") == "create"){this.fetch_subtype();} }, destroy: function () { @@ -125,33 +125,37 @@ openerp_mail_followers = function(session, mail) { this.$element.find('ul.oe_mail_recthread_subtype').hide() } }, - subtype_value: function(value_) { - return this.sub_model.call('read', [value_ || this.get_value(),['name', 'default']]).then(this.proxy('read_subtype')); - }, - - read_subtype: function(records) { + // Display the subtypes of each records. + display_subtype: function(records) { var self = this var subtype_list = this.$element.find('ul.oe_mail_recthread_subtype').empty(); - var follow_ids = this.follow_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) - follow_ids.then(function (record){ - var follow_read = self.follow_model.call('read', [record,['subtype_ids']]); - follow_read.then(function (follow_record){ - if(follow_record.length != 0){ - _(follow_record[0].subtype_ids).each(function (subtype_id){ - self.$element.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true - });} + var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) + follower_ids.then(function (record){ + var follower_read = self.follower_model.call('read', [record,['subtype_ids']]); + follower_read.then(function (follower_record){ + if(follower_record.length != 0){ + _(follower_record[0].subtype_ids).each(function (subtype_id){ + self.$element.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true + }); + } }) }); _(records).each(function (record) { $(session.web.qweb.render('mail.subtype.ids', {'record': record})).appendTo(subtype_list); }); - }, + }, do_follow: function () { return this.ds_model.call('message_subscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value')); }, - search_subtype: function () { - return this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]).pipe(this.proxy('subtype_value')); + + //fetch subtype from subtype model + fetch_subtype: function () { + var self = this + var subtype_object = this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]); + subtype_object.then(function (subtype_ids){ + self.sub_model.call('read', [subtype_ids || self.get_value(),['name', 'default']]).then(self.proxy('display_subtype')); + }); }, do_unfollow: function () { From 27e0487ee742ca0692557ccc38508c18904c531b Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 23 Aug 2012 14:36:16 +0530 Subject: [PATCH 026/175] [IMP] improve code in mail.xml bzr revid: fka@tinyerp.com-20120823090616-e2ro792wqyywxtt9 --- addons/mail/static/src/js/mail_followers.js | 2 +- addons/mail/static/src/xml/mail_followers.xml | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 3ba080e19f0..76280e38ae3 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -141,7 +141,7 @@ openerp_mail_followers = function(session, mail) { }) }); _(records).each(function (record) { - $(session.web.qweb.render('mail.subtype.ids', {'record': record})).appendTo(subtype_list); + $(session.web.qweb.render('mail.record_thread.subtype', {'record': record})).appendTo(subtype_list); }); }, diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 9979aa9d6fa..c0cc747a817 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -28,9 +28,17 @@ -
    • - - +
    • + + + + + +
      + + + +
    • From 107eade158b0950e01277e09fbed0a5c0459f84e Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 23 Aug 2012 15:51:38 +0530 Subject: [PATCH 027/175] [IMP] make 1st latter of name of subtype bzr revid: fka@tinyerp.com-20120823102138-0cjhjiw5ob6z2i7e --- addons/mail/static/src/js/mail_followers.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 76280e38ae3..42e331863be 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -141,6 +141,9 @@ openerp_mail_followers = function(session, mail) { }) }); _(records).each(function (record) { + record.name = record.name.toLowerCase().replace(/\b[a-z]/g, function(letter) { + return letter.toUpperCase(); + }); $(session.web.qweb.render('mail.record_thread.subtype', {'record': record})).appendTo(subtype_list); }); }, From 0d8bfaaf87e7013190f0587e411ab0e3a467db6c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 23 Aug 2012 16:17:05 +0530 Subject: [PATCH 028/175] [IMP]add comment whr needed bzr revid: sgo@tinyerp.com-20120823104705-ji03v95oe2ycz2k2 --- addons/mail/static/src/js/mail_followers.js | 9 ++++----- addons/mail/static/src/xml/mail_followers.xml | 9 +++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 42e331863be..29761ff66ce 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -43,7 +43,6 @@ openerp_mail_followers = function(session, mail) { this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); this.fetch_subtype(); - this.$element.find('ul.oe_mail_recthread_subtype').hide() this.$element.find('ul.oe_mail_recthread_subtype').click(function () { var subtypelist = new Array(); _($(this).find('.oe_msg_subtype_check')).each(function (record){ @@ -55,15 +54,15 @@ openerp_mail_followers = function(session, mail) { this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }); if (! this.params.display_control) { this.$element.find('button.oe_mail_button_followers').hide(); + this.$element.find('ul.oe_mail_recthread_subtype').hide() } this.$element.find('button.oe_mail_button_follow').click(function () { self.do_follow(); - self.$element.find('ul.oe_mail_recthread_subtype').show() + self.fetch_subtype(); }) .mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); - this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); - self.$element.find('ul.oe_mail_recthread_subtype').hide() }) + this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); }) .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.reinit(); @@ -118,7 +117,7 @@ openerp_mail_followers = function(session, mail) { if (this.is_subscriber) { this.$element.find('button.oe_mail_button_follow').hide(); this.$element.find('button.oe_mail_button_unfollow').show(); - this.$element.find('ul.oe_mail_recthread_subtype').show()} + this.$element.find('ul.oe_mail_recthread_subtype').show(); } else { this.$element.find('button.oe_mail_button_follow').show(); this.$element.find('button.oe_mail_button_unfollow').hide(); diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index c0cc747a817..d590407494f 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -3,7 +3,7 @@
      @@ -27,7 +27,12 @@
    • -
    • + \ + +
    • From cc56b498a14992e4fe78ec11962da1161466d726 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 24 Aug 2012 14:16:28 +0530 Subject: [PATCH 029/175] [IMP]if record is unread it also show only those record which checked in subtype bzr revid: sgo@tinyerp.com-20120824084628-r9bvejcya6mt6l33 --- addons/mail/mail_thread.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index c7f77208149..04a71a91a5b 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -319,9 +319,11 @@ class mail_thread(osv.Model): subscr_ids = subscr_obj.search(cr, uid, ['&', ('res_model', '=', self._name), ('res_id', 'in', thread_ids)], context=context) notif_user_ids = [] # check with subtype + is_subtype = False for subscription in subscr_obj.browse(cr, uid, subscr_ids, context=context): if subtype_id: if subtype_id in [subtype.id for subtype in subscription.subtype_ids]: + is_subtype = True notif_user_ids.append(subscription.user_id.id) else: notif_user_ids.append(subscription.user_id.id) @@ -330,7 +332,8 @@ class mail_thread(osv.Model): if hasattr(self, 'get_needaction_user_ids') and self._columns.get('user_id'): user_ids_dict = self.get_needaction_user_ids(cr, uid, thread_ids, context=context) for id, user_ids in user_ids_dict.iteritems(): - notif_user_ids += user_ids + if is_subtype: + notif_user_ids += user_ids # add users notified of the parent messages (because: if parent message contains @login, login must receive the replies) if new_msg_vals.get('parent_id'): From 27010a32ec33107d658f932ed2b5b8a0d36ae9d5 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 24 Aug 2012 18:02:03 +0530 Subject: [PATCH 030/175] [IMP]add access rights bzr revid: sgo@tinyerp.com-20120824123203-4kmu02cyehbqd48v --- addons/mail/security/ir.model.access.csv | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/mail/security/ir.model.access.csv b/addons/mail/security/ir.model.access.csv index 1979e2fec05..1e88e4e5a12 100644 --- a/addons/mail/security/ir.model.access.csv +++ b/addons/mail/security/ir.model.access.csv @@ -1,9 +1,10 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_mail_message_all,mail.message.all,model_mail_message,,1,0,0,0 -access_mail_message_group_user,mail.message.group.user,model_mail_message,base.group_user,1,1,1,1 -access_mail_thread,mail.thread,model_mail_thread,base.group_user,1,1,1,0 -access_mail_followers_all,mail.followers.all,model_mail_followers,,1,1,1,1 -access_mail_notification_all,mail.notification.all,model_mail_notification,,1,1,1,1 -access_mail_group,mail.group,model_mail_group,base.group_user,1,1,1,1 -access_mail_alias_user,mail.alias,model_mail_alias,base.group_user,1,1,1,0 -access_mail_alias_system,mail.alias,model_mail_alias,base.group_system,1,1,1,1 +id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink +access_mail_message_all mail.message.all model_mail_message 1 0 0 0 +access_mail_message_group_user mail.message.group.user model_mail_message base.group_user 1 1 1 1 +access_mail_thread mail.thread model_mail_thread base.group_user 1 1 1 0 +access_mail_followers_all mail.followers.all model_mail_followers 1 1 1 1 +access_mail_notification_all mail.notification.all model_mail_notification 1 1 1 1 +access_mail_group mail.group model_mail_group base.group_user 1 1 1 1 +access_mail_alias_user mail.alias model_mail_alias base.group_user 1 1 1 0 +access_mail_alias_system mail.alias model_mail_alias base.group_system 1 1 1 1 +access_mail_message_subtype mail.message.subtype mode_mail_message_subtype 1 1 1 1 From af5583bb93822f4a5c8d2c48ddfb5a9cfd208fd8 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Mon, 27 Aug 2012 10:59:20 +0530 Subject: [PATCH 031/175] [IMP]:improved view bzr revid: apa@tinyerp.com-20120827052920-e7dwg2vqj0swnwqk --- addons/mail/static/src/xml/mail_followers.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index d590407494f..1a93d860b53 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -11,12 +11,12 @@ +

          -
            @@ -33,7 +33,7 @@ record_thread.subtype template Template used to display subtype of record --> -
          • +
          • @@ -44,6 +44,6 @@
            -
          • +
            From 1338046cf0f7d37f724a09899695b7e02a5b873c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Mon, 27 Aug 2012 10:59:33 +0530 Subject: [PATCH 032/175] [IMP]added access to mail_message_subtype bzr revid: sgo@tinyerp.com-20120827052933-6ajhaete5vuzqhiv --- addons/mail/security/ir.model.access.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/mail/security/ir.model.access.csv b/addons/mail/security/ir.model.access.csv index 1979e2fec05..61106fbf234 100644 --- a/addons/mail/security/ir.model.access.csv +++ b/addons/mail/security/ir.model.access.csv @@ -7,3 +7,4 @@ access_mail_notification_all,mail.notification.all,model_mail_notification,,1,1, access_mail_group,mail.group,model_mail_group,base.group_user,1,1,1,1 access_mail_alias_user,mail.alias,model_mail_alias,base.group_user,1,1,1,0 access_mail_alias_system,mail.alias,model_mail_alias,base.group_system,1,1,1,1 +access_mail_message_subtype,mail.message.subtype,model_mail_message_subtype,,1,1,1,1 \ No newline at end of file From 5a8bdae6d684cc4e4c9140ff971aaa5c552e7925 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Mon, 27 Aug 2012 11:25:39 +0530 Subject: [PATCH 033/175] [IMP]:improved view bzr revid: apa@tinyerp.com-20120827055539-kqybbq2sqhx9tax9 --- addons/mail/static/src/js/mail_followers.js | 12 ++++++------ addons/mail/static/src/xml/mail_followers.xml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index c6a83817af9..f81919de1c7 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -43,7 +43,7 @@ openerp_mail_followers = function(session, mail) { this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); this.fetch_subtype(); - this.$el.find('ul.oe_mail_recthread_subtype').click(function () { + this.$el.find('div.oe_mail_recthread_subtype').click(function () { var subtypelist = new Array(); _($(this).find('.oe_msg_subtype_check')).each(function (record){ if($(record).is(':checked')) { @@ -55,7 +55,7 @@ openerp_mail_followers = function(session, mail) { if (! this.params.display_control) { this.$el.find('button.oe_mail_button_followers').hide(); - this.$el.find('ul.oe_mail_recthread_subtype').hide() + this.$el.find('div.oe_mail_recthread_subtype').hide() } this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); @@ -85,7 +85,7 @@ openerp_mail_followers = function(session, mail) { this.$el.find('button.oe_mail_button_followers').html('Hide followers') this.$el.find('button.oe_mail_button_follow').hide(); this.$el.find('button.oe_mail_button_unfollow').hide(); - this.$el.find('ul.oe_mail_recthread_subtype').hide() + this.$el.find('div.oe_mail_recthread_subtype').hide() }, set_value: function(value_) { @@ -118,17 +118,17 @@ openerp_mail_followers = function(session, mail) { if (this.is_subscriber) { this.$el.find('button.oe_mail_button_follow').hide(); this.$el.find('button.oe_mail_button_unfollow').show(); - this.$el.find('ul.oe_mail_recthread_subtype').show(); } + this.$el.find('div.oe_mail_recthread_subtype').show(); } else { this.$el.find('button.oe_mail_button_follow').show(); this.$el.find('button.oe_mail_button_unfollow').hide(); - this.$el.find('ul.oe_mail_recthread_subtype').hide() } + this.$el.find('div.oe_mail_recthread_subtype').hide() } }, // Display the subtypes of each records. display_subtype: function(records) { var self = this - var subtype_list = this.$el.find('ul.oe_mail_recthread_subtype').empty(); + var subtype_list = this.$el.find('div.oe_mail_recthread_subtype').empty(); var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) follower_ids.then(function (record){ var follower_read = self.follower_model.call('read', [record,['subtype_ids']]); diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 1a93d860b53..2f7f5e6cde8 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -11,7 +11,7 @@
            -
              +

              From 0f8274ffa30acf585dbd7359c0e9872727a8663d Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Tue, 28 Aug 2012 12:49:06 +0530 Subject: [PATCH 034/175] [IMP] Display Default value of subtype bzr revid: fka@tinyerp.com-20120828071906-cdoh84qlie1si73t --- addons/mail/static/src/js/mail_followers.js | 18 +++++++++++------- addons/mail/static/src/xml/mail_followers.xml | 3 ++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index f81919de1c7..cfbff3744aa 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -44,12 +44,7 @@ openerp_mail_followers = function(session, mail) { this._check_visibility(); this.fetch_subtype(); this.$el.find('div.oe_mail_recthread_subtype').click(function () { - var subtypelist = new Array(); - _($(this).find('.oe_msg_subtype_check')).each(function (record){ - if($(record).is(':checked')) { - subtypelist.push(parseInt($(record).attr('id')))} - }); - self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,subtypelist]) + self.update_subtype(); }) this.$el.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }); @@ -108,6 +103,7 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; + if(this.view.get("actual_mode") == "edit"){this.update_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { @@ -124,7 +120,15 @@ openerp_mail_followers = function(session, mail) { this.$el.find('button.oe_mail_button_unfollow').hide(); this.$el.find('div.oe_mail_recthread_subtype').hide() } }, - + update_subtype: function (){ + var self = this; + var cheklist = new Array(); + _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ + if($(record).is(':checked')) { + cheklist.push(parseInt($(record).attr('id')))} + }); + self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,cheklist]) + }, // Display the subtypes of each records. display_subtype: function(records) { var self = this diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 2f7f5e6cde8..d307aff7b19 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -40,7 +40,8 @@ - + + From 65d83c36204529e60fcdc6a16bb583d4090a9ce8 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Tue, 28 Aug 2012 14:26:35 +0530 Subject: [PATCH 035/175] [IMP]:improved code. set default while reload and create bzr revid: apa@tinyerp.com-20120828085635-tw54dpuno965k2bn --- addons/mail/static/src/js/mail_followers.js | 42 ++++++++++----------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index cfbff3744aa..5750d005973 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -43,15 +43,13 @@ openerp_mail_followers = function(session, mail) { this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); this.fetch_subtype(); - this.$el.find('div.oe_mail_recthread_subtype').click(function () { - self.update_subtype(); - }) + this.$el.find('div.oe_mail_recthread_subtype').click(function () {self.update_subtype();}) this.$el.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); }); if (! this.params.display_control) { this.$el.find('button.oe_mail_button_followers').hide(); this.$el.find('div.oe_mail_recthread_subtype').hide() - } + } this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); self.fetch_subtype(); @@ -66,7 +64,7 @@ openerp_mail_followers = function(session, mail) { _check_visibility: function() { this.$el.toggle(this.view.get("actual_mode") !== "create"); - if(this.view.get("actual_mode") == "create"){this.fetch_subtype();} + if (this.view.get("actual_mode") === "create"){this.fetch_subtype();} }, destroy: function () { @@ -103,7 +101,7 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; - if(this.view.get("actual_mode") == "edit"){this.update_subtype();} + if (this.view.get("actual_mode") !== "create"){self.update_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { @@ -125,7 +123,7 @@ openerp_mail_followers = function(session, mail) { var cheklist = new Array(); _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ if($(record).is(':checked')) { - cheklist.push(parseInt($(record).attr('id')))} + cheklist.push(parseInt($(record).attr('id')))} }); self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,cheklist]) }, @@ -135,19 +133,17 @@ openerp_mail_followers = function(session, mail) { var subtype_list = this.$el.find('div.oe_mail_recthread_subtype').empty(); var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) follower_ids.then(function (record){ - var follower_read = self.follower_model.call('read', [record,['subtype_ids']]); - follower_read.then(function (follower_record){ - if(follower_record.length != 0){ - _(follower_record[0].subtype_ids).each(function (subtype_id){ - self.$el.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true - }); - } - }) + var follower_read = self.follower_model.call('read', [record,['subtype_ids']]); + follower_read.then(function (follower_record){ + if(follower_record.length != 0){ + _(follower_record[0].subtype_ids).each(function (subtype_id){ + self.$el.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true + }); + } + }) }); _(records).each(function (record) { - record.name = record.name.toLowerCase().replace(/\b[a-z]/g, function(letter) { - return letter.toUpperCase(); - }); + record.name = record.name.toLowerCase().replace(/\b[a-z]/g, function(letter) {return letter.toUpperCase();}); $(session.web.qweb.render('mail.record_thread.subtype', {'record': record})).appendTo(subtype_list); }); }, @@ -158,11 +154,11 @@ openerp_mail_followers = function(session, mail) { //fetch subtype from subtype model fetch_subtype: function () { - var self = this - var subtype_object = this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]); - subtype_object.then(function (subtype_ids){ - self.sub_model.call('read', [subtype_ids || self.get_value(),['name', 'default']]).then(self.proxy('display_subtype')); - }); + var self = this + var subtype_object = this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]); + subtype_object.then(function (subtype_ids){ + self.sub_model.call('read', [subtype_ids || self.get_value(),['name', 'default']]).then(self.proxy('display_subtype')); + }); }, do_unfollow: function () { From 362e7e310262f1a160bf3c8aadfbf11a526848fb Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Tue, 28 Aug 2012 14:57:23 +0530 Subject: [PATCH 036/175] [IMP]:improved code. set default while reload and create bzr revid: apa@tinyerp.com-20120828092723-oogxsd60t348defy --- addons/mail/static/src/js/mail_followers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 5750d005973..4606996c374 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -101,7 +101,7 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; - if (this.view.get("actual_mode") !== "create"){self.update_subtype();} + if (this.view.get("actual_mode") === "edit"){self.update_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { From 99e021203f1e13360bf953c3502aaa38c2980215 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Tue, 28 Aug 2012 15:01:25 +0530 Subject: [PATCH 037/175] [IMP]:improve code bzr revid: apa@tinyerp.com-20120828093125-mbyw902f77cm9n1w --- addons/mail/static/src/js/mail_followers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 4606996c374..bc219712b3d 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -101,7 +101,6 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; - if (this.view.get("actual_mode") === "edit"){self.update_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { @@ -130,6 +129,7 @@ openerp_mail_followers = function(session, mail) { // Display the subtypes of each records. display_subtype: function(records) { var self = this + if (self.view.get("actual_mode") === "edit"){self.update_subtype();} var subtype_list = this.$el.find('div.oe_mail_recthread_subtype').empty(); var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) follower_ids.then(function (record){ From 205c8453ea9ec353e26497309a749333dd29600f Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Tue, 28 Aug 2012 15:35:06 +0530 Subject: [PATCH 038/175] [IMP]:reverted default to display subcribe method bzr revid: apa@tinyerp.com-20120828100506-7o73f6sh6gcbeq7p --- addons/mail/static/src/js/mail_followers.js | 2 +- addons/mail/static/src/xml/mail_followers.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index bc219712b3d..4a328fbbc55 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -101,6 +101,7 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; + if (self.view.get("actual_mode") === "edit"){self.update_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { @@ -129,7 +130,6 @@ openerp_mail_followers = function(session, mail) { // Display the subtypes of each records. display_subtype: function(records) { var self = this - if (self.view.get("actual_mode") === "edit"){self.update_subtype();} var subtype_list = this.$el.find('div.oe_mail_recthread_subtype').empty(); var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]]) follower_ids.then(function (record){ diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index d307aff7b19..b0e19e57579 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -40,7 +40,7 @@ - + From 7c3569385fa5cd5e32899a3b044a71605aeb07d5 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Wed, 29 Aug 2012 12:12:43 +0530 Subject: [PATCH 039/175] [IMP]:default work with demo data and remove readonly from subtype bzr revid: apa@tinyerp.com-20120829064243-w0y3k6c3uxcqruzm --- addons/crm/crm_lead.py | 4 +++- addons/mail/mail_thread.py | 2 +- addons/mail/static/src/js/mail_followers.js | 1 - addons/mail/static/src/xml/mail_followers.xml | 3 +-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index c4423520847..75c1863c4d8 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -278,9 +278,11 @@ class crm_lead(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(crm_lead, self).create(cr, uid, vals, context) + subtype_obj = self.pool.get('mail.message.subtype'); + subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', 'crm.lead')]) record = self.browse(cr, uid, obj_id, context) if record.user_id: - self.message_subscribe(cr, uid, [obj_id], [record.user_id.id], context = context) + self.message_subscribe(cr, uid, [obj_id], [record.user_id.id], subtype_ids,context = context) self.create_send_note(cr, uid, [obj_id], context=context) return obj_id diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 04a71a91a5b..0e1e90f39df 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1051,7 +1051,7 @@ class mail_thread(osv.Model): write_res = self.write(cr, uid, ids, {'message_follower_ids': self.message_subscribe_get_command(cr, uid, to_subscribe_uids, context)}, context=context) follower_ids = [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] if subtype_ids: - self.pool.get('mail.followers').write(cr, uid, follower_ids, {'subtype_ids': [(6, 0, subtype_ids)]}, context=context) + self.message_subscribe_udpate_subtypes(cr, uid, ids, user_ids, subtype_ids, context=context) return follower_ids def message_subscribe_get_command(self, cr, uid, follower_ids, context=None): diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 4a328fbbc55..7e150051f7f 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -101,7 +101,6 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; - if (self.view.get("actual_mode") === "edit"){self.update_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index b0e19e57579..3bdd18bb0a0 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -40,8 +40,7 @@ - - + From 8e0151002ac6692afc833f523872b97b7433784d Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Wed, 29 Aug 2012 12:25:14 +0530 Subject: [PATCH 040/175] [IMP]:improved code bzr revid: apa@tinyerp.com-20120829065514-mzr02sccg2fhrfog --- addons/crm/crm_lead.py | 4 +--- addons/mail/mail_thread.py | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 75c1863c4d8..c4423520847 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -278,11 +278,9 @@ class crm_lead(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(crm_lead, self).create(cr, uid, vals, context) - subtype_obj = self.pool.get('mail.message.subtype'); - subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', 'crm.lead')]) record = self.browse(cr, uid, obj_id, context) if record.user_id: - self.message_subscribe(cr, uid, [obj_id], [record.user_id.id], subtype_ids,context = context) + self.message_subscribe(cr, uid, [obj_id], [record.user_id.id], context = context) self.create_send_note(cr, uid, [obj_id], context=context) return obj_id diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 0e1e90f39df..b68c32ad860 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1050,6 +1050,10 @@ class mail_thread(osv.Model): to_subscribe_uids = [uid] if user_ids is None else user_ids write_res = self.write(cr, uid, ids, {'message_follower_ids': self.message_subscribe_get_command(cr, uid, to_subscribe_uids, context)}, context=context) follower_ids = [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] + + if not subtype_ids: + subtype_obj = self.pool.get('mail.message.subtype') + subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)]) if subtype_ids: self.message_subscribe_udpate_subtypes(cr, uid, ids, user_ids, subtype_ids, context=context) return follower_ids From 1325a350d5f21f3a2ee789d6bb1ee73d0dbb6210 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Wed, 29 Aug 2012 12:46:57 +0530 Subject: [PATCH 041/175] [IMP]:improved code to display subtype while create new lead bzr revid: apa@tinyerp.com-20120829071657-rb5kmx9kdbgiyydj --- addons/mail/mail_thread.py | 3 ++- addons/mail/static/src/js/mail_followers.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index b68c32ad860..8c117065055 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1050,10 +1050,11 @@ class mail_thread(osv.Model): to_subscribe_uids = [uid] if user_ids is None else user_ids write_res = self.write(cr, uid, ids, {'message_follower_ids': self.message_subscribe_get_command(cr, uid, to_subscribe_uids, context)}, context=context) follower_ids = [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] - + print "self._name",self._name if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)]) + print "subtype_ids",subtype_ids if subtype_ids: self.message_subscribe_udpate_subtypes(cr, uid, ids, user_ids, subtype_ids, context=context) return follower_ids diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 7e150051f7f..d9c55a2d6ab 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -64,7 +64,7 @@ openerp_mail_followers = function(session, mail) { _check_visibility: function() { this.$el.toggle(this.view.get("actual_mode") !== "create"); - if (this.view.get("actual_mode") === "create"){this.fetch_subtype();} + if (this.view.get("actual_mode") !== "create"){this.fetch_subtype();} }, destroy: function () { @@ -101,6 +101,7 @@ openerp_mail_followers = function(session, mail) { display_subscribers: function (records) { var self = this; this.is_subscriber = false; + //if (self.view.get("actual_mode") === "edit"){self.fetch_subtype();} var user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { From 8a84afef994b08834f97e325ecbdf591dbbccb47 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Wed, 29 Aug 2012 12:56:33 +0530 Subject: [PATCH 042/175] [IMP]:removed print and pass uid bzr revid: apa@tinyerp.com-20120829072633-c13fg277j6be8182 --- addons/mail/mail_thread.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 8c117065055..78b6dfac92c 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1050,13 +1050,11 @@ class mail_thread(osv.Model): to_subscribe_uids = [uid] if user_ids is None else user_ids write_res = self.write(cr, uid, ids, {'message_follower_ids': self.message_subscribe_get_command(cr, uid, to_subscribe_uids, context)}, context=context) follower_ids = [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] - print "self._name",self._name if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)]) - print "subtype_ids",subtype_ids if subtype_ids: - self.message_subscribe_udpate_subtypes(cr, uid, ids, user_ids, subtype_ids, context=context) + self.message_subscribe_udpate_subtypes(cr, uid, ids, to_subscribe_uids, subtype_ids, context=context) return follower_ids def message_subscribe_get_command(self, cr, uid, follower_ids, context=None): @@ -1202,7 +1200,7 @@ class mail_thread(osv.Model): def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): subscription_obj = self.pool.get('mail.followers') - subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids),('user_id','=',user_id)]) + subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids),('user_id','in',user_id)]) return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one def message_subscription_remove_subtype(self, cr, uid, ids, user_id, subtype_id): From abc4e850421a6bb19f32cba5768ad2b8828fa0d7 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Wed, 29 Aug 2012 13:03:33 +0530 Subject: [PATCH 043/175] [IMP]:improved code bzr revid: apa@tinyerp.com-20120829073333-j6xts836d3bqepk8 --- addons/mail/static/src/js/mail_followers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index d9c55a2d6ab..3c91bbae89e 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -125,7 +125,7 @@ openerp_mail_followers = function(session, mail) { if($(record).is(':checked')) { cheklist.push(parseInt($(record).attr('id')))} }); - self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,cheklist]) + self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],[self.session.uid],cheklist]) }, // Display the subtypes of each records. display_subtype: function(records) { From aa9fa89423b341d1c95356065352bfc2d4a65d7d Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 29 Aug 2012 18:45:32 +0530 Subject: [PATCH 044/175] [IMP] improve demo data of crm and add demo data in project bzr revid: fka@tinyerp.com-20120829131532-vpvaaq0mbwdfktyk --- addons/crm/crm_lead_data.xml | 33 +++++++++++-------------- addons/mail/data/mail_data.xml | 11 +++++++++ addons/project/project.py | 16 ++++++------ addons/project/project_data.xml | 43 +++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 27 deletions(-) diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index ce9951defc6..6f6562657ce 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -155,37 +155,32 @@ - + new - + - + won - + - + lost - + - + stage change - + - - other - - + + - - email - + + - - comment - - + + diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index c8e8b1a488e..b241cb095de 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -12,5 +12,16 @@ + + + other + + + + email + + + comment + diff --git a/addons/project/project.py b/addons/project/project.py index 4a6311b7f56..4f23cbbdc49 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -536,23 +536,23 @@ def Project(): return project_id def create_send_note(self, cr, uid, ids, context=None): - return self.message_append_note(cr, uid, ids, body=_("Project has been created."), context=context) + return self.message_append_note(cr, uid, ids, body=_("Project has been created."), subtype="new", context=context) def set_open_send_note(self, cr, uid, ids, context=None): message = _("Project has been opened.") - return self.message_append_note(cr, uid, ids, body=message, context=context) + return self.message_append_note(cr, uid, ids, body=message, subtype="open", context=context) def set_pending_send_note(self, cr, uid, ids, context=None): message = _("Project is now pending.") - return self.message_append_note(cr, uid, ids, body=message, context=context) + return self.message_append_note(cr, uid, ids, body=message, subtype="pending", context=context) def set_cancel_send_note(self, cr, uid, ids, context=None): message = _("Project has been cancelled.") - return self.message_append_note(cr, uid, ids, body=message, context=context) + return self.message_append_note(cr, uid, ids, body=message, subtype="cancel", context=context) def set_close_send_note(self, cr, uid, ids, context=None): message = _("Project has been closed.") - return self.message_append_note(cr, uid, ids, body=message, context=context) + return self.message_append_note(cr, uid, ids, body=message, subtype="close", context=context) def write(self, cr, uid, ids, vals, context=None): # if alias_model has been changed, update alias_model_id accordingly @@ -1210,14 +1210,14 @@ class task(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), context=context) + return self.message_append_note(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) def create_send_note(self, cr, uid, ids, context=None): - return self.message_append_note(cr, uid, ids, body=_("Task has been created."), context=context) + return self.message_append_note(cr, uid, ids, body=_("Task has been created."), subtype="new", context=context) def case_draft_send_note(self, cr, uid, ids, context=None): msg = _('Task has been set as draft.') - return self.message_append_note(cr, uid, ids, body=msg, context=context) + return self.message_append_note(cr, uid, ids, body=msg, subtype="draft", context=context) def do_delegation_send_note(self, cr, uid, ids, context=None): for task in self.browse(cr, uid, ids, context=context): diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index c2d37f7943d..77eb203e66b 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -83,6 +83,49 @@ + + + + new + + + + + open + + + + pending + + + + + close + + + + cancel + + + + + stage change + + + + + draft + + + + + + + + + + + From 0135c779a8b3389331d64e03115fc1d4c2cae91a Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 30 Aug 2012 11:59:48 +0530 Subject: [PATCH 045/175] [IMP] Improve code in project demo bzr revid: fka@tinyerp.com-20120830062948-llta7r2pc2ezbjij --- addons/project/project.py | 2 +- addons/project/project_data.xml | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 4f23cbbdc49..66fb81d6fbd 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1217,7 +1217,7 @@ class task(base_stage, osv.osv): def case_draft_send_note(self, cr, uid, ids, context=None): msg = _('Task has been set as draft.') - return self.message_append_note(cr, uid, ids, body=msg, subtype="draft", context=context) + return self.message_append_note(cr, uid, ids, body=msg, context=context) def do_delegation_send_note(self, cr, uid, ids, context=None): for task in self.browse(cr, uid, ids, context=context): diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index 77eb203e66b..f6f2af7953c 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -113,10 +113,6 @@ - - draft - - From 9e067bc26eb63c6a8658a4ab412c636ee3bfdcdc Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 30 Aug 2012 14:54:43 +0530 Subject: [PATCH 046/175] [IMP] Add demo data of subtype in sale bzr revid: fka@tinyerp.com-20120830092443-4ptms30neaz4xjnv --- addons/sale/sale.py | 10 +++++----- addons/sale/sale_data.xml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index c525ba04df1..fdffdf465c9 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1031,7 +1031,7 @@ class sale_order(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), subtype="new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -1039,7 +1039,7 @@ class sale_order(osv.osv): def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype="cancel", context=context) def delivery_send_note(self, cr, uid, ids, picking_id, context=None): for order in self.browse(cr, uid, ids, context=context): @@ -1051,15 +1051,15 @@ class sale_order(osv.osv): self.message_append_note(cr, uid, [order.id], body=_("Delivery Order %s scheduled for %s.") % (picking.name, picking_date_str), context=context) def delivery_end_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("Order delivered."), context=context) + self.message_append_note(cr, uid, ids, body=_("Order delivered."), subtype="delivered", context=context) def invoice_paid_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("Invoice paid."), context=context) + self.message_append_note(cr, uid, ids, body=_("Invoice paid."), subtype="paid", context=context) def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), context=context) + self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype="pending", context=context) def action_cancel_draft_send_note(self, cr, uid, ids, context=None): return self.message_append_note(cr, uid, ids, body='Sale order has been set in draft.', context=context) diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml index bbee9ca7455..974b3dd4490 100644 --- a/addons/sale/sale_data.xml +++ b/addons/sale/sale_data.xml @@ -49,5 +49,38 @@ If you need to manage your sales pipeline (leads, opportunities, phonecalls), you can install the module <i>CRM</i> from the top menu Settings. + + + new + + + + + cancel + + + + + paid + + + + pending + + + + + delivered + + + + + + + + + + + From 1e6099d7136739d3ba415968e5cc6461c6179961 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 30 Aug 2012 17:00:37 +0530 Subject: [PATCH 047/175] [IMP] Add data of subtype in purchase & purchase_requisition bzr revid: fka@tinyerp.com-20120830113037-7t4raly1gf4a3uoh --- addons/purchase/purchase.py | 10 +++--- addons/purchase/purchase_data.xml | 32 +++++++++++++++++++ .../purchase_requisition.py | 8 ++--- .../purchase_requisition_data.xml | 19 +++++++++++ 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 756016d39e2..1dfcc8a3f46 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -744,7 +744,7 @@ class purchase_order(osv.osv): return res + ['validator'] def create_send_note(self, cr, uid, ids, context=None): - return self.message_append_note(cr, uid, ids, body=_("Request for quotation created."), context=context) + return self.message_append_note(cr, uid, ids, body=_("Request for quotation created."), subtype="new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -762,20 +762,20 @@ class purchase_order(osv.osv): def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), context=context) + self.message_append_note(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype="pending", context=context) def shipment_done_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("""Shipment received."""), context=context) + self.message_append_note(cr, uid, ids, body=_("""Shipment received."""), subtype="received", context=context) def invoice_done_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("Invoice paid."), context=context) + self.message_append_note(cr, uid, ids, body=_("Invoice paid."), subtype="paid", context=context) def draft_send_note(self, cr, uid, ids, context=None): return self.message_append_note(cr, uid, ids, body=_("Purchase Order has been set to draft."), context=context) def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype="cancel", context=context) purchase_order() diff --git a/addons/purchase/purchase_data.xml b/addons/purchase/purchase_data.xml index 75074d4cedf..41ff7dd59ac 100644 --- a/addons/purchase/purchase_data.xml +++ b/addons/purchase/purchase_data.xml @@ -48,5 +48,37 @@ You can also manage purchase requisitions, see the Purchase Settings. model="ir.values" name="set"/> + + new + + + + + paid + + + + pending + + + + + received + + + + cancel + + + + + + + + + + + + diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index cf0294730a7..084701ff52e 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -94,13 +94,13 @@ class purchase_requisition(osv.osv): self.message_append_note(cr, uid, ids, body=_("Draft Requisition has been sent to suppliers."), context=context) def reset_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), context=context) + self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype="new", context=context) def done_to_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been done."), context=context) + self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype="close", context=context) def cancel_send_note(self, cr, uid, ids, context=None): - self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), context=context) + self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), subtype="cancel", context=context) def _planned_date(self, requisition, delay=0.0): company = requisition.company_id @@ -184,7 +184,7 @@ class purchase_requisition(osv.osv): return res def create_send_note(self, cr, uid, ids, context=None): - return self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been created."), context=context) + return self.message_append_note(cr, uid, ids, body=_("Purchase Requisition has been created."), subtype="new", context=context) def create(self, cr, uid, vals, context=None): requisition = super(purchase_requisition, self).create(cr, uid, vals, context=context) diff --git a/addons/purchase_requisition/purchase_requisition_data.xml b/addons/purchase_requisition/purchase_requisition_data.xml index 98591535f91..211f51374dd 100644 --- a/addons/purchase_requisition/purchase_requisition_data.xml +++ b/addons/purchase_requisition/purchase_requisition_data.xml @@ -6,5 +6,24 @@ id="purchase_default_set" model="ir.values" name="set"/> + + close + + + + + + + + + + + + + + + + + \ No newline at end of file From 1dd00e9116a1b37469a97064ce74f0e75c904aff Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Thu, 30 Aug 2012 18:19:47 +0530 Subject: [PATCH 048/175] [IMP]Add data of the subtype in accouting modules bzr revid: rma@tinyerp.com-20120830124947-xxkah5za90oa5tuy --- addons/account/account_invoice.py | 6 ++--- addons/account/data/account_data.xml | 26 ++++++++++++++++--- addons/account_voucher/account_voucher.py | 6 ++--- .../account_voucher/account_voucher_data.xml | 23 ++++++++++++++++ addons/analytic/analytic.py | 2 +- 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 7bc9ceaaf61..57606ba46fb 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1297,15 +1297,15 @@ class account_invoice(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), context=context) + self.message_append_note(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), subtype="new", context=context) def confirm_paid_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), subtype="paid", context=context) def invoice_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype="cancel", context=context) account_invoice() diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index e8899d0348a..589683055d8 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -563,8 +563,28 @@ Invoice account.invoice - - - + + new + + + + + paid + + + + cancel + + + + + + + + + + + + diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 223705af85e..ee57368e509 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1293,17 +1293,17 @@ class account_voucher(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s created." % self._document_type[obj.type or False] - self.message_append_note(cr, uid, [obj.id], body=message, context=context) + self.message_append_note(cr, uid, [obj.id], body=message, subtype="new", context=context) def post_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s '%s' is posted." % (self._document_type[obj.type or False], obj.move_id.name) - self.message_append_note(cr, uid, [obj.id], body=message, context=context) + self.message_append_note(cr, uid, [obj.id], body=message, subtype="post", context=context) def reconcile_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s reconciled." % self._document_type[obj.type or False] - self.message_append_note(cr, uid, [obj.id], body=message, context=context) + self.message_append_note(cr, uid, [obj.id], body=message, subtype="reconcile", context=context) account_voucher() diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index 8be2851a434..76e4d7b1849 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -12,5 +12,28 @@ You can track customer payments easily and automate the reminders. You get an ov If you want to use advanced accounting features, you should install the "Accounting and Finance" module. + + + + + + post + + + + + reconcile + + + + + + + + + + + + diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index 7eeb9266e47..60d2731fe9d 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -297,7 +297,7 @@ class account_analytic_account(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), context=context) + self.message_append_note(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), subtype="new", context=context) account_analytic_account() From 88adf5a68e404a2ed95f18189e8b5e277aa203ff Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 31 Aug 2012 10:26:36 +0530 Subject: [PATCH 049/175] [IMP]improve code as per changes in mail message bzr revid: sgo@tinyerp.com-20120831045636-5p1oa9lkhglyd6on --- addons/mail/mail_message.py | 16 ++++++++++------ addons/mail/mail_thread.py | 1 - 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index af6a5cdbb2a..147f4f2d02c 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -330,19 +330,23 @@ class mail_message(osv.Model): """ Add the related record followers to the destination partner_ids. Call mail_notification.notify to manage the email sending """ + followers_obj = self.pool.get('mail.followers') message = self.browse(cr, uid, newid, context=context) + followers_ids = followers_obj.search(cr, uid, ['&', ('res_model', '=', message.model), ('res_id', 'in', [message.res_id])], context=context) + # check with subtype + is_subtype = False + + for subscription in followers_obj.browse(cr, uid, followers_ids, context=context): + if subtype_id: + if subtype_id in [subtype.id for subtype in subscription.subtype_ids]: + is_subtype = True partners_to_notify = [] # add all partner_ids of the message - is_subtype = False if message.partner_ids: for partner in message.partner_ids: if partner.id not in partners_to_notify: - if subtype_id: - if subtype_id in [subtype.id for subtype in subscription.subtype_ids]: - is_subtype = False + if(is_subtype): partners_to_notify.append(partner.id) - else: - partners_to_notify.append(partner.id) # add all followers and set them as partner_ids if message.model and message.res_id: modobj = self.pool.get(message.model) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 28286783f39..a100a8f1b84 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -652,7 +652,6 @@ class mail_thread(osv.Model): :param partner_ids: a list of partner_ids to subscribe :param return: new value of followers, for Chatter """ - print "message_subscribe",subtype_ids self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') From 82f0465b30d5be8089867789372b8721f62b9864 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 10:33:58 +0530 Subject: [PATCH 050/175] [IMP] Add data of subtype in stock bzr revid: fka@tinyerp.com-20120831050358-fg7r75e0og1myke6 --- addons/stock/stock.py | 10 +++++----- addons/stock/stock_data.xml | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 006af587c1f..5e8b5dfaf5d 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1379,13 +1379,13 @@ class stock_picking(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), subtype="new", context=context) def scrap_send_note(self, cr, uid, ids, quantity, uom, name, context=None): - return self.message_post(cr, uid, ids, body= _("%s %s %s has been moved to scrap.") % (quantity, uom, name), context=context) + return self.message_post(cr, uid, ids, body= _("%s %s %s has been moved to scrap.") % (quantity, uom, name), subtype="moved", context=context) def back_order_send_note(self, cr, uid, ids, back_name, context=None): - return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), context=context) + return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), subtype="new", context=context) def ship_done_send_note(self, cr, uid, ids, context=None): type_dict = { @@ -1394,11 +1394,11 @@ class stock_picking(osv.osv): 'internal': 'moved', } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), context=context) + self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype="close", context=context) def ship_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype="cancel", context=context) stock_picking() diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index 282929ea6fb..f8fd499e311 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -164,5 +164,32 @@ + + + + + + + moved + + + + close + + + + + + + + + + + + + + From d25ac32d1bb102a918044bee433751a161de44e9 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 11:16:14 +0530 Subject: [PATCH 051/175] [IMP] improve code: add stock.move object bzr revid: fka@tinyerp.com-20120831054614-41w4jus1rjki1tg6 --- addons/stock/stock_data.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index f8fd499e311..72c9be96b16 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -183,13 +183,13 @@ - + - + - + From 6e8660a776fdf582535776eb5b199cd256822961 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 12:05:24 +0530 Subject: [PATCH 052/175] [IMP] Add data of subtype in idea bzr revid: fka@tinyerp.com-20120831063524-bnvxkie4tgsjxjsq --- addons/idea/idea.py | 8 ++++---- addons/idea/idea_data.xml | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/addons/idea/idea.py b/addons/idea/idea.py index e2e5ec50ddf..a20ddf51414 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -67,21 +67,21 @@ class idea_idea(osv.osv): def idea_cancel(self, cr, uid, ids, context={}): self.write(cr, uid, ids, { 'state': 'cancel' }) - self.message_post(cr, uid, ids, body=_('Idea canceled.'), context=context) + self.message_post(cr, uid, ids, body=_('Idea canceled.'), subtype="cancel", context=context) return True def idea_open(self, cr, uid, ids, context={}): self.write(cr, uid, ids, { 'state': 'open'}) - self.message_post(cr, uid, ids, body=_('Idea accepted.'), context=context) + self.message_post(cr, uid, ids, body=_('Idea accepted.'), subtype="open", context=context) return True def idea_close(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea done.'), context=context) + self.message_post(cr, uid, ids, body=_('Idea done.'), subtype="close", context=context) self.write(cr, uid, ids, { 'state': 'close' }) return True def idea_draft(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), context=context) + self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), subtype="new", context=context) self.write(cr, uid, ids, { 'state': 'draft' }) return True idea_idea() diff --git a/addons/idea/idea_data.xml b/addons/idea/idea_data.xml index d63eb907ef8..a4cd4970511 100644 --- a/addons/idea/idea_data.xml +++ b/addons/idea/idea_data.xml @@ -15,6 +15,35 @@ + + + + new + + + + + open + + + + cancel + + + + + close + + + + + + + + + + + From d993e47c007e7e1ee363d6f81e5e6999741b3dff Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 31 Aug 2012 14:12:35 +0530 Subject: [PATCH 053/175] [IMP]if subtype not selected should not b show in wall bzr revid: sgo@tinyerp.com-20120831084235-0pbgui7w4d62c4ip --- addons/mail/mail_message.py | 29 ++++++++----------- addons/mail/static/src/xml/mail_followers.xml | 2 +- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 563e6d2ef6f..c0ae16dc503 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -323,37 +323,32 @@ class mail_message(osv.Model): values['message_id'] = tools.generate_tracking_message_id('%(model)s-%(res_id)s'% values) newid = super(mail_message, self).create(cr, uid, values, context) self.check(cr, uid, [newid], mode='create', context=context) - self.notify(cr, uid, newid, values.get('subtype_id',False), context=context) + self.notify(cr, uid, newid, context=context) return newid - def notify(self, cr, uid, newid,subtype_id=None, context=None): + def notify(self, cr, uid, newid, context=None): """ Add the related record followers to the destination partner_ids. Call mail_notification.notify to manage the email sending """ - followers_obj = self.pool.get('mail.followers') + followers_obj = self.pool.get("mail.followers") message = self.browse(cr, uid, newid, context=context) - followers_ids = followers_obj.search(cr, uid, ['&', ('res_model', '=', message.model), ('res_id', 'in', [message.res_id])], context=context) - # check with subtype - is_subtype = False - - for subscription in followers_obj.browse(cr, uid, followers_ids, context=context): - if subtype_id: - if subtype_id in [subtype.id for subtype in subscription.subtype_ids]: - is_subtype = True partners_to_notify = set([]) # add all partner_ids of the message if message.partner_ids: - if(is_subtype): - partners_to_notify |= set(partner.id for partner in message.partner_ids) + partners_to_notify |= set(partner.id for partner in message.partner_ids) # add all followers and set add them in partner_ids if message.model and message.res_id: record = self.pool.get(message.model).browse(cr, uid, message.res_id, context=context) extra_notified = set(partner.id for partner in record.message_follower_ids) missing_notified = extra_notified - partners_to_notify - if missing_notified: - message.write({'partner_ids': [(4, p_id) for p_id in missing_notified]}) - if(is_subtype): - partners_to_notify |= extra_notified + missing_follow_ids = [] + if message.subtype_id: + for p_id in missing_notified: + follow_ids = followers_obj.search(cr, uid, [('partner_id','=',p_id),('subtype_ids','in',[message.subtype_id.id]),('res_model','=',message.model),('res_id','=',message.res_id)]) + if follow_ids and len(follow_ids): + missing_follow_ids.append(p_id) + message.write({'partner_ids': [(4, p_id) for p_id in missing_follow_ids]}) + partners_to_notify |= extra_notified self.pool.get('mail.notification').notify(cr, uid, list(partners_to_notify), newid, context=context) def read(self, cr, uid, ids, fields_to_read=None, context=None, load='_classic_read'): diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 6960e2a3b5f..66173dd47ee 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -10,11 +10,11 @@
              +

                -
                    From 5eed2be266d4dd2d12280ba06b467f3fd54387be Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 31 Aug 2012 14:40:43 +0530 Subject: [PATCH 054/175] [IMP]minor changes bzr revid: sgo@tinyerp.com-20120831091043-4rix3ozakssbxrgn --- 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 abe5c296218..972227e120f 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -577,7 +577,7 @@ class mail_thread(osv.Model): self.message_post(cr, uid, [id], message, context=context) def message_post(self, cr, uid, thread_id, body='', subject=False, - msg_type='notification', parent_id=False, attachments=None, context=None, **kwargs): + msg_type='notification', parent_id=False, attachments=None, subtype='other', context=None, **kwargs): """ Post a new message in an existing message thread, returning the new mail.message ID. Extra keyword arguments will be used as default column values for the new mail.message record. From ca22d79a2107d943f1484728cdda7b6d37f43826 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 14:42:06 +0530 Subject: [PATCH 055/175] [IMP] Add data of subtype in procurement bzr revid: fka@tinyerp.com-20120831091206-196wzqlatj7lryi0 --- addons/procurement/procurement.py | 12 ++++----- addons/procurement/procurement_data.xml | 34 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index db50ebd94fd..4c60316ffb6 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -496,22 +496,22 @@ class procurement_order(osv.osv): return obj_id def create_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been created."), context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been created."), subtype="new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been confirmed."), context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been confirmed."), subtype="confirmed", context=context) def running_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been set to running."), context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been set to running."), subtype="running", context=context) def ready_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), subtype="ready", context=context) def cancel_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype="cancel", context=context) def done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been done."), context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype="close", context=context) procurement_order() diff --git a/addons/procurement/procurement_data.xml b/addons/procurement/procurement_data.xml index 6a83d525c68..bbcaa33d2a1 100644 --- a/addons/procurement/procurement_data.xml +++ b/addons/procurement/procurement_data.xml @@ -28,5 +28,39 @@ 1 1 + + + + + + + confirmed + + + + ready + + + + running + + + + + + + + + + + + + + + + + \ No newline at end of file From 17ef40f428cbe12358e5bd54efa3c66ecf8e1b0c Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Fri, 31 Aug 2012 15:30:12 +0530 Subject: [PATCH 056/175] [IMP]add the data into event for subtype bzr revid: rma@tinyerp.com-20120831100012-mlzik593orznp9aj --- addons/event/__openerp__.py | 1 + addons/event/event.py | 20 ++++++++++---------- addons/event/event_data.xml | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/addons/event/__openerp__.py b/addons/event/__openerp__.py index 1e548f68991..428ebb4cb06 100644 --- a/addons/event/__openerp__.py +++ b/addons/event/__openerp__.py @@ -46,6 +46,7 @@ Note that: 'data': [ 'security/event_security.xml', 'security/ir.model.access.csv', + 'event_data.xml', 'wizard/event_confirm_view.xml', 'event_view.xml', 'report/report_event_registration_view.xml', diff --git a/addons/event/event.py b/addons/event/event.py index 763aa423378..c3284695ab9 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -264,27 +264,27 @@ class event_event(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Event has been created.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="new", context=context) return True def button_cancel_send_note(self, cr, uid, ids, context=None): message = _("Event has been cancelled.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="cancel", context=context) return True def button_draft_send_note(self, cr, uid, ids, context=None): message = _("Event has been set to draft.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="new", context=context) return True def button_done_send_note(self, cr, uid, ids, context=None): message = _("Event has been done.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="close", context=context) return True def button_confirm_send_note(self, cr, uid, ids, context=None): message = _("Event has been confirmed.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="confirm", context=context) return True event_event() @@ -331,7 +331,7 @@ class event_registration(osv.osv): def confirm_registration(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_('State set to open'), context=context) - return self.write(cr, uid, ids, {'state': 'open'}, context=context) + return self.write(cr, uid, ids, {'state': 'open'}, subtype="open", context=context) def create(self, cr, uid, vals, context=None): obj_id = super(event_registration, self).create(cr, uid, vals, context) @@ -360,13 +360,13 @@ class event_registration(osv.osv): if today >= registration.event_id.date_begin: values = {'state': 'done', 'date_closed': today} self.write(cr, uid, ids, values) - self.message_post(cr, uid, ids, body=_('State set to Done'), context=context) + self.message_post(cr, uid, ids, body=_('State set to Done'), subtype="close", context=context) else: raise osv.except_osv(_('Error!'),_("You must wait for the starting day of the event to do this action.") ) return True def button_reg_cancel(self, cr, uid, ids, context=None, *args): - self.message_post(cr, uid, ids, body=_('State set to Cancel'), context=context) + self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype="cancel", context=context) return self.write(cr, uid, ids, {'state': 'cancel'}) def mail_user(self, cr, uid, ids, context=None): @@ -436,12 +436,12 @@ class event_registration(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Registration has been created.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="new", context=context) return True def do_draft_send_note(self, cr, uid, ids, context=None): message = _("Registration has been set as draft.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="new", context=context) return True event_registration() diff --git a/addons/event/event_data.xml b/addons/event/event_data.xml index 83af2f35cfb..0498d3e490b 100644 --- a/addons/event/event_data.xml +++ b/addons/event/event_data.xml @@ -12,6 +12,38 @@ automatic 100 + + new + + + + + close + + + + cancel + + + + + confirm + + + + + open + + + + + + + + + + + @@ -20,5 +52,6 @@ From the top menu Events, you can organize events, manage registrations, automate communication around your event and sell events through your quotations. Module Events Organisation has been installed + From 90e55a5337694a15131bfac9a3d705ee25723052 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 31 Aug 2012 15:33:18 +0530 Subject: [PATCH 057/175] [IMP]remove unused method and improve code bzr revid: sgo@tinyerp.com-20120831100318-t2e2wv81trwfpc7u --- addons/mail/mail_thread.py | 6 +++--- addons/mail/static/src/js/mail_followers.js | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 972227e120f..2d31a9ad3ba 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -711,8 +711,8 @@ class mail_thread(osv.Model): return True def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): - subscription_obj = self.pool.get('mail.followers') - subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) - return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one + followers_obj = self.pool.get('mail.followers') + followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) + return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 1601f3aaf46..fc9223b3657 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -40,11 +40,7 @@ openerp_mail_followers = function(session, mail) { this._check_visibility(); this.fetch_subtype(); this.$el.find('ul.oe_mail_recthread_subtype').click(function () {self.update_subtype();}) - this.$el.find('button.oe_mail_button_follow').click(function () { - self.do_follow(); - self.fetch_subtype(); - }) - this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); }) + this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); self.fetch_subtype();}) .mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.$el.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); }) From a6a3d4eda6427fc1470e1bfd8408ba90581ad9e9 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 16:10:32 +0530 Subject: [PATCH 058/175] [IMP] set indentation in purchase_requisition.xml bzr revid: fka@tinyerp.com-20120831104032-yfuugotohlgfvz75 --- .../purchase_requisition_data.xml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/addons/purchase_requisition/purchase_requisition_data.xml b/addons/purchase_requisition/purchase_requisition_data.xml index 211f51374dd..11ac73a6dd2 100644 --- a/addons/purchase_requisition/purchase_requisition_data.xml +++ b/addons/purchase_requisition/purchase_requisition_data.xml @@ -6,17 +6,18 @@ id="purchase_default_set" model="ir.values" name="set"/> - + + close - - - - - - - + + + + + + + From 31064b1855a60bf211c4a6f0abcb304865ee692e Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Fri, 31 Aug 2012 16:11:43 +0530 Subject: [PATCH 059/175] fix data bzr revid: apa@tinyerp.com-20120831104143-1ymb932kpng3bu3z --- addons/sale/sale_data.xml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml index a9c0e18a415..fceb806b3a2 100644 --- a/addons/sale/sale_data.xml +++ b/addons/sale/sale_data.xml @@ -41,14 +41,13 @@ - - mail.group - - notification - Sales Management application installed! - This application lets you create and send quotations and process your sales orders; from delivery to invoicing. -If you need to manage your sales pipeline (leads, opportunities, phonecalls), you can install the module <i>CRM</i> from the top menu Settings.
                    + + + The Sales Management application has been installed. + This modules allows you to create and send easily quotations and process your sales orders; from the delivery to the invoicing. + +If you need to manage your sales pipeline (leads, opportunities, phonecalls), you can install the module <i>CRM</i> from the top menu Settings. From 139ee97562ec45549e35ac747bd6c2ae53360c58 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Fri, 31 Aug 2012 16:15:40 +0530 Subject: [PATCH 060/175] typo bzr revid: apa@tinyerp.com-20120831104540-oixjx4jpknk5hlcc --- addons/sale/sale_data.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml index fceb806b3a2..a23ab401dbd 100644 --- a/addons/sale/sale_data.xml +++ b/addons/sale/sale_data.xml @@ -56,7 +56,7 @@ If you need to manage your sales pipeline (leads, opportunities, phonecalls), yo - cancel + cancelled From 1100d6b1cceb2cf74edf3b68f19d1a74b1c35c0c Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Fri, 31 Aug 2012 16:21:17 +0530 Subject: [PATCH 061/175] typo bzr revid: apa@tinyerp.com-20120831105117-mjm99cs7ko8pmkfq --- addons/sale/sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 9628c4fdc91..a407be80c99 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1035,7 +1035,7 @@ class sale_order(osv.osv): def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype="cancel", context=context) + self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype="cancelled", context=context) def delivery_send_note(self, cr, uid, ids, picking_id, context=None): for order in self.browse(cr, uid, ids, context=context): From d621d8fae3ca98ccd0cfffd56413459421069655 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 16:24:22 +0530 Subject: [PATCH 062/175] [IMP] improve code bzr revid: fka@tinyerp.com-20120831105422-m2unzh8mezt4oan4 --- addons/stock/stock.py | 2 +- addons/stock/stock_data.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 5e8b5dfaf5d..3011fc6c6c2 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1398,7 +1398,7 @@ class stock_picking(osv.osv): def ship_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype="cancel", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype="cancelled", context=context) stock_picking() diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index a24502ab361..976c89ad06f 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -181,7 +181,7 @@ watch your stock valuation, and track production lots upstream and downstream (b close - + From 6c04925c0f3521a5a99586f688727f2be5f6340b Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 16:28:55 +0530 Subject: [PATCH 063/175] [IMP] improve code bzr revid: fka@tinyerp.com-20120831105855-crs13rnqi2uztgha --- addons/purchase/purchase.py | 2 +- addons/purchase/purchase_data.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 81b851eb2a2..16b827c1323 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -766,7 +766,7 @@ class purchase_order(osv.osv): def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype="cancel", context=context) + self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype="cancelled", context=context) purchase_order() diff --git a/addons/purchase/purchase_data.xml b/addons/purchase/purchase_data.xml index 1cc3b3b014b..a84564b2360 100644 --- a/addons/purchase/purchase_data.xml +++ b/addons/purchase/purchase_data.xml @@ -67,8 +67,8 @@ You can also manage purchase requisitions, see also the Purchase Settings.received - - cancel + + cancelled From d32908a359dcba66b032ee4dcfca7dd2142b94d6 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Fri, 31 Aug 2012 16:30:00 +0530 Subject: [PATCH 064/175] [IMP]make changes for the calcelled state into event bzr revid: rma@tinyerp.com-20120831110000-cd022yy58aken0iw --- addons/event/event.py | 4 ++-- addons/event/event_data.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/event/event.py b/addons/event/event.py index c3284695ab9..feb0aed9d46 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -269,7 +269,7 @@ class event_event(osv.osv): def button_cancel_send_note(self, cr, uid, ids, context=None): message = _("Event has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype="cancel", context=context) + self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) return True def button_draft_send_note(self, cr, uid, ids, context=None): @@ -366,7 +366,7 @@ class event_registration(osv.osv): return True def button_reg_cancel(self, cr, uid, ids, context=None, *args): - self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype="cancel", context=context) + self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype="cancelled", context=context) return self.write(cr, uid, ids, {'state': 'cancel'}) def mail_user(self, cr, uid, ids, context=None): diff --git a/addons/event/event_data.xml b/addons/event/event_data.xml index 65713628de9..bc16fc08aee 100644 --- a/addons/event/event_data.xml +++ b/addons/event/event_data.xml @@ -21,8 +21,8 @@ close - - cancel + + cancelled From 6c56f95e869f21d5eaecb3c3eda1de831e1d5499 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 16:34:43 +0530 Subject: [PATCH 065/175] [IMP] improve code bzr revid: fka@tinyerp.com-20120831110443-55nxhelq1dfl073j --- addons/idea/idea.py | 2 +- addons/idea/idea_data.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/idea/idea.py b/addons/idea/idea.py index a20ddf51414..ff55e6afbc3 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -67,7 +67,7 @@ class idea_idea(osv.osv): def idea_cancel(self, cr, uid, ids, context={}): self.write(cr, uid, ids, { 'state': 'cancel' }) - self.message_post(cr, uid, ids, body=_('Idea canceled.'), subtype="cancel", context=context) + self.message_post(cr, uid, ids, body=_('Idea canceled.'), subtype="cancelled", context=context) return True def idea_open(self, cr, uid, ids, context={}): diff --git a/addons/idea/idea_data.xml b/addons/idea/idea_data.xml index a4cd4970511..17401f72f98 100644 --- a/addons/idea/idea_data.xml +++ b/addons/idea/idea_data.xml @@ -26,8 +26,8 @@ open - - cancel + + cancelled From 5ec28dcd8933cb8ef42d3349d7651e66b02d46f5 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 16:41:15 +0530 Subject: [PATCH 066/175] [IMP] improve code bzr revid: fka@tinyerp.com-20120831111115-fqoapz8uroxsdddm --- addons/procurement/procurement.py | 2 +- addons/procurement/procurement_data.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 4c60316ffb6..d59a894bc2b 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -508,7 +508,7 @@ class procurement_order(osv.osv): self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), subtype="ready", context=context) def cancel_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype="cancel", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype="cancelled", context=context) def done_send_note(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype="close", context=context) diff --git a/addons/procurement/procurement_data.xml b/addons/procurement/procurement_data.xml index bbcaa33d2a1..8f4e945a7de 100644 --- a/addons/procurement/procurement_data.xml +++ b/addons/procurement/procurement_data.xml @@ -47,7 +47,7 @@ running - + From e5b99dca25aea687272e0e09d73d9ac034acd14c Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 18:11:23 +0530 Subject: [PATCH 067/175] [IMP] change close bzr revid: fka@tinyerp.com-20120831124123-3fq363k7b5bcnuix --- addons/procurement/procurement.py | 2 +- addons/procurement/procurement_data.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index d59a894bc2b..94d83675df1 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -511,7 +511,7 @@ class procurement_order(osv.osv): self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype="cancelled", context=context) def done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype="close", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype="closed", context=context) procurement_order() diff --git a/addons/procurement/procurement_data.xml b/addons/procurement/procurement_data.xml index 8f4e945a7de..bd44f0caee5 100644 --- a/addons/procurement/procurement_data.xml +++ b/addons/procurement/procurement_data.xml @@ -50,7 +50,7 @@ - + From 596debf67e4792755c72b629cd481d7cdb653292 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Fri, 31 Aug 2012 18:17:22 +0530 Subject: [PATCH 068/175] [IMP]make changes into account data for subtype bzr revid: rma@tinyerp.com-20120831124722-2u9fcx10gnrcfsl5 --- addons/account/data/account_data.xml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index 589683055d8..fe0c864e72f 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -518,7 +518,6 @@ - Account Reconcile account.reconcile @@ -554,8 +553,6 @@ - - @@ -563,7 +560,7 @@ Invoice account.invoice - + new From 84fd3b3a35767140a0fcbc0aebb5a4439fcd4e79 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 18:17:44 +0530 Subject: [PATCH 069/175] [IMP] change subtype close bzr revid: fka@tinyerp.com-20120831124744-uup75dwshj5nmf2n --- addons/purchase_requisition/purchase_requisition.py | 2 +- addons/purchase_requisition/purchase_requisition_data.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index 67905f35922..5a5f669b1a1 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -97,7 +97,7 @@ class purchase_requisition(osv.osv): self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype="new", context=context) def done_to_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype="close", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype="closed", context=context) def cancel_send_note(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), subtype="cancel", context=context) diff --git a/addons/purchase_requisition/purchase_requisition_data.xml b/addons/purchase_requisition/purchase_requisition_data.xml index 11ac73a6dd2..11dd5f45170 100644 --- a/addons/purchase_requisition/purchase_requisition_data.xml +++ b/addons/purchase_requisition/purchase_requisition_data.xml @@ -7,8 +7,8 @@ model="ir.values" name="set"/> - - close + + closed From de9f0c9777800cb398afddc8466c6a5c9ea3056e Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 18:22:01 +0530 Subject: [PATCH 070/175] [IMP] change subtype close bzr revid: fka@tinyerp.com-20120831125201-gomz1f0hy8wid1rh --- addons/stock/stock.py | 2 +- addons/stock/stock_data.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 3011fc6c6c2..0bc455a149c 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1394,7 +1394,7 @@ class stock_picking(osv.osv): 'internal': 'moved', } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype="close", context=context) + self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype="closed", context=context) def ship_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index 976c89ad06f..a7e2ffdd562 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -177,8 +177,8 @@ watch your stock valuation, and track production lots upstream and downstream (b moved - - close + + closed From e44d125479d9208d3d2d9b0b64b655b530a07eae Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 31 Aug 2012 18:47:12 +0530 Subject: [PATCH 071/175] [IMP] Add data of subtype in mrp, mrp_repair & mrp_operations bzr revid: fka@tinyerp.com-20120831131712-dz5b5isq797v5xfc --- addons/mrp/mrp.py | 10 ++-- addons/mrp/mrp_data.xml | 33 ++++++++++++++ addons/mrp_operations/mrp_operation_data.xml | 34 ++++++++++++++ addons/mrp_operations/mrp_operations.py | 10 ++-- addons/mrp_repair/__openerp__.py | 1 + addons/mrp_repair/mrp_repair.py | 14 +++--- addons/mrp_repair/mrp_repair_data.xml | 48 ++++++++++++++++++++ 7 files changed, 133 insertions(+), 17 deletions(-) create mode 100644 addons/mrp_repair/mrp_repair_data.xml diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index c667daadbec..a9f6290c58a 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1047,27 +1047,27 @@ class mrp_production(osv.osv): # --------------------------------------------------- def create_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), context=context) + self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), subtype="new", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been canceled.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) return True def action_ready_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is ready to produce.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="ready", context=context) return True def action_in_production_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is in production.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="production", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been done.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) return True def action_confirm_send_note(self, cr, uid, ids, context=None): diff --git a/addons/mrp/mrp_data.xml b/addons/mrp/mrp_data.xml index 0bbf2d3b64c..6ee7cc82dd2 100644 --- a/addons/mrp/mrp_data.xml +++ b/addons/mrp/mrp_data.xml @@ -27,5 +27,38 @@ From the Manufacturing Settings, you can choose to compute production schedules 1 + + new + + + + + ready + + + + + production + + + + cancelled + + + + + closed + + + + + + + + + + + + diff --git a/addons/mrp_operations/mrp_operation_data.xml b/addons/mrp_operations/mrp_operation_data.xml index ff83fdc7e8b..e2d7f9f0a56 100644 --- a/addons/mrp_operations/mrp_operation_data.xml +++ b/addons/mrp_operations/mrp_operation_data.xml @@ -30,5 +30,39 @@ done + + + new + + + + + started + + + + + pending + + + + cancelled + + + + + closed + + + + + + + + + + + + diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index ee2547bc7df..a18eb4141ba 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -224,7 +224,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been created for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype="new", context=context) return True def action_start_send_note(self, cr, uid, ids, context=None): @@ -232,7 +232,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been started for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype="started", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): @@ -240,7 +240,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been done for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype="closed", context=context) return True def action_pending_send_note(self, cr, uid, ids, context=None): @@ -248,7 +248,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order is pending for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype="pending", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): @@ -256,7 +256,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been cancelled for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype="cancelled", context=context) return True mrp_production_workcenter_line() diff --git a/addons/mrp_repair/__openerp__.py b/addons/mrp_repair/__openerp__.py index da4070d6210..13a6e81e141 100644 --- a/addons/mrp_repair/__openerp__.py +++ b/addons/mrp_repair/__openerp__.py @@ -43,6 +43,7 @@ The following topics should be covered by this module: 'data': [ 'security/ir.model.access.csv', 'security/mrp_repair_security.xml', + 'mrp_repair_data.xml', 'mrp_repair_sequence.xml', 'wizard/mrp_repair_cancel_view.xml', 'wizard/mrp_repair_make_invoice_view.xml', diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index c1ac8f809ce..44624044090 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -571,40 +571,40 @@ class mrp_repair(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Repair Order for %s has been created." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype="new", context=context) return True def set_start_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Repair Order for %s has been started." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype="started", context=context) return True def set_toinvoiced_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Draft Invoice of %s %s waiting for validation.") % (repair.invoice_id.amount_total, repair.invoice_id.currency_id.symbol) - self.message_post(cr, uid, [repair.id], body=message, context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype="pending", context=context) return True def set_confirm_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _( "Repair Order for %s has been accepted." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype="accepted", context=context) return True def set_cancel_send_note(self, cr, uid, ids, context=None): message = _("Repair has been cancelled.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) return True def set_ready_send_note(self, cr, uid, ids, context=None): message = _("Repair Order is now ready to repair.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="ready", context=context) return True def set_done_send_note(self, cr, uid, ids, context=None): message = _("Repair Order is closed.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) return True mrp_repair() diff --git a/addons/mrp_repair/mrp_repair_data.xml b/addons/mrp_repair/mrp_repair_data.xml new file mode 100644 index 00000000000..337a4113382 --- /dev/null +++ b/addons/mrp_repair/mrp_repair_data.xml @@ -0,0 +1,48 @@ + + + + + + new + + + + + started + + + + + ready + + + + + pending + + + + accepted + + + + cancelled + + + + + closed + + + + + + + + + + + + + + From aa216774eab92cd4334a9bbbdbf50293b26d5565 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Mon, 3 Sep 2012 11:47:13 +0530 Subject: [PATCH 072/175] [IMP] make changes into account data for the subtype bzr revid: rma@tinyerp.com-20120903061713-xuhcfdqi4e7cp6qf --- addons/account/account_invoice.py | 2 +- addons/account/data/account_data.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index e8e935a9505..5f81cbfe857 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1306,7 +1306,7 @@ class account_invoice(osv.osv): def invoice_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype="cancel", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype="cancelled", context=context) account_invoice() class account_invoice_line(osv.osv): diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index fe0c864e72f..bf3b3152552 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -569,12 +569,12 @@ paid - - cancel + + cancelled - + From 23007e8aebbd269abfbf3f62f27e8cbbcecafb33 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 3 Sep 2012 14:27:28 +0530 Subject: [PATCH 073/175] [IMP] Add picking_in & picking_out object in stock bzr revid: fka@tinyerp.com-20120903085728-vx5hbkug5527nolo --- addons/stock/stock_data.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index a7e2ffdd562..3539d5b5056 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -171,27 +171,27 @@ watch your stock valuation, and track production lots upstream and downstream (b Mail: mail.message.subtype --> - + moved - + closed - + - + - + - + - + From 49722c77c05375ad2f04c716cda3599f1c5bd5e8 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 3 Sep 2012 18:04:05 +0530 Subject: [PATCH 074/175] [IMP] add received & delivered subtype in stock bzr revid: fka@tinyerp.com-20120903123405-7rmte2src1xtdghp --- addons/stock/stock.py | 2 +- addons/stock/stock_data.xml | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 0bc455a149c..ed20bbec2c5 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1394,7 +1394,7 @@ class stock_picking(osv.osv): 'internal': 'moved', } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype="closed", context=context) + self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype=type_dict.get(obj.type), context=context) def ship_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index 3539d5b5056..f83b0ada388 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -171,27 +171,29 @@ watch your stock valuation, and track production lots upstream and downstream (b Mail: mail.message.subtype --> - + - - moved - + + delivered + + - - closed - + + received + + - + - + - + - + From df3aa41ac443d22511dc4cf4732629e109c15ef1 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Tue, 4 Sep 2012 12:47:54 +0530 Subject: [PATCH 075/175] [IMP] add subtype data in hr module bzr revid: rma@tinyerp.com-20120904071754-d99h6iey5nzrjf08 --- addons/hr_holidays/hr_holidays.py | 12 +++--- addons/hr_holidays/hr_holidays_data.xml | 38 +++++++++++++++++++ addons/hr_recruitment/hr_recruitment.py | 14 +++---- addons/hr_recruitment/hr_recruitment_data.xml | 36 +++++++++++++++++- .../hr_timesheet_invoice.py | 8 ++-- .../hr_timesheet_invoice_data.xml | 28 ++++++++++++++ 6 files changed, 118 insertions(+), 18 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 759170224bd..e0358efe0d9 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -364,32 +364,32 @@ class hr_holidays(osv.osv): def create_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, ids, - _("The request has been created and is waiting confirmation."), context=context) + _("The request has been created and is waiting confirmation."),subtype="new", context=context) return True def holidays_confirm_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been submitted and is waiting for validation by the manager."), context=context) + _("The request has been submitted and is waiting for validation by the manager."), subtype="submitted", context=context) def holidays_first_validate_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, [obj.id], - _("The request has been approved. A second validation is necessary and is now pending."), context=context) + _("The request has been approved. A second validation is necessary and is now pending."), subtype="pending", context=context) def holidays_validate_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): if obj.double_validation: self.message_post(cr, uid, [obj.id], - _("The request has been double validated. The validation process is now over."), context=context) + _("The request has been double validated. The validation process is now over."), subtype="double validated", context=context) else: self.message_post(cr, uid, [obj.id], - _("The request has been approved. The validation process is now over."), context=context) + _("The request has been approved. The validation process is now over."), subtype="closed", context=context) def holidays_refuse_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been refused. The validation process is now over."), context=context) + _("The request has been refused. The validation process is now over."), subtype="cancelled", context=context) class resource_calendar_leaves(osv.osv): diff --git a/addons/hr_holidays/hr_holidays_data.xml b/addons/hr_holidays/hr_holidays_data.xml index 1e534093eb3..3b927b60419 100644 --- a/addons/hr_holidays/hr_holidays_data.xml +++ b/addons/hr_holidays/hr_holidays_data.xml @@ -49,5 +49,43 @@ Once validated, they are visible in the employee's calendar. HR officers can def True brown + + + new + + + + + submitted + + + + + pending + + + + + double validated + + + + closed + + + + cancelled + + + + + + + + + + + + diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 82f2c9c3a21..578ebde9162 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -457,14 +457,14 @@ class hr_applicant(base_stage, osv.Model): """ Override of the (void) default notification method. """ if not stage_id: return True stage_name = self.pool.get('hr.recruitment.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): return 'Applicant' def case_open_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been set in progress.") - return self.message_post(cr, uid, ids, body=message, context=context) + return self.message_post(cr, uid, ids, body=message, subtype="in progress", context=context) def case_close_send_note(self, cr, uid, ids, context=None): if context is None: @@ -472,23 +472,23 @@ class hr_applicant(base_stage, osv.Model): for applicant in self.browse(cr, uid, ids, context=context): if applicant.emp_id: message = _("Applicant has been hired and created as an employee.") - self.message_post(cr, uid, [applicant.id], body=message, context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype="closed", context=context) else: message = _("Applicant has been hired.") - self.message_post(cr, uid, [applicant.id], body=message, context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype="closed", context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): msg = 'Applicant refused.' - return self.message_post(cr, uid, ids, body=msg, context=context) + return self.message_post(cr, uid, ids, body=msg, subtype="cancelled", context=context) def case_reset_send_note(self, cr, uid, ids, context=None): message =_("Applicant has been set as new.") - return self.message_post(cr, uid, ids, body=message, context=context) + return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) def create_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been created.") - return self.message_post(cr, uid, ids, body=message, context=context) + return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) class hr_job(osv.osv): diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index 84289da7bae..a567489751a 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -460,6 +460,40 @@ You can automatically receive job application though an email gateway, see the H - + + + + new + + + + + closed + + + + cancelled + + + + + stage change + + + + + in progress + + + + + + + + + + + + diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index a1562d53a61..4ed61119a5f 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -95,25 +95,25 @@ class account_analytic_account(osv.osv): def set_close(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'close'}, context=context) message = _("Contract has been closed.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) return True def set_cancel(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'cancelled'}, context=context) message = _("Contract has been cancelled.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) return True def set_open(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'open'}, context=context) message = _("Contract has been opened.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="open", context=context) return True def set_pending(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'pending'}, context=context) message = _("Contract has been set as pending.") - self.message_post(cr, uid, ids, body=message, context=context) + self.message_post(cr, uid, ids, body=message, subtype="pending", context=context) return True account_analytic_account() diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml index 462888e0b39..5cc5024d591 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml @@ -16,5 +16,33 @@ 50% 50.0 + + + closed + + + + pending + + + + + open + + + + cancelled + + + + + + + + + + + + From 61118d78473a91cdc13ef753c5509fdf62d25e63 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Tue, 4 Sep 2012 14:26:26 +0530 Subject: [PATCH 076/175] [IMP] add subtype data into project and project_issue module bzr revid: rma@tinyerp.com-20120904085626-klbtc8hrrksi4gy9 --- addons/project/project.py | 4 +-- addons/project/project_data.xml | 8 +++--- addons/project_issue/project_issue.py | 6 ++--- addons/project_issue/project_issue_data.xml | 27 ++++++++++++++++++++- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index ae70dcc1dd4..26e42a73539 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -525,11 +525,11 @@ def Project(): def set_cancel_send_note(self, cr, uid, ids, context=None): message = _("Project has been cancelled.") - return self.message_post(cr, uid, ids, body=message, subtype="cancel", context=context) + return self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) def set_close_send_note(self, cr, uid, ids, context=None): message = _("Project has been closed.") - return self.message_post(cr, uid, ids, body=message, subtype="close", context=context) + return self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) def write(self, cr, uid, ids, vals, context=None): # if alias_model has been changed, update alias_model_id accordingly diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index 88afc08b961..c2e51fa8049 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -99,12 +99,12 @@ - - close + + closed - - cancel + + cancelled diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 9cc97ec470b..52bb2d2d687 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -500,7 +500,7 @@ class project_issue(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): """ Override of default prefix for notifications. """ @@ -508,11 +508,11 @@ class project_issue(base_stage, osv.osv): def convert_to_task_send_note(self, cr, uid, ids, context=None): message = _("Project issue converted to task.") - return self.message_post(cr, uid, ids, body=message, context=context) + return self.message_post(cr, uid, ids, body=message, subtype="converted", context=context) def create_send_note(self, cr, uid, ids, context=None): message = _("Project issue created.") - return self.message_post(cr, uid, ids, body=message, context=context) + return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) def case_escalate_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml index ddb0d575e63..2501bd821d2 100644 --- a/addons/project_issue/project_issue_data.xml +++ b/addons/project_issue/project_issue_data.xml @@ -30,7 +30,32 @@ v3.0 - + + + + new + + + + + stage change + + + + + converted + + + + + + + + + + + + mail.group From 93f5c6b6a9265e30c7b7addb7eceeef57dbb7fb6 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Tue, 4 Sep 2012 15:01:11 +0530 Subject: [PATCH 077/175] [IMP]add unit test for message subtype bzr revid: sgo@tinyerp.com-20120904093111-hj291blbbkg39cey --- addons/mail/mail_thread.py | 1 - addons/mail/tests/test_mail.py | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 2d31a9ad3ba..241e6674b17 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -656,7 +656,6 @@ class mail_thread(osv.Model): subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)]) if subtype_ids: self.message_subscribe_udpate_subtypes(cr, uid, ids, partner_ids, subtype_ids, context=context) - # TDE: temp, must check followers widget return [] # return [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index fd4b116b364..c27b3c6f68e 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -83,6 +83,7 @@ class test_mail(common.TransactionCase): self.mail_message = self.registry('mail.message') self.mail_notification = self.registry('mail.notification') self.mail_followers = self.registry('mail.followers') + self.mail_message_subtype = self.registry('mail.message.subtype') self.res_users = self.registry('res.users') self.res_partner = self.registry('res.partner') @@ -534,3 +535,37 @@ class test_mail(common.TransactionCase): msg1.refresh() self.assertEqual(5, len(group_pigs.message_ids), 'group should contain 5 messages') self.assertEqual(2, len(msg1.child_ids), 'msg1 should have 2 children now') + + def test_60_message_subtype(self): + """ Tests designed for message_subtype. """ + cr, uid = self.cr, self.uid + self.res_users.write(cr, uid, [uid], {'signature': 'Admin', 'email': 'a@a'}) + user_admin = self.res_users.browse(cr, uid, uid) + group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) + + # 0 - Admin + p_a_id = user_admin.partner_id.id + # Subscribe #1, + self.mail_group_model_id = self.ir_model.search(cr, uid, [('model','=', 'mail.group')])[0] + subtype_ids = self.mail_message_subtype.search(cr, uid, []) + self.mail_message_subtype.write(cr,uid,subtype_ids,{'model_ids':[(4,self.mail_group_model_id )]}) + group_pigs.message_subscribe_users([uid]) + + # Mail data + _subject = 'Pigs' + _mail_subject = '%s posted on %s' % (user_admin.name, group_pigs.name) + _body1 = 'Pigs rules' + _mail_body1 = 'Pigs rules\n
                    Admin
                    \n' + _mail_bodyalt1 = 'Pigs rules\nAdmin' + _body2 = 'Pigs rules' + _mail_body2 = 'Pigs rules\n
                    Admin
                    \n' + _mail_bodyalt2 = 'Pigs rules\nAdmin\n' + filter_subtype_id = self.mail_message_subtype.search(cr, uid, [('default','=',True)]) + # Post comment with body and subject, comment preference + msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, msg_type='comment',subtype='email') + notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) + self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") + # New post: test automatic subject, signature in html, add a partner, email preference, parent_id previous message + msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, msg_type='email', subtype='other') + notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) + self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") From e50afb97b4f2c5183fc5d60db5736ed822a2710f Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Tue, 4 Sep 2012 15:10:52 +0530 Subject: [PATCH 078/175] [IMP] make changes into hr module for subtype data bzr revid: rma@tinyerp.com-20120904094052-5povh2fua010g3ej --- addons/hr_holidays/hr_holidays.py | 10 ++++----- addons/hr_holidays/hr_holidays_data.xml | 22 ++++--------------- addons/hr_recruitment/hr_recruitment.py | 4 ++-- addons/hr_recruitment/hr_recruitment_data.xml | 8 +++---- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index e0358efe0d9..4136abbb2f7 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -370,26 +370,26 @@ class hr_holidays(osv.osv): def holidays_confirm_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been submitted and is waiting for validation by the manager."), subtype="submitted", context=context) + _("The request has been submitted and is waiting for validation by the manager."), context=context) def holidays_first_validate_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, [obj.id], - _("The request has been approved. A second validation is necessary and is now pending."), subtype="pending", context=context) + _("The request has been approved. A second validation is necessary and is now pending."), context=context) def holidays_validate_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): if obj.double_validation: self.message_post(cr, uid, [obj.id], - _("The request has been double validated. The validation process is now over."), subtype="double validated", context=context) + _("The request has been double validated. The validation process is now over."), context=context) else: self.message_post(cr, uid, [obj.id], - _("The request has been approved. The validation process is now over."), subtype="closed", context=context) + _("The request has been approved. The validation process is now over."), subtype="approved", context=context) def holidays_refuse_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been refused. The validation process is now over."), subtype="cancelled", context=context) + _("The request has been refused. The validation process is now over."), subtype="refused", context=context) class resource_calendar_leaves(osv.osv): diff --git a/addons/hr_holidays/hr_holidays_data.xml b/addons/hr_holidays/hr_holidays_data.xml index 3b927b60419..ad337b72c62 100644 --- a/addons/hr_holidays/hr_holidays_data.xml +++ b/addons/hr_holidays/hr_holidays_data.xml @@ -55,26 +55,12 @@ Once validated, they are visible in the employee's calendar. HR officers can def
                    - - submitted - - - - - pending - - - - - double validated + + approved - - closed - - - - cancelled + + refused diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 578ebde9162..99d522703d3 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -475,12 +475,12 @@ class hr_applicant(base_stage, osv.Model): self.message_post(cr, uid, [applicant.id], body=message, subtype="closed", context=context) else: message = _("Applicant has been hired.") - self.message_post(cr, uid, [applicant.id], body=message, subtype="closed", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype="hired", context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): msg = 'Applicant refused.' - return self.message_post(cr, uid, ids, body=msg, subtype="cancelled", context=context) + return self.message_post(cr, uid, ids, body=msg, subtype="refused", context=context) def case_reset_send_note(self, cr, uid, ids, context=None): message =_("Applicant has been set as new.") diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index a567489751a..818b5f5adef 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -467,12 +467,12 @@ You can automatically receive job application though an email gateway, see the H - - closed + + hired - - cancelled + + refused From 10313331e8f10c148bb9acc602d34822d4bbbae2 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Tue, 4 Sep 2012 15:26:49 +0530 Subject: [PATCH 079/175] [IMP] make chnages into subtype data in hr bzr revid: rma@tinyerp.com-20120904095649-ye94bntdm8ia5jrd --- addons/hr_recruitment/hr_recruitment.py | 2 +- addons/hr_recruitment/hr_recruitment_data.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 99d522703d3..2ff594aa820 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -472,7 +472,7 @@ class hr_applicant(base_stage, osv.Model): for applicant in self.browse(cr, uid, ids, context=context): if applicant.emp_id: message = _("Applicant has been hired and created as an employee.") - self.message_post(cr, uid, [applicant.id], body=message, subtype="closed", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype="hired", context=context) else: message = _("Applicant has been hired.") self.message_post(cr, uid, [applicant.id], body=message, subtype="hired", context=context) diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index 818b5f5adef..30ff9118584 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -471,7 +471,7 @@ You can automatically receive job application though an email gateway, see the H hired - + refused From d90d78171bb257cc4c65ca935d3f43814e31de67 Mon Sep 17 00:00:00 2001 From: "Randhir Mayatra (OpenERP)" Date: Tue, 4 Sep 2012 18:34:23 +0530 Subject: [PATCH 080/175] [IMP] make changes into the subtype data for project module bzr revid: rma@tinyerp.com-20120904130423-928mhaatxuxfbwi4 --- addons/base_status/base_stage.py | 6 +++--- addons/project_issue/project_issue.py | 2 +- addons/project_issue/project_issue_data.xml | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index 26afe548217..fdbc41cd8ac 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -401,13 +401,13 @@ class base_stage(object): def case_close_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been closed.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, context=context) + self.message_post(cr, uid, [id], body=msg, subtype="closed", context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): for id in ids: - msg = _('%s has been canceled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, context=context) + msg = _('%s has been cancelled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) + self.message_post(cr, uid, [id], body=msg, subtype="cancelled", context=context) return True def case_pending_send_note(self, cr, uid, ids, context=None): diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 52bb2d2d687..833c7dbb460 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -508,7 +508,7 @@ class project_issue(base_stage, osv.osv): def convert_to_task_send_note(self, cr, uid, ids, context=None): message = _("Project issue converted to task.") - return self.message_post(cr, uid, ids, body=message, subtype="converted", context=context) + return self.message_post(cr, uid, ids, body=message, context=context) def create_send_note(self, cr, uid, ids, context=None): message = _("Project issue created.") diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml index 2501bd821d2..6ee704c6b39 100644 --- a/addons/project_issue/project_issue_data.xml +++ b/addons/project_issue/project_issue_data.xml @@ -42,11 +42,15 @@ - - converted + + cancelled + + closed + + From ef747c7143eb0ce04d505dc1c24eae0d8b83f688 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Wed, 5 Sep 2012 11:00:31 +0530 Subject: [PATCH 081/175] [IMP]improve test case bzr revid: sgo@tinyerp.com-20120905053031-dqtcfyr1na9j7zpk --- addons/mail/tests/test_mail.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index bc8a0e5c085..45583d46fa3 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -566,10 +566,10 @@ class test_mail(common.TransactionCase): _mail_bodyalt2 = 'Pigs rules\nAdmin\n' filter_subtype_id = self.mail_message_subtype.search(cr, uid, [('default','=',True)]) # Post comment with body and subject, comment preference - msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, msg_type='comment',subtype='email') + msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype='email') notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") # New post: test automatic subject, signature in html, add a partner, email preference, parent_id previous message - msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, msg_type='email', subtype='other') + msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, type='email', subtype='other') notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") From 3476daf79fad6a05feefd76379c262bfd9d4a4a7 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Wed, 5 Sep 2012 15:01:35 +0530 Subject: [PATCH 082/175] [IMP]Add mail_subtype.rst file in mail bzr revid: fka@tinyerp.com-20120905093135-ydsqq62gnkcifqyv --- addons/mail/doc/index.rst.inc | 1 + addons/mail/doc/mail_subtype.rst | 70 ++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 addons/mail/doc/mail_subtype.rst diff --git a/addons/mail/doc/index.rst.inc b/addons/mail/doc/index.rst.inc index c4b87cc18f9..4b01d3ec7bd 100644 --- a/addons/mail/doc/index.rst.inc +++ b/addons/mail/doc/index.rst.inc @@ -11,3 +11,4 @@ Mail Module documentation topics mail_needaction_howto mail_partner mail_state + mail_subtype diff --git a/addons/mail/doc/mail_subtype.rst b/addons/mail/doc/mail_subtype.rst new file mode 100644 index 00000000000..e63b67936cd --- /dev/null +++ b/addons/mail/doc/mail_subtype.rst @@ -0,0 +1,70 @@ +.. _mail_message_subtype: + +OpenChatter Pi (3.1415): Message Subtype +======================================== + + To overcome the problems of crowdy walls in system notification, We have added features of **Message Subtype** in mail. + +mail.message.subtype +++++++++++++++++++++ +``mail.message.subtype`` has following fields: + + - ``Name``: fields.char(' Message Subtype ', size = 128,required = True,help = 'Subtype Of Message'), + - ``model_ids``: fields.many2many('ir.model','mail_message_subtyp_message_rel','message_subtype_id', 'model_id', 'Model',help = "link some subtypes to several models, for projet/task"), + - ``default``: fields.boolean('Default', help = "When subscribing to the document, users will receive by default messages related to this subtype unless they uncheck this subtype"), + +mail.followers +++++++++++++++ + +In ``mail.followers`` we have added additional many2many field subtype ids : + + - ``subtype_ids``: fields.many2many('mail.message.subtype','mail_message_subtyp_rel','subscription_id', 'subtype_id', 'Subtype',help = "linking some subscription to several subtype for projet/task") + +mail.message +++++++++++++ + +In mail_message we have added additional field subtype_id which Indicates the Type of Message + + - ``subtype_id``: fields.many2one('mail.message.subtype', 'Subtype') + +mail.thread ++++++++++++ + + - In **message_post** method add the *subtype_id* field as parameter and set as default subtype 'Other'. + + def message_post(self, cr, uid, thread_id, body='', subject=False, msg_type='notification', parent_id=False, attachments=None, subtype='other', context=None, ``**kwargs``): + + - In **message_subscribe** method add the *subtype_ids* field as parameter.In this method if subtype_ids is None, it fatch the default true subtypes in mail.message.subtypes otherwise pass selected subtypes. + For update subtypes call **message_subscribe_udpate_subtypes** method + + def message_subscribe(self, cr, uid, ids, partner_ids,subtype_ids = None, context=None): + + - Add **message_subscribe_udpate_subtypes** method to update the subtype_ids in followers. + + def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): + followers_obj = self.pool.get('mail.followers') + followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) + return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) + +For Each Addons: +++++++++++++++++ + + - Add data of subtypes for each addons module. + - Add subtype field as parameter in **message_post** Method for each addons module. + +How It Works: ++++++++++++++ + + - In addons module when we Follow a Perticular document It display under the followers button. + - In sybtypes there are 3 default subtypes for each addons + 1) Email + 2) Comment + 3) Other + - In document display a default subtypes(which are true) related a perticular model_ids wise. + + Example:- + If I have open crm.lead, It display only subtypes of crm.lead + + - When we select subtype it update subtype_ids(which are checked) in mail.follower where match res_model & res_id of the current documents. + - when message created update subtype_id of that message in mail.message. + - In Feeds display only those notifications of documents which subtypes are selected From d3edae5084b9c4a0a60fa0992c7e517ceb0b3bc7 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 6 Sep 2012 12:25:03 +0530 Subject: [PATCH 083/175] [IMP]:improved yml bzr revid: apa@tinyerp.com-20120906065503-h8rziczo7ri31z3o --- addons/crm/test/process/crm_message_subtype.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index 705d3cc2fc4..ee78553c913 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -9,7 +9,7 @@ - I have add the sub_type name email with default true - - !record {model: mail.message.subtype, id: mail_subtype_lead_email }: + !record {model: mail.message.subtype, id: mail.mail_subtype_email }: name: email model_ids: - crm.model_crm_lead @@ -17,7 +17,7 @@ - I have add the sub_type name comment with default true - - !record {model: mail.message.subtype, id: mail_subtype_lead_comment }: + !record {model: mail.message.subtype, id: mail.mail_subtype_comment }: name: comment model_ids: - crm.model_crm_lead From c028143bcf6e33592ff4c344ff990285ad48a178 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 6 Sep 2012 12:33:34 +0530 Subject: [PATCH 084/175] [IMP]:improved yml bzr revid: apa@tinyerp.com-20120906070334-bf4fvtr3kz055qfh --- addons/crm/crm_lead_data.xml | 2 +- addons/crm/test/process/crm_message_subtype.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 6f6562657ce..168aa62f714 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -160,7 +160,7 @@ - + won diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index ee78553c913..6c0038a7fb8 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -1,7 +1,7 @@ - I have add the sub_type name other with default false - - !record {model: mail.message.subtype, id: mail_subtype_lead_won }: + !record {model: mail.message.subtype, id: mail.mail_subtype_won }: name: won model_ids: - crm.model_crm_lead From 87bb5e31bff85fd3d5abe685d5271970c53c403b Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 6 Sep 2012 12:35:09 +0530 Subject: [PATCH 085/175] [IMP]:improved yml bzr revid: apa@tinyerp.com-20120906070509-u7ueba94sr10dqcg --- addons/crm/test/process/crm_message_subtype.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index 6c0038a7fb8..3dd042c1279 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -27,7 +27,7 @@ - !python {model: mail.followers}: | ids = self.search(cr, uid, [('res_model', '=', 'crm.lead'),('res_id', '=', ref('crm_case_1'))]) - self.write(cr, uid, ids, {'subtype_ids': [(6,0,[ref('mail_subtype_lead_won')])]}) + self.write(cr, uid, ids, {'subtype_ids': [(6,0,[ref('mail.mail_subtype_won')])]}) - I have change the lead into mark won - @@ -43,6 +43,6 @@ I have check the subtype as won in feeds - !python {model: mail.followers}: | - followers_ids =self.search(cr, uid, [('res_model', '=','crm.lead'),('res_id', '=', ref('crm_case_1')),('subtype_ids', 'in',[ref('mail_subtype_lead_won')])]) + followers_ids =self.search(cr, uid, [('res_model', '=','crm.lead'),('res_id', '=', ref('crm_case_1')),('subtype_ids', 'in',[ref('mail.mail_subtype_won')])]) if len(followers_ids): assert followers_ids, 'lead is in won' From 70c1c3df658c38e477108c40c8344bd0d967cd1e Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 6 Sep 2012 12:38:01 +0530 Subject: [PATCH 086/175] [IMP]:hide subtype when unfollowing bzr revid: apa@tinyerp.com-20120906070801-9fulnfblrrdxhetx --- addons/mail/static/src/js/mail_followers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 5d7b2ec5116..90318664474 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -95,7 +95,7 @@ openerp_mail_followers = function(session, mail) { else { this.$el.find('button.oe_mail_button_follow').show(); this.$el.find('button.oe_mail_button_unfollow').hide(); - // this.$el.find('ul.oe_mail_recthread_subtype').hide() + this.$el.find('ul.oe_mail_recthread_subtype').hide() } }, update_subtype: function (){ From 330abd29996e4b439c0d7cd59b9ace89fc7119f8 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 6 Sep 2012 15:07:54 +0530 Subject: [PATCH 087/175] [IMP]:improved indentation bzr revid: apa@tinyerp.com-20120906093754-gvly9tnpbc6mzhxs --- addons/mrp_repair/mrp_repair_data.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/mrp_repair/mrp_repair_data.xml b/addons/mrp_repair/mrp_repair_data.xml index 337a4113382..b45b7ec3105 100644 --- a/addons/mrp_repair/mrp_repair_data.xml +++ b/addons/mrp_repair/mrp_repair_data.xml @@ -1,7 +1,6 @@ - - + new @@ -44,5 +43,5 @@ - + From 4707ee56a9e6f2d5b4af389a1adba8fd83f0dac4 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 6 Sep 2012 15:11:23 +0530 Subject: [PATCH 088/175] [IMP]add context to the method bzr revid: sgo@tinyerp.com-20120906094123-ua4zxhot0z3wgd7g --- addons/mail/mail_message.py | 2 +- addons/mail/mail_thread.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 3ef731b766b..be1fbe78176 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -335,7 +335,7 @@ class mail_message(osv.Model): missing_follow_ids = [] if message.subtype_id: for p_id in missing_notified: - follow_ids = followers_obj.search(cr, uid, [('partner_id','=',p_id),('subtype_ids','in',[message.subtype_id.id]),('res_model','=',message.model),('res_id','=',message.res_id)]) + follow_ids = followers_obj.search(cr, uid, [('partner_id','=',p_id),('subtype_ids','in',[message.subtype_id.id]),('res_model','=',message.model),('res_id','=',message.res_id)], context=context) if follow_ids and len(follow_ids): missing_follow_ids.append(p_id) message.write({'partner_ids': [(4, p_id) for p_id in missing_follow_ids]}) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 7fc6c79bd9a..4d627712742 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -600,9 +600,9 @@ class mail_thread(osv.AbstractModel): values = kwargs subtype_obj = self.pool.get('mail.message.subtype') if subtype: - subtypes = subtype_obj.name_search(cr, uid, subtype) + subtypes = subtype_obj.name_search(cr, uid, subtype,context=context) if len(subtypes): - subtype_browse = subtype_obj.browse(cr, uid, subtypes[0][0]) + subtype_browse = subtype_obj.browse(cr, uid, subtypes[0][0],context=context) if self._name in [model.model for model in subtype_browse.model_ids]: values['subtype_id']=subtype_browse.id values.update({ @@ -636,7 +636,7 @@ class mail_thread(osv.AbstractModel): self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') - subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)]) + subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)],context=context) if subtype_ids: self.message_subscribe_udpate_subtypes(cr, uid, ids, partner_ids, subtype_ids, context=context) if context and context.get('read_back'): @@ -690,7 +690,7 @@ class mail_thread(osv.AbstractModel): def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): followers_obj = self.pool.get('mail.followers') - followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)]) + followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context=context) return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From f36dd4c891710bb3ddb6e097f80ef0b9b6c26134 Mon Sep 17 00:00:00 2001 From: "Amit Patel (OpenERP)" Date: Thu, 6 Sep 2012 16:29:14 +0530 Subject: [PATCH 089/175] [IMP]:improved test case bzr revid: apa@tinyerp.com-20120906105914-iwoi15ghgtibt2lr --- addons/mail/data/mail_data.xml | 5 ++++- addons/mail/mail_thread.py | 2 +- addons/mail/tests/test_mail.py | 4 +--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index b241cb095de..80aff038dac 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -15,13 +15,16 @@ other - + + email + comment + diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 4d627712742..42581654ace 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -562,7 +562,7 @@ class mail_thread(osv.AbstractModel): self.message_post(cr, uid, [id], message, context=context) def message_post(self, cr, uid, thread_id, body='', subject=False, - type='notification', parent_id=False, attachments=None, subtype='other', context=None, **kwargs): + type='notification', parent_id=False, attachments=None, subtype='comment', context=None, **kwargs): """ Post a new message in an existing thread, returning the new mail.message ID. Extra keyword arguments will be used as default column values for the new mail.message record. diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index a8c1d6b7cf1..8cf0e25ecbb 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -616,9 +616,7 @@ class test_mail(common.TransactionCase): # 0 - Admin p_a_id = user_admin.partner_id.id # Subscribe #1, - self.mail_group_model_id = self.ir_model.search(cr, uid, [('model','=', 'mail.group')])[0] - subtype_ids = self.mail_message_subtype.search(cr, uid, []) - self.mail_message_subtype.write(cr,uid,subtype_ids,{'model_ids':[(4,self.mail_group_model_id )]}) + group_pigs.message_subscribe_users([uid]) # Mail data From 6977a136498ccd320f5dbcc0caa9e476db5ada86 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 7 Sep 2012 17:12:16 +0530 Subject: [PATCH 090/175] [IMP]resolve error bzr revid: sgo@tinyerp.com-20120907114216-5qbzq1y80ut9d6mx --- addons/mail/mail_message_subtype.xml | 9 +++++++++ addons/mail/static/src/js/mail_followers.js | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_message_subtype.xml b/addons/mail/mail_message_subtype.xml index 8de3224470f..0bfdc2cad95 100644 --- a/addons/mail/mail_message_subtype.xml +++ b/addons/mail/mail_message_subtype.xml @@ -47,6 +47,15 @@ mail.message.subtype form tree,form + +

                    + Click to create a message subtype. +

                    + OpenERP's message subtype allows to ease and fasten the + subtype which helps to decrease over crowdy wall comments which displays + only those. +

                    +
                    Date: Fri, 7 Sep 2012 17:42:58 +0530 Subject: [PATCH 091/175] [IMP]improve code bzr revid: sgo@tinyerp.com-20120907121258-r48mymwh9yvxlrqi --- addons/mail/static/src/js/mail_followers.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 53f2117fa04..c2d4f31c159 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -117,8 +117,9 @@ openerp_mail_followers = function(session, mail) { follower_read.then(function (follower_record){ if(follower_record.length != 0){ _(follower_record[0].subtype_ids).each(function (subtype_id){ - if(self.$el.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0]){ - self.$el.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true} + var subtype_check = self.$el.find('.oe_msg_subtype_check[id=' + subtype_id + ']') + if(subtype_check.length > 0){ + subtype_check[0].checked=true} }); } }) From 741bbaa9f457577b25d8f6007b6aae34aedf2840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 7 Sep 2012 18:09:20 +0200 Subject: [PATCH 092/175] [WIP] mail_message.message_read(): WIP about having correct expandables. Will be updated next week. bzr revid: tde@openerp.com-20120907160920-4ijs93y9ogp39xma --- addons/mail/mail_message.py | 59 ++++++++++++++++++++++++---------- addons/mail/res_partner.py | 1 - addons/mail/tests/test_mail.py | 13 ++++---- 3 files changed, 49 insertions(+), 24 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 18a88bb0b61..90ccc8a2f24 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -167,7 +167,24 @@ class mail_message(osv.Model): 'child_ids': [], } - def message_read_tree_flatten(self, cr, uid, messages, current_level, level, context=None): + def message_read_tree_get_expandable(self, cr, uid, parent_message, last_message, domain=[], current_level=0, level=0, context=None): + """ . """ + base_domain = [('id', '<', last_message['id'])] + if parent_message and current_level < level: + base_domain += [('parent_id', '=', parent_message['id'])] + elif parent_message: + base_domain += [('id', 'child_od', parent_message['id'])] + if domain: + base_domain += domain + extension = { 'type': 'expandable', + 'domain': base_domain, + 'thread_level': current_level, + 'context': context, + 'id': -1, + } + return extension + + def message_read_tree_flatten(self, cr, uid, parent_message, messages, current_level, level, domain=[], context=None): """ Given a tree with several roots of following structure : [ {'id': 1, 'child_ids': [ {'id': 11, 'child_ids': [...] },], @@ -186,28 +203,36 @@ class mail_message(osv.Model): child_ids = msg_dict.pop('child_ids', []) msg_dict['child_ids'] = [] return [msg_dict] + child_ids - # return sorted([msg_dict] + child_ids, key=itemgetter('id'), reverse=True) context = context or {} # Depth-first flattening for message in messages: if message.get('type') == 'expandable': continue - message['child_ids'] = self.message_read_tree_flatten(cr, uid, message['child_ids'], current_level + 1, level, context=context) + message['child_ids'] = self.message_read_tree_flatten(cr, uid, message, message['child_ids'], current_level + 1, level, domain, context=context) # Flatten if above maximum depth if current_level < level: return_list = messages else: - return_list = [] - for message in messages: - for flat_message in _flatten(message): - return_list.append(flat_message) - return sorted(return_list, key=itemgetter(context.get('sort_key', 'id')), reverse=context.get('sort_reverse', True)) + return_list = [flat_message for message in messages for flat_message in _flatten(message)] + # Add expandable + return_list = sorted(return_list, key=itemgetter(context.get('sort_key', 'id')), reverse=context.get('sort_reverse', True)) + if current_level <= level: + expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, [], current_level, level, context=context) + print 'expandable', expandable + return return_list - def message_read(self, cr, uid, ids=False, domain=[], thread_level=0, limit=None, context=None): - """ If IDs are provided, fetch these records. Otherwise use the domain - to fetch the matching records. - After having fetched the records provided by IDs, it will fetch the - parents to have well-formed threads. + def message_read(self, cr, uid, ids=False, domain=[], level=0, context=None, limit=None, tree_parent_id=False): + """ Read messages from mail.message, and get back a structured tree + of messages to be displayed as discussion threads. If IDs is set, + fetch these records. Otherwise use the domain to fetch messages. + After having fetch messages, their parents will be added to obtain + well formed threads. + + :param domain: optional domain for searching ids + :param level: level of threads to display, 0 being flat + :param limit: number of messages to fetch + :param tree_parent_id: if parent_id reached, stop searching for + further parents :return list: list of trees of messages """ limit = limit or self._message_read_limit @@ -221,8 +246,8 @@ class mail_message(osv.Model): for msg in messages: if len(result) < (limit - 1): record = self._message_dict_get(cr, uid, msg, context=context) - if thread_level and msg.parent_id: - while msg.parent_id: + if level and msg.parent_id: + while msg.parent_id != tree_parent_id: if msg.parent_id.id in tree: record_parent = tree[msg.parent_id.id] else: @@ -241,14 +266,14 @@ class mail_message(osv.Model): 'type': 'expandable', 'domain': [('id', '<=', msg.id)] + domain, 'context': context, - 'thread_level': thread_level, # should be improve accodting to level of records + 'thread_level': level, # should be improve accodting to level of records 'id': -1, }) break # Flatten the result if thread_level > 0: - result = self.message_read_tree_flatten(cr, uid, result, 0, thread_level, context=context) + result = self.message_read_tree_flatten(cr, uid, None, result, 0, thread_level, domain, context=context) return result #------------------------------------------------------ diff --git a/addons/mail/res_partner.py b/addons/mail/res_partner.py index 2988cee3d9c..4a6f98fa31d 100644 --- a/addons/mail/res_partner.py +++ b/addons/mail/res_partner.py @@ -41,5 +41,4 @@ class res_partner_mail(osv.Model): 'notification_email_send': lambda *args: 'comment' } - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index f45745f31dc..1f65c38f755 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -459,13 +459,13 @@ class test_mail(common.TransactionCase): cr, uid = self.cr, self.uid group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) def _compare_structures(struct1, struct2, n=0): - # print '%scompare structure' % ('\t' * n) + print '%scompare structure' % ('\t' * n) self.assertEqual(len(struct1), len(struct2), 'message_read structure number of childs incorrect') for x in range(len(struct1)): - # print '%s' % ('\t' * n), struct1[x]['id'], struct2[x]['id'], struct1[x].get('subject') or '' + print '%s' % ('\t' * n), struct1[x]['id'], struct2[x]['id'], struct1[x].get('subject') or '' self.assertEqual(struct1[x]['id'], struct2[x]['id'], 'message_read failure %s' % struct1[x].get('subject')) _compare_structures(struct1[x]['child_ids'], struct2[x]['child_ids'], n + 1) - # print '%send compare' % ('\t' * n) + print '%send compare' % ('\t' * n) # ---------------------------------------- # CASE1: Flattening test @@ -490,7 +490,8 @@ class test_mail(common.TransactionCase): ]}, ] # Test: completely flat - new_tree = self.mail_message.message_read_tree_flatten(cr, uid, copy.deepcopy(tree), 0, 0) + new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), 0, 0, [('type', 'in', 'borderlands')]) + _compare_structures(new_tree, new_tree) self.assertEqual(len(new_tree), 10, 'message_read_tree_flatten wrong in flat') # Test: 1 thread level tree_test = [{'id': 2, 'child_ids': [ @@ -502,10 +503,10 @@ class test_mail(common.TransactionCase): {'id': 4, 'child_ids': []}, {'id': 3, 'child_ids': []}, ]}, ] - new_tree = self.mail_message.message_read_tree_flatten(cr, uid, copy.deepcopy(tree), 0, 1) + new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), 0, 1, [('type', 'in', 'borderlands')]) _compare_structures(new_tree, tree_test) # Test: 2 thread levels - new_tree = self.mail_message.message_read_tree_flatten(cr, uid, copy.deepcopy(tree), 0, 2) + new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), 0, 2, [('type', 'in', 'borderlands')]) _compare_structures(new_tree, tree) # ---------------------------------------- From 5cf330f39a23157caa50d475add761ff93109f99 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Mon, 10 Sep 2012 11:19:03 +0530 Subject: [PATCH 093/175] [IMP]add help on subtype name bzr revid: sgo@tinyerp.com-20120910054903-22sveyi971arsl39 --- addons/mail/mail_message_subtype.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_message_subtype.py b/addons/mail/mail_message_subtype.py index ab41c83ed61..2330e34e1d3 100644 --- a/addons/mail/mail_message_subtype.py +++ b/addons/mail/mail_message_subtype.py @@ -27,8 +27,8 @@ class mail_message_subtype(osv.osv): _name = 'mail.message.subtype' _description = 'mail_message_subtype' _columns = { - 'name': fields.char(' Message Subtype ', size = 128, - required = True, help = 'Subtype Of Message'), + 'name': fields.char('Message Subtype ', size = 128, + required = True, help = 'Message subtype, gives a more precise type on the message, especially for system notifications. For example, it can be a notification related to a new record (New), or to a stage change in a process (Stage change). Message subtypes allow to precisely tune the notifications the user want to receive on its wall.'), 'model_ids': fields.many2many('ir.model', 'mail_message_subtyp_message_rel', 'message_subtype_id', 'model_id', 'Model', From dfa14420d212911bb5f87af19231a848c59cab07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 11 Sep 2012 14:01:17 +0200 Subject: [PATCH 094/175] [WIP] mail_message: continued work on message_read and expandables. bzr revid: tde@openerp.com-20120911120117-xeeercvglfwq3c9e --- addons/mail/mail_message.py | 69 +++++++++++++++---------------- addons/mail/static/src/js/mail.js | 2 +- addons/mail/tests/test_mail.py | 37 +++++++++-------- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 90ccc8a2f24..230199569f4 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -147,6 +147,7 @@ class mail_message(osv.Model): def _message_dict_get(self, cr, uid, msg, context=None): """ Return a dict representation of the message browse record. """ + child_nbr = len(msg.child_ids) attachment_ids = [{'id': attach[0], 'name': attach[1]} for attach in self.pool.get('ir.attachment').name_get(cr, uid, [x.id for x in msg.attachment_ids], context=context)] author_id = self.pool.get('res.partner').name_get(cr, uid, [msg.author_id.id], context=context)[0] author_user_id = self.pool.get('res.users').name_get(cr, uid, [msg.author_id.user_ids[0].id], context=context)[0] @@ -165,6 +166,7 @@ class mail_message(osv.Model): 'author_user_id': author_user_id, 'partner_ids': partner_ids, 'child_ids': [], + 'child_nbr': child_nbr, } def message_read_tree_get_expandable(self, cr, uid, parent_message, last_message, domain=[], current_level=0, level=0, context=None): @@ -173,7 +175,7 @@ class mail_message(osv.Model): if parent_message and current_level < level: base_domain += [('parent_id', '=', parent_message['id'])] elif parent_message: - base_domain += [('id', 'child_od', parent_message['id'])] + base_domain += [('id', 'child_of', parent_message['id'])] if domain: base_domain += domain extension = { 'type': 'expandable', @@ -184,7 +186,7 @@ class mail_message(osv.Model): } return extension - def message_read_tree_flatten(self, cr, uid, parent_message, messages, current_level, level, domain=[], context=None): + def message_read_tree_flatten(self, cr, uid, parent_message, messages, domain=[], level=0, current_level=0, context=None, limit=None): """ Given a tree with several roots of following structure : [ {'id': 1, 'child_ids': [ {'id': 11, 'child_ids': [...] },], @@ -204,11 +206,14 @@ class mail_message(osv.Model): msg_dict['child_ids'] = [] return [msg_dict] + child_ids context = context or {} + limit = limit or self._message_read_limit # Depth-first flattening for message in messages: if message.get('type') == 'expandable': continue - message['child_ids'] = self.message_read_tree_flatten(cr, uid, message, message['child_ids'], current_level + 1, level, domain, context=context) + message['child_ids'] = self.message_read_tree_flatten(cr, uid, message, message['child_ids'], domain, level, current_level + 1, context=context) + for child in message['child_ids']: + message['child_nbr'] += child['child_nbr'] # Flatten if above maximum depth if current_level < level: return_list = messages @@ -216,12 +221,17 @@ class mail_message(osv.Model): return_list = [flat_message for message in messages for flat_message in _flatten(message)] # Add expandable return_list = sorted(return_list, key=itemgetter(context.get('sort_key', 'id')), reverse=context.get('sort_reverse', True)) - if current_level <= level: + if current_level == 0: + expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, [], current_level, level, context=context) + if len(return_list) >= limit: + print 'we need an expandable here' + print 'expandable', expandable + elif current_level <= level: expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, [], current_level, level, context=context) print 'expandable', expandable return return_list - def message_read(self, cr, uid, ids=False, domain=[], level=0, context=None, limit=None, tree_parent_id=False): + def message_read(self, cr, uid, ids=False, domain=[], level=0, context=None, limit=None, parent_id=False): """ Read messages from mail.message, and get back a structured tree of messages to be displayed as discussion threads. If IDs is set, fetch these records. Otherwise use the domain to fetch messages. @@ -231,7 +241,7 @@ class mail_message(osv.Model): :param domain: optional domain for searching ids :param level: level of threads to display, 0 being flat :param limit: number of messages to fetch - :param tree_parent_id: if parent_id reached, stop searching for + :param parent_id: if parent_id reached, stop searching for further parents :return list: list of trees of messages """ @@ -241,39 +251,28 @@ class mail_message(osv.Model): ids = self.search(cr, uid, domain, context=context, limit=limit) messages = self.browse(cr, uid, ids, context=context) + # key: ID, value: record + tree = {} result = [] - tree = {} # key: ID, value: record for msg in messages: - if len(result) < (limit - 1): - record = self._message_dict_get(cr, uid, msg, context=context) - if level and msg.parent_id: - while msg.parent_id != tree_parent_id: - if msg.parent_id.id in tree: - record_parent = tree[msg.parent_id.id] - else: - record_parent = self._message_dict_get(cr, uid, msg.parent_id, context=context) - if msg.parent_id.parent_id: - tree[msg.parent_id.id] = record_parent - if record['id'] not in [x['id'] for x in record_parent['child_ids']]: - record_parent['child_ids'].append(record) - record = record_parent - msg = msg.parent_id - if msg.id not in tree: - result.append(record) - tree[msg.id] = record - else: - result.append({ - 'type': 'expandable', - 'domain': [('id', '<=', msg.id)] + domain, - 'context': context, - 'thread_level': level, # should be improve accodting to level of records - 'id': -1, - }) - break + record = self._message_dict_get(cr, uid, msg, context=context) + while msg.parent_id and msg.parent_id.id != parent_id: + if msg.parent_id.id in tree: + record_parent = tree[msg.parent_id.id] + else: + record_parent = self._message_dict_get(cr, uid, msg.parent_id, context=context) + if msg.parent_id.parent_id: + tree[msg.parent_id.id] = record_parent + if record['id'] not in [x['id'] for x in record_parent['child_ids']]: + record_parent['child_ids'].append(record) + record = record_parent + msg = msg.parent_id + if msg.id not in tree: + result.append(record) + tree[msg.id] = record # Flatten the result - if thread_level > 0: - result = self.message_read_tree_flatten(cr, uid, None, result, 0, thread_level, domain, context=context) + result = self.message_read_tree_flatten(cr, uid, None, result, domain, level, context=context) return result #------------------------------------------------------ diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index c02b81d0c4f..651a2642cc4 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -455,7 +455,7 @@ openerp.mail = function(session) { return this.message_display(this.options.message_data); } return this.ds_message.call('message_read', - [(initial_mode && this.options.message_ids) || false, fetch_domain, this.options.thread_level, undefined, fetch_context] + [(initial_mode && this.options.message_ids) || false, fetch_domain, this.options.thread_level, fetch_context] ).then(this.proxy('message_display')); }, diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 1f65c38f755..053e5697207 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -29,7 +29,7 @@ Received: by mail1.openerp.com (Postfix, from userid 10002) From: Sylvie Lelitre Subject: {subject} MIME-Version: 1.0 -Content-Type: multipart/alternative; +Content-Type: multipart/alternative; boundary="----=_Part_4200734_24778174.1344608186754" Date: Fri, 10 Aug 2012 14:16:26 +0000 Message-ID: <1198923581.41972151344608186760.JavaMail@agrolait.com> @@ -52,9 +52,9 @@ Content-Transfer-Encoding: quoted-printable =20 =20 - +

                    Please call me as soon as possible this afternoon!

                    - +

                    --
                    Sylvie

                    @@ -153,7 +153,7 @@ class test_mail(common.TransactionCase): test_msg_id = '' mail_text = MAIL_TEMPLATE_PLAINTEXT.format(to='groups@example.com', subject='frogs', extra='', msg_id=test_msg_id) self.mail_thread.message_process(cr, uid, None, mail_text) - new_mail = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [('message_id','=',test_msg_id)])[0]) + new_mail = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [('message_id', '=', test_msg_id)])[0]) self.assertEqual(new_mail.body, '\n

                    \nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n
                    \n', 'plaintext mail incorrectly parsed') @@ -458,11 +458,12 @@ class test_mail(common.TransactionCase): # It will be updated as soon as we have fixed specs ! cr, uid = self.cr, self.uid group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) + def _compare_structures(struct1, struct2, n=0): print '%scompare structure' % ('\t' * n) self.assertEqual(len(struct1), len(struct2), 'message_read structure number of childs incorrect') for x in range(len(struct1)): - print '%s' % ('\t' * n), struct1[x]['id'], struct2[x]['id'], struct1[x].get('subject') or '' + print '%s' % ('\t' * n), struct1[x]['id'], struct1[x]['child_nbr'], struct2[x]['id'], struct2[x]['child_nbr'], struct1[x].get('subject') or '' self.assertEqual(struct1[x]['id'], struct2[x]['id'], 'message_read failure %s' % struct1[x].get('subject')) _compare_structures(struct1[x]['child_ids'], struct2[x]['child_ids'], n + 1) print '%send compare' % ('\t' * n) @@ -473,24 +474,24 @@ class test_mail(common.TransactionCase): # Create dummy message structure import copy - tree = [{'id': 2, 'child_ids': [ - {'id': 6, 'child_ids': [ - {'id': 8, 'child_ids': []}, + tree = [{'id': 2, 'child_nbr': 1, 'child_ids': [ + {'id': 6, 'child_nbr': 1, 'child_ids': [ + {'id': 8, 'child_nbr': 0, 'child_ids': []}, ]}, ]}, - {'id': 1, 'child_ids':[ - {'id': 7, 'child_ids': [ - {'id': 9, 'child_ids': []}, + {'id': 1, 'child_nbr': 3, 'child_ids':[ + {'id': 7, 'child_nbr': 1, 'child_ids': [ + {'id': 9, 'child_nbr': 0, 'child_ids': []}, ]}, - {'id': 4, 'child_ids': [ - {'id': 10, 'child_ids': []}, - {'id': 5, 'child_ids': []}, + {'id': 4, 'child_nbr': 2, 'child_ids': [ + {'id': 10, 'child_nbr': 0, 'child_ids': []}, + {'id': 5, 'child_nbr': 0, 'child_ids': []}, ]}, - {'id': 3, 'child_ids': []}, + {'id': 3, 'child_nbr': 0, 'child_ids': []}, ]}, ] # Test: completely flat - new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), 0, 0, [('type', 'in', 'borderlands')]) + new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), [('type', 'in', 'borderlands')], 0) _compare_structures(new_tree, new_tree) self.assertEqual(len(new_tree), 10, 'message_read_tree_flatten wrong in flat') # Test: 1 thread level @@ -503,10 +504,10 @@ class test_mail(common.TransactionCase): {'id': 4, 'child_ids': []}, {'id': 3, 'child_ids': []}, ]}, ] - new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), 0, 1, [('type', 'in', 'borderlands')]) + new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), [('type', 'in', 'borderlands')], 1) _compare_structures(new_tree, tree_test) # Test: 2 thread levels - new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), 0, 2, [('type', 'in', 'borderlands')]) + new_tree = self.mail_message.message_read_tree_flatten(cr, uid, None, copy.deepcopy(tree), [('type', 'in', 'borderlands')], 2) _compare_structures(new_tree, tree) # ---------------------------------------- From ce39ffe9271261cdc52b76e3bc981d177f7a6693 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Wed, 12 Sep 2012 16:52:45 +0530 Subject: [PATCH 095/175] [IMP]changed as per new spec update and make it work for crm changes done in crm bzr revid: sgo@tinyerp.com-20120912112245-3cp03024fiqb47qs --- addons/crm/crm_lead.py | 18 ++-- addons/crm/crm_lead_data.xml | 28 +++--- addons/mail/data/mail_data.xml | 10 --- addons/mail/mail_message.py | 45 +++------- addons/mail/mail_message_subtype.py | 8 +- addons/mail/mail_message_subtype.xml | 5 +- addons/mail/mail_thread.py | 41 ++++++--- addons/mail/static/src/js/mail_followers.js | 64 +++++-------- addons/mail/tests/test_mail.py | 99 ++++++--------------- 9 files changed, 106 insertions(+), 212 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index b7cc0f840d9..6b04be2244d 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -27,15 +27,13 @@ import time import tools from tools.translate import _ -from base.res.res_partner import format_address - CRM_LEAD_PENDING_STATES = ( crm.AVAILABLE_STATES[2][0], # Cancelled crm.AVAILABLE_STATES[3][0], # Done crm.AVAILABLE_STATES[4][0], # Pending ) -class crm_lead(base_stage, format_address, osv.osv): +class crm_lead(base_stage, osv.osv): """ CRM Lead Case """ _name = "crm.lead" _description = "Lead/Opportunity" @@ -107,12 +105,6 @@ class crm_lead(base_stage, format_address, osv.osv): return result, fold - def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): - res = super(crm_lead,self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu) - if view_type == 'form': - res['arch'] = self.fields_view_get_address(cr, user, res['arch'], context=context) - return res - _group_by_full = { 'stage_id': _read_group_stage_ids } @@ -842,7 +834,7 @@ class crm_lead(base_stage, format_address, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change",context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), mail_subtype_new="crm_subtype_stage_change",context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): @@ -852,16 +844,16 @@ class crm_lead(base_stage, format_address, osv.osv): def create_send_note(self, cr, uid, ids, context=None): for id in ids: message = _("%s has been created.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=message, subtype="new", context=context) + self.message_post(cr, uid, [id], body=message, subtype_xml_id="crm_subtype_new", context=context) return True def case_mark_lost_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been lost.") - return self.message_post(cr, uid, ids, body=message,subtype="lost", context=context) + return self.message_post(cr, uid, ids, body=message,subtype_xml_id="crm_subtype_lost", context=context) def case_mark_won_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been won.") - return self.message_post(cr, uid, ids, body=message, subtype="won", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="crm_subtype_won", context=context) def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None): phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0] diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 9b3f5d7ec75..252e843cf30 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -155,32 +155,24 @@
                    - + new - + crm.lead - + won - + crm.lead - + lost - - - - stage change - + crm.lead - - - - - - - - + + stage change + crm.lead + diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index 80aff038dac..8e2af38f2ea 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -13,18 +13,8 @@ - - other - - - - - email - - comment - diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 686f3e3d381..9e228083b1b 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -20,13 +20,11 @@ ############################################################################## import logging -import openerp import tools from email.header import decode_header from operator import itemgetter from osv import osv, fields -from tools.translate import _ _logger = logging.getLogger(__name__) @@ -37,7 +35,6 @@ def decode(text): text = decode_header(text.replace('\r', '')) return ''.join([tools.ustr(x[0], x[1]) for x in text]) - class mail_message(osv.Model): """ Messages model: system notification (replacing res.log notifications), comments (OpenChatter discussion) and incoming emails. """ @@ -60,10 +57,7 @@ class mail_message(osv.Model): for message in self.browse(cr, uid, ids, context=context): if not message.model or not message.res_id: continue - try: - result[message.id] = self._shorten_name(self.pool.get(message.model).name_get(cr, uid, [message.res_id], context=context)[0][1]) - except openerp.exceptions.AccessDenied, e: - pass + result[message.id] = self._shorten_name(self.pool.get(message.model).name_get(cr, uid, [message.res_id], context=context)[0][1]) return result def _get_unread(self, cr, uid, ids, name, arg, context=None): @@ -154,7 +148,7 @@ class mail_message(osv.Model): def _message_dict_get(self, cr, uid, msg, context=None): """ Return a dict representation of the message browse record. """ - attachment_ids = [{'id': attach[0], 'name': attach[1]} for attach in self.pool.get('ir.attachment').name_get(cr, uid, [x.id for x in msg.attachment_ids], context=context)] + attachment_ids = self.pool.get('ir.attachment').name_get(cr, uid, [x.id for x in msg.attachment_ids], context=context) author_id = self.pool.get('res.partner').name_get(cr, uid, [msg.author_id.id], context=context)[0] author_user_id = self.pool.get('res.users').name_get(cr, uid, [msg.author_id.user_ids[0].id], context=context)[0] partner_ids = self.pool.get('res.partner').name_get(cr, uid, [x.id for x in msg.partner_ids], context=context) @@ -313,15 +307,15 @@ class mail_message(osv.Model): def unlink(self, cr, uid, ids, context=None): # cascade-delete attachments that are directly attached to the message (should only happen - # for mail.messages that act as parent for a standalone mail.mail record). + # for mail.messages that act as parent for a standalone mail.mail record. attachments_to_delete = [] - for message in self.browse(cr, uid, ids, context=context): - for attach in message.attachment_ids: - if attach.res_model == self._name and attach.res_id == message.id: + for mail in self.browse(cr, uid, ids, context=context): + for attach in mail.attachment_ids: + if attach.res_model == 'mail.message' and attach.res_id == mail.id: attachments_to_delete.append(attach.id) if attachments_to_delete: self.pool.get('ir.attachment').unlink(cr, uid, attachments_to_delete, context=context) - return super(mail_message, self).unlink(cr, uid, ids, context=context) + return super(mail_message,self).unlink(cr, uid, ids, context=context) def notify(self, cr, uid, newid, context=None): """ Add the related record followers to the destination partner_ids. @@ -344,6 +338,9 @@ class mail_message(osv.Model): follow_ids = followers_obj.search(cr, uid, [('partner_id','=',p_id),('subtype_ids','in',[message.subtype_id.id]),('res_model','=',message.model),('res_id','=',message.res_id)], context=context) if follow_ids and len(follow_ids): missing_follow_ids.append(p_id) + subtype_record = self.pool.get('mail.message.subtype').browse(cr, uid, message.subtype_id.id,context=context) + if not subtype_record.res_model: + missing_follow_ids.append(p_id) message.write({'partner_ids': [(4, p_id) for p_id in missing_follow_ids]}) partners_to_notify |= extra_notified self.pool.get('mail.notification').notify(cr, uid, list(partners_to_notify), newid, context=context) @@ -354,25 +351,3 @@ class mail_message(osv.Model): default = {} default.update(message_id=False, headers=False) return super(mail_message, self).copy(cr, uid, id, default=default, context=context) - - #------------------------------------------------------ - # Tools - #------------------------------------------------------ - - def check_partners_email(self, cr, uid, partner_ids, context=None): - """ Verify that selected partner_ids have an email_address defined. - Otherwise throw a warning. """ - partner_wo_email_lst = [] - for partner in self.pool.get('res.partner').browse(cr, uid, partner_ids, context=context): - if not partner.email: - partner_wo_email_lst.append(partner) - if not partner_wo_email_lst: - return {} - warning_msg = _('The following partners chosen as recipients for the email have no email address linked :') - for partner in partner_wo_email_lst: - warning_msg += '\n- %s' % (partner.name) - return {'warning': { - 'title': _('Partners email addresses not found'), - 'message': warning_msg, - } - } diff --git a/addons/mail/mail_message_subtype.py b/addons/mail/mail_message_subtype.py index 2330e34e1d3..6eb349fc71e 100644 --- a/addons/mail/mail_message_subtype.py +++ b/addons/mail/mail_message_subtype.py @@ -29,15 +29,9 @@ class mail_message_subtype(osv.osv): _columns = { 'name': fields.char('Message Subtype ', size = 128, required = True, help = 'Message subtype, gives a more precise type on the message, especially for system notifications. For example, it can be a notification related to a new record (New), or to a stage change in a process (Stage change). Message subtypes allow to precisely tune the notifications the user want to receive on its wall.'), - 'model_ids': fields.many2many('ir.model', - 'mail_message_subtyp_message_rel', - 'message_subtype_id', 'model_id', 'Model', - help = "link some subtypes to several models, for projet/task"), + 'res_model': fields.char('Model',size = 128, help = "link subtype to model"), 'default': fields.boolean('Default', help = "When subscribing to the document, users will receive by default messages related to this subtype unless they uncheck this subtype"), } _defaults = { 'default': True, } - _sql_constraints = [ - ('name_uniq', 'unique (name)', 'The name of the message subtype must be unique !') - ] diff --git a/addons/mail/mail_message_subtype.xml b/addons/mail/mail_message_subtype.xml index 0bfdc2cad95..7d0eed2f4da 100644 --- a/addons/mail/mail_message_subtype.xml +++ b/addons/mail/mail_message_subtype.xml @@ -14,7 +14,7 @@ - + @@ -30,13 +30,12 @@ + - - diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 87c2e22d46b..23c038ce692 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -562,7 +562,7 @@ class mail_thread(osv.AbstractModel): self.message_post(cr, uid, [id], message, context=context) def message_post(self, cr, uid, thread_id, body='', subject=False, - type='notification', parent_id=False, attachments=None, subtype='comment', context=None, **kwargs): + type='notification', parent_id=False, attachments=None, subtype_xml_id='mail_subtype_comment', context=None, **kwargs): """ Post a new message in an existing thread, returning the new mail.message ID. Extra keyword arguments will be used as default column values for the new mail.message record. @@ -599,12 +599,13 @@ class mail_thread(osv.AbstractModel): values = kwargs subtype_obj = self.pool.get('mail.message.subtype') - if subtype: - subtypes = subtype_obj.name_search(cr, uid, subtype,context=context) - if len(subtypes): - subtype_browse = subtype_obj.browse(cr, uid, subtypes[0][0],context=context) - if self._name in [model.model for model in subtype_browse.model_ids]: - values['subtype_id']=subtype_browse.id + ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype_xml_id) + if subtype_xml_id: + subtype_browse = subtype_obj.browse(cr, uid, ref[1],context=context) + if self._name == subtype_browse.res_model: + values['subtype_id']=subtype_browse.id + else: + values['subtype_id']=subtype_browse.id values.update({ 'model': context.get('thread_model', self._name) if thread_id else False, 'res_id': thread_id or False, @@ -628,14 +629,20 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids, context=None): - """ Add partners to the records followers. """ + def message_subscribe(self, cr, uid, ids, partner_ids,subtype_ids = None, context=None): + """ Add partners to the records followers. + :param partner_ids: a list of partner_ids to subscribe + :param return: new value of followers if read_back key in context + """ + self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') - subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('model_ids.model', '=', self._name)],context=context) + subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('res_model', '=', self._name)],context=context) if subtype_ids: self.message_subscribe_udpate_subtypes(cr, uid, ids, partner_ids, subtype_ids, context=context) - return self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) + if context and context.get('read_back'): + return [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] + return [] def message_unsubscribe_users(self, cr, uid, ids, user_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not @@ -645,8 +652,14 @@ class mail_thread(osv.AbstractModel): return self.message_unsubscribe(cr, uid, ids, partner_ids, context=context) def message_unsubscribe(self, cr, uid, ids, partner_ids, context=None): - """ Remove partners from the records followers. """ - return self.write(cr, uid, ids, {'message_follower_ids': [(3, pid) for pid in partner_ids]}, context=context) + """ Remove partners from the records followers. + :param partner_ids: a list of partner_ids to unsubscribe + :param return: new value of followers if read_back key in context + """ + self.write(cr, uid, ids, {'message_follower_ids': [(3, pid) for pid in partner_ids]}, context=context) + if context and context.get('read_back'): + return [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids] + return [] #------------------------------------------------------ # Thread state @@ -679,6 +692,6 @@ class mail_thread(osv.AbstractModel): def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): followers_obj = self.pool.get('mail.followers') followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context=context) - return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one + return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 2126d60edf0..b1d62b76a62 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -33,12 +33,20 @@ openerp_mail_followers = function(session, mail) { }, start: function() { - // use actual_mode property on view to know if the view is in create mode anymore + var self = this; + // NB: all the widget should be modified to check the actual_mode property on view, not use + // any other method to know if the view is in create mode anymore this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); this.fetch_subtype(); + this.$el.find('ul.oe_mail_recthread_subtype').click(function () {self.update_subtype();}) + this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); self.fetch_subtype();}) + .mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) + .mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); + this.$el.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); }) + .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) + .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.reinit(); - this.bind_events(); }, _check_visibility: function() { @@ -46,40 +54,14 @@ openerp_mail_followers = function(session, mail) { if (this.view.get("actual_mode") !== "create"){this.fetch_subtype();} }, + destroy: function () { + this._super.apply(this, arguments); + }, + reinit: function() { this.$el.find('button.oe_mail_button_follow').hide(); this.$el.find('button.oe_mail_button_unfollow').hide(); - }, - - bind_events: function() { - var self = this; - this.$('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); }) - .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) - .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); - this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); self.fetch_subtype(); }); - this.$el.on('click','ul.oe_mail_recthread_subtype', function () {self.update_subtype();}) - this.$el.on('click', 'button.oe_mail_button_invite', function(event) { - action = { - type: 'ir.actions.act_window', - res_model: 'mail.wizard.invite', - view_mode: 'form', - view_type: 'form', - views: [[false, 'form']], - target: 'new', - context: { - 'default_res_model': self.view.dataset.model, - 'default_res_id': self.view.datarecord.id - }, - } - self.do_action(action, function() { self.read_value(); }); - }); - }, - - read_value: function() { - var self = this; - return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).pipe(function (results) { - return results[0].message_follower_ids; - }).pipe(this.proxy('set_value')); + // this.$el.find('ul.oe_mail_recthread_subtype').hide() }, set_value: function(value_) { @@ -89,11 +71,11 @@ openerp_mail_followers = function(session, mail) { this.$el.find('div.oe_mail_recthread_aside').hide(); return; } - return this.fetch_followers(value_ || this.get_value()); + return this.fetch_followers(value_); }, fetch_followers: function (value_) { - return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers')); + return this.ds_follow.call('read', [value_ || this.get_value(), ['name', 'user_ids']]).then(this.proxy('display_followers')); }, /** Display the followers, evaluate is_follower directly */ @@ -103,7 +85,7 @@ openerp_mail_followers = function(session, mail) { var node_user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.options.title + ' (' + records.length + ')'); _(records).each(function (record) { - record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id); + record.avatar_url = mail.ChatterUtils.get_image(self.session.prefix, self.session.session_id, 'res.partner', 'image_small', record.id); $(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(node_user_list); }); if (this.message_is_follower) { @@ -149,22 +131,22 @@ openerp_mail_followers = function(session, mail) { }, do_follow: function () { - var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); + var context = new session.web.CompoundContext(this.build_context(), {'read_back': true}); + return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('set_value')); }, //fetch subtype from subtype model fetch_subtype: function () { var self = this - var subtype_object = this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]); + var subtype_object = this.sub_model.call('search', [[['res_model','=',this.view.model]]]); subtype_object.then(function (subtype_ids){ self.sub_model.call('read', [subtype_ids || self.get_value(),['name', 'default']]).then(self.proxy('display_subtype')); }); }, do_unfollow: function () { - var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); + var context = new session.web.CompoundContext(this.build_context(), {'read_back': true}); + return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('set_value')); }, }); }; diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 5da3456abe9..0ed1d2b38c0 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -19,8 +19,6 @@ # ############################################################################## -import tools - from openerp.tests import common from openerp.tools.html_sanitize import html_sanitize @@ -31,7 +29,7 @@ Received: by mail1.openerp.com (Postfix, from userid 10002) From: Sylvie Lelitre Subject: {subject} MIME-Version: 1.0 -Content-Type: multipart/alternative; +Content-Type: multipart/alternative; boundary="----=_Part_4200734_24778174.1344608186754" Date: Fri, 10 Aug 2012 14:16:26 +0000 Message-ID: <1198923581.41972151344608186760.JavaMail@agrolait.com> @@ -54,9 +52,9 @@ Content-Transfer-Encoding: quoted-printable =20 =20 - +

                    Please call me as soon as possible this afternoon!

                    - +

                    --
                    Sylvie

                    @@ -84,42 +82,15 @@ Sylvie """ -class TestMailMockups(common.TransactionCase): +class test_mail(common.TransactionCase): def _mock_smtp_gateway(self, *args, **kwargs): return True - def _init_mock_build_email(self): - self._build_email_args_list = [] - self._build_email_kwargs_list = [] - def _mock_build_email(self, *args, **kwargs): - self._build_email_args_list.append(args) - self._build_email_kwargs_list.append(kwargs) - return self._build_email(*args, **kwargs) - - def setUp(self): - super(TestMailMockups, self).setUp() - # Install mock SMTP gateway - self._init_mock_build_email() - self._build_email = self.registry('ir.mail_server').build_email - self.registry('ir.mail_server').build_email = self._mock_build_email - self._send_email = self.registry('ir.mail_server').send_email - self.registry('ir.mail_server').send_email = self._mock_smtp_gateway - - def tearDown(self): - # Remove mocks - self.registry('ir.mail_server').build_email = self._build_email - self.registry('ir.mail_server').send_email = self._send_email - super(TestMailMockups, self).tearDown() - - -class test_mail(TestMailMockups): - - def _mock_send_get_mail_body(self, *args, **kwargs): - # def _send_get_mail_body(self, cr, uid, mail, partner=None, context=None) - body = tools.append_content_to_html(args[2].body_html, kwargs.get('partner').name if kwargs.get('partner') else 'No specific partner') - return body + self._build_email_args = args + self._build_email_kwargs = kwargs + return self.build_email_real(*args, **kwargs) def setUp(self): super(test_mail, self).setUp() @@ -135,9 +106,10 @@ class test_mail(TestMailMockups): self.res_users = self.registry('res.users') self.res_partner = self.registry('res.partner') - # Mock send_get_mail_body to test its functionality without other addons override - self._send_get_mail_body = self.registry('mail.mail').send_get_mail_body - self.registry('mail.mail').send_get_mail_body = self._mock_send_get_mail_body + # Install mock SMTP gateway + self.build_email_real = self.registry('ir.mail_server').build_email + self.registry('ir.mail_server').build_email = self._mock_build_email + self.registry('ir.mail_server').send_email = self._mock_smtp_gateway # groups@.. will cause the creation of new mail groups self.mail_group_model_id = self.ir_model.search(self.cr, self.uid, [('model', '=', 'mail.group')])[0] @@ -147,11 +119,6 @@ class test_mail(TestMailMockups): self.group_pigs_id = self.mail_group.create(self.cr, self.uid, {'name': 'Pigs', 'description': 'Fans of Pigs, unite !'}) - def tearDown(self): - # Remove mocks - self.registry('mail.mail').send_get_mail_body = self._send_get_mail_body - super(test_mail, self).tearDown() - def test_00_message_process(self): cr, uid = self.cr, self.uid # Incoming mail creates a new mail_group "frogs" @@ -187,7 +154,7 @@ class test_mail(TestMailMockups): test_msg_id = '' mail_text = MAIL_TEMPLATE_PLAINTEXT.format(to='groups@example.com', subject='frogs', extra='', msg_id=test_msg_id) self.mail_thread.message_process(cr, uid, None, mail_text) - new_mail = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [('message_id', '=', test_msg_id)])[0]) + new_mail = self.mail_message.browse(cr, uid, self.mail_message.search(cr, uid, [('message_id','=',test_msg_id)])[0]) self.assertEqual(new_mail.body, '\n

                    \nPlease call me as soon as possible this afternoon!\n\n--\nSylvie\n
                    \n', 'plaintext mail incorrectly parsed') @@ -308,20 +275,18 @@ class test_mail(TestMailMockups): _attachments = [('First', 'My first attachment'), ('Second', 'My second attachment')] # CASE1: post comment, body and subject specified - self._init_mock_build_email() msg_id = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body1, subject=_subject, type='comment') message = self.mail_message.browse(cr, uid, msg_id) - sent_emails = self._build_email_kwargs_list + sent_email = self._build_email_kwargs # Test: notifications have been deleted self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg_id)]), 'mail.mail notifications should have been auto-deleted!') # Test: mail_message: subject is _subject, body is _body1 (no formatting done) self.assertEqual(message.subject, _subject, 'mail.message subject incorrect') self.assertEqual(message.body, _body1, 'mail.message body incorrect') - # Test: sent_email: email send by server: correct subject, body, body_alternative - for sent_email in sent_emails: - self.assertEqual(sent_email['subject'], _subject, 'sent_email subject incorrect') - self.assertEqual(sent_email['body'], _mail_body1 + '\n
                    Bert Tartopoils
                    \n', 'sent_email body incorrect') - self.assertEqual(sent_email['body_alternative'], _mail_bodyalt1 + '\nBert Tartopoils', 'sent_email body_alternative is incorrect') + # Test: sent_email: email send by server: correct subject, body; body_alternative + self.assertEqual(sent_email['subject'], _subject, 'sent_email subject incorrect') + self.assertEqual(sent_email['body'], _mail_body1, 'sent_email body incorrect') + self.assertEqual(sent_email['body_alternative'], _mail_bodyalt1, 'sent_email body_alternative is incorrect') # Test: mail_message: partner_ids = group followers message_pids = set([partner.id for partner in message.partner_ids]) test_pids = set([p_a_id, p_b_id, p_c_id]) @@ -331,16 +296,14 @@ class test_mail(TestMailMockups): notif_pids = set([notif.partner_id.id for notif in self.mail_notification.browse(cr, uid, notif_ids)]) self.assertEqual(notif_pids, test_pids, 'mail.message notification partners incorrect') # Test: sent_email: email_to should contain b@b, not c@c (pref email), not a@a (writer) - for sent_email in sent_emails: - self.assertEqual(sent_email['email_to'], ['b@b'], 'sent_email email_to is incorrect') + self.assertEqual(sent_email['email_to'], ['b@b'], 'sent_email email_to is incorrect') # CASE2: post an email with attachments, parent_id, partner_ids # TESTS: automatic subject, signature in body_html, attachments propagation - self._init_mock_build_email() msg_id2 = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body2, type='email', partner_ids=[(6, 0, [p_d_id])], parent_id=msg_id, attachments=_attachments) message = self.mail_message.browse(cr, uid, msg_id2) - sent_emails = self._build_email_kwargs_list + sent_email = self._build_email_kwargs self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg_id2)]), 'mail.mail notifications should have been auto-deleted!') # Test: mail_message: subject is False, body is _body2 (no formatting done), parent_id is msg_id @@ -348,11 +311,9 @@ class test_mail(TestMailMockups): self.assertEqual(message.body, html_sanitize(_body2), 'mail.message body incorrect') self.assertEqual(message.parent_id.id, msg_id, 'mail.message parent_id incorrect') # Test: sent_email: email send by server: correct subject, body, body_alternative - self.assertEqual(len(sent_emails), 2, 'sent_email number of sent emails incorrect') - for sent_email in sent_emails: - self.assertEqual(sent_email['subject'], _mail_subject, 'sent_email subject incorrect') - self.assertIn(_mail_body2, sent_email['body'], 'sent_email body incorrect') - self.assertIn(_mail_bodyalt2, sent_email['body_alternative'], 'sent_email body_alternative incorrect') + self.assertEqual(sent_email['subject'], _mail_subject, 'sent_email subject incorrect') + self.assertEqual(sent_email['body'], _mail_body2, 'sent_email body incorrect') + self.assertEqual(sent_email['body_alternative'], _mail_bodyalt2, 'sent_email body_alternative incorrect') # Test: mail_message: partner_ids = group followers message_pids = set([partner.id for partner in message.partner_ids]) test_pids = set([p_a_id, p_b_id, p_c_id, p_d_id]) @@ -362,8 +323,7 @@ class test_mail(TestMailMockups): notif_pids = set([notif.partner_id.id for notif in self.mail_notification.browse(cr, uid, notif_ids)]) self.assertEqual(notif_pids, test_pids, 'mail.message notification partners incorrect') # Test: sent_email: email_to should contain b@b, c@c, not a@a (writer) - for sent_email in sent_emails: - self.assertTrue(set(sent_email['email_to']).issubset(set(['b@b', 'c@c'])), 'sent_email email_to incorrect') + self.assertEqual(set(sent_email['email_to']), set(['b@b', 'c@c']), 'sent_email email_to incorrect') # Test: attachments for attach in message.attachment_ids: self.assertEqual(attach.res_model, 'mail.group', 'mail.message attachment res_model incorrect') @@ -450,14 +410,12 @@ class test_mail(TestMailMockups): self.assertEqual(compose.content_subtype, 'html', 'mail.compose.message incorrect content_subtype') # 2. Post the comment, get created message - parent_id = message.id mail_compose.send_mail(cr, uid, [compose_id]) group_pigs.refresh() message = group_pigs.message_ids[0] - # Test: mail.message: subject as Re:.., body in html, parent_id + # Test: mail.message: subject as Re:.., body in html self.assertEqual(message.subject, _msg_reply, 'mail.message incorrect subject') self.assertIn('Administrator wrote:
                    Pigs rules
                    ', message.body, 'mail.message body is incorrect') - self.assertEqual(message.parent_id and message.parent_id.id, parent_id, 'mail.message parent_id incorrect') # Test: mail.message: attachments for attach in message.attachment_ids: self.assertEqual(attach.res_model, 'mail.group', 'mail.message attachment res_model incorrect') @@ -501,7 +459,6 @@ class test_mail(TestMailMockups): # It will be updated as soon as we have fixed specs ! cr, uid = self.cr, self.uid group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) - def _compare_structures(struct1, struct2, n=0): # print '%scompare structure' % ('\t' * n) self.assertEqual(len(struct1), len(struct2), 'message_read structure number of childs incorrect') @@ -673,10 +630,10 @@ class test_mail(TestMailMockups): _mail_bodyalt2 = 'Pigs rules\nAdmin\n' filter_subtype_id = self.mail_message_subtype.search(cr, uid, [('default','=',True)]) # Post comment with body and subject, comment preference - msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype='email') + msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mail_subtype_comment') notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") # New post: test automatic subject, signature in html, add a partner, email preference, parent_id previous message - msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, type='email', subtype='other') - notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) - self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") +# msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, type='email', subtype='other') +# notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) +# self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") From 6f0b8abe3159831e67434c5938bc867a98b462dd Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 11:05:40 +0530 Subject: [PATCH 096/175] [IMP]account,project,project_issue: changed as per new spec bzr revid: sgo@tinyerp.com-20120913053540-atfsrw8bkf16qo3t --- addons/account/account_invoice.py | 33 ++++++------- addons/account/data/account_data.xml | 26 +++++----- addons/account_voucher/account_voucher.py | 8 ++-- .../account_voucher/account_voucher_data.xml | 21 +++------ addons/analytic/analytic.py | 18 ++++++- addons/base_status/base_stage.py | 14 +++++- addons/project/project.py | 21 ++++----- addons/project/project_data.xml | 47 ++++++++++--------- addons/project_issue/project_issue.py | 4 +- addons/project_issue/project_issue_data.xml | 25 ++++------ 10 files changed, 109 insertions(+), 108 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 9dcbd877c67..8a7251b3856 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -395,23 +395,18 @@ class account_invoice(osv.osv): template_id = template and template[1] or False res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form') res_id = res and res[1] or False - ctx = dict(context) - ctx.update({ - 'default_model': 'account.invoice', - 'default_res_id': ids[0], - 'default_use_template': True, - 'default_template_id': template_id, - }) + ctx = dict(context, active_model='account.invoice', active_id=ids[0]) + ctx.update({'mail.compose.template_id': template_id}) return { - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'mail.compose.message', - 'views': [(res_id, 'form')], - 'view_id': res_id, - 'type': 'ir.actions.act_window', - 'target': 'new', - 'context': ctx, - 'nodestroy': True, + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'mail.compose.message', + 'views': [(res_id, 'form')], + 'view_id': res_id, + 'type': 'ir.actions.act_window', + 'target': 'new', + 'context': ctx, + 'nodestroy': True, } def confirm_paid(self, cr, uid, ids, context=None): @@ -1306,15 +1301,15 @@ class account_invoice(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), subtype="new", context=context) + self.message_post(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), subtype_xml_id="analytic_subtype_new", context=context) def confirm_paid_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), subtype="paid", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_paid", context=context) def invoice_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_cancelled", context=context) account_invoice() class account_invoice_line(osv.osv): diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index bf3b3152552..22849a9b886 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -560,28 +560,24 @@ Invoice account.invoice
                    - + new - + account.analytic.account - + + new + account.invoice + + + paid - + account.invoice - + cancelled - + account.invoice - - - - - - - - - diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index ae670b3d0b7..d2976882981 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1045,8 +1045,6 @@ class account_voucher(osv.osv): # if the amount encoded in voucher is equal to the amount unreconciled, we need to compute the # currency rate difference if line.amount == line.amount_unreconciled: - if not line.move_line_id.amount_residual: - raise osv.except_osv(_('Wrong bank statement line'),_("You have to delete the bank statement line which the payment was reconciled to manually. Please check the payment of the partner %s by the amount of %s.")%(line.voucher_id.partner_id.name, line.voucher_id.amount)) currency_rate_difference = line.move_line_id.amount_residual - amount else: currency_rate_difference = 0.0 @@ -1295,17 +1293,17 @@ class account_voucher(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s created." % self._document_type[obj.type or False] - self.message_post(cr, uid, [obj.id], body=message, subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_new", context=context) def post_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s '%s' is posted." % (self._document_type[obj.type or False], obj.move_id.name) - self.message_post(cr, uid, [obj.id], body=message, subtype="post", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_post", context=context) def reconcile_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s reconciled." % self._document_type[obj.type or False] - self.message_post(cr, uid, [obj.id], body=message, subtype="reconcile", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_reconcile", context=context) account_voucher() diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index a99a8735842..dd46a83777e 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -13,27 +13,18 @@ If you want to use advanced accounting features, you should install the "Account Module eInvoicing & Payments has been installed.
                    - - + + account.voucher - + post - + account.voucher - + reconcile - + account.voucher - - - - - - - - - diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index a44fcb01653..776df713b4e 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -96,6 +96,22 @@ class account_analytic_account(osv.osv): res[row['id']][field] = row[field] return self._compute_level_tree(cr, uid, ids, child_ids, res, fields, context) + def name_get(self, cr, uid, ids, context=None): + if isinstance(ids, (int, long)): + ids=[ids] + if not ids: + return [] + res = [] + for account in self.browse(cr, uid, ids, context=context): + data = [] + acc = account + while acc: + data.insert(0, acc.name) + acc = acc.parent_id + data = ' / '.join(data) + res.append((account.id, data)) + return res + def _complete_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict): res = self.name_get(cr, uid, ids) return dict(res) @@ -281,7 +297,7 @@ class account_analytic_account(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), subtype_xml_id="analytic_subtype_new", context=context) account_analytic_account() diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index 9bb2764d8bd..f72168cde46 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -362,17 +362,27 @@ class base_stage(object): msg = _('%s has been opened.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) self.message_post(cr, uid, [id], body=msg, context=context) return True + + def find_xml_id(self,cr,uid,ids,name,context=None): + subtype_obj = self.pool.get('mail.message.subtype') + irmodel_obj = self.pool.get('ir.model.data') + subtype_id = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) + ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','=',subtype_id)]) + ir_model_browse = irmodel_obj.browse(cr,uid,ir_ids) + return ir_model_browse.name def case_close_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been closed.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, subtype="closed", context=context) + xml_id = self.find_xml_id(cr, uid, ids, name="closed", context) + self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been cancelled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, subtype="cancelled", context=context) + xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context) + self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True def case_pending_send_note(self, cr, uid, ids, context=None): diff --git a/addons/project/project.py b/addons/project/project.py index e1dea8e70c5..412e14fd8fd 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -41,9 +41,8 @@ class project_task_type(osv.osv): 'case_default': fields.boolean('Common to All Projects', help="If you check this field, this stage will be proposed by default on each new project. It will not assign this stage to existing projects."), 'project_ids': fields.many2many('project.project', 'project_task_type_rel', 'type_id', 'project_id', 'Projects'), - 'state': fields.selection(_TASK_STATE, 'Related Status', required=True, - help="The status of your document is automatically changed regarding the selected stage. " \ - "For example, if a stage is related to the status 'Close', when your document reaches this stage, it is automatically closed."), + 'state': fields.selection(_TASK_STATE, 'State', required=True, + help="The related state for the stage. The state of your document will automatically change regarding the selected stage. Example, a stage is related to the state 'Close', when your document reach this stage, it will be automatically closed."), 'fold': fields.boolean('Hide in views if empty', help="This stage is not visible, for example in status bar or kanban view, when there are no records in that stage to display."), } @@ -514,23 +513,23 @@ def Project(): return project_id def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Project has been created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Project has been created."), subtype_xml_id="project_subtype_new", context=context) def set_open_send_note(self, cr, uid, ids, context=None): message = _("Project has been opened.") - return self.message_post(cr, uid, ids, body=message, subtype="open", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_open", context=context) def set_pending_send_note(self, cr, uid, ids, context=None): message = _("Project is now pending.") - return self.message_post(cr, uid, ids, body=message, subtype="pending", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_pending", context=context) def set_cancel_send_note(self, cr, uid, ids, context=None): message = _("Project has been cancelled.") - return self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_cancelled", context=context) def set_close_send_note(self, cr, uid, ids, context=None): message = _("Project has been closed.") - return self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_closed", context=context) def write(self, cr, uid, ids, vals, context=None): # if alias_model has been changed, update alias_model_id accordingly @@ -728,7 +727,7 @@ class task(base_stage, osv.osv): When the case is over, the state is set to \'Done\'.\ If the case needs to be reviewed then the state is \ set to \'Pending\'.'), - 'categ_ids': fields.many2many('project.category', string='Tags'), + 'categ_ids': fields.many2many('project.category', string='Categories'), 'kanban_state': fields.selection([('normal', 'Normal'),('blocked', 'Blocked'),('done', 'Ready To Pull')], 'Kanban State', help="A task's kanban state indicates special situations affecting it:\n" " * Normal is the default situation\n" @@ -1231,10 +1230,10 @@ class task(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="task_subtype_stage_change", context=context) def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Task has been created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Task has been created."), subtype_xml_id="task_subtype_new", context=context) def case_draft_send_note(self, cr, uid, ids, context=None): msg = _('Task has been set as draft.') diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index 34608d3abeb..0544b6d4e78 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -85,43 +85,48 @@ - + new - + project.project - + + new + project.task + + + open - + project.project - + pending - + project.project - + closed - + project.project - + + closed + project.task + + cancelled - + project.project - + + cancelled + project.task + + + stage change - + project.task - - - - - - - - - diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index d3f47ba9b3e..83eddb83d5e 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -503,7 +503,7 @@ class project_issue(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="issue_subtype_stage_change", context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): """ Override of default prefix for notifications. """ @@ -515,7 +515,7 @@ class project_issue(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Project issue created.") - return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="issue_subtype_new", context=context) def case_escalate_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml index 6ee704c6b39..f6c225a4d00 100644 --- a/addons/project_issue/project_issue_data.xml +++ b/addons/project_issue/project_issue_data.xml @@ -32,33 +32,24 @@ - + new - + project.issue - + stage change - + project.issue - + cancelled - + project.issue - + closed - - - - - - - - - - + project.issue From 8ca3f76711df87f17e2514dec84f63b82fee2ab7 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 11:59:28 +0530 Subject: [PATCH 097/175] [IMP]code improvement and other minor changes bzr revid: sgo@tinyerp.com-20120913062928-hvqnp116y49yrl4d --- addons/account/data/account_data.xml | 6 +----- addons/analytic/__openerp__.py | 3 ++- addons/analytic/analytic_data.xml | 10 ++++++++++ addons/base_status/base_stage.py | 11 +++++++---- addons/crm/crm_lead_data.xml | 5 +++++ 5 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 addons/analytic/analytic_data.xml diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index 22849a9b886..7689ca2c253 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -560,11 +560,7 @@ Invoice account.invoice - - new - account.analytic.account - - + new account.invoice diff --git a/addons/analytic/__openerp__.py b/addons/analytic/__openerp__.py index 10762a1d2be..d90b2fd62ac 100644 --- a/addons/analytic/__openerp__.py +++ b/addons/analytic/__openerp__.py @@ -38,7 +38,8 @@ that have no counterpart in the general financial accounts. 'security/analytic_security.xml', 'security/ir.model.access.csv', 'analytic_sequence.xml', - 'analytic_view.xml' + 'analytic_view.xml', + 'analytic_data.xml' ], 'demo': [], 'installable': True, diff --git a/addons/analytic/analytic_data.xml b/addons/analytic/analytic_data.xml new file mode 100644 index 00000000000..cfd3b5e9b78 --- /dev/null +++ b/addons/analytic/analytic_data.xml @@ -0,0 +1,10 @@ + + + + + new + account.analytic.account + + + + \ No newline at end of file diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index f72168cde46..4b1cc3c6946 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -367,21 +367,24 @@ class base_stage(object): subtype_obj = self.pool.get('mail.message.subtype') irmodel_obj = self.pool.get('ir.model.data') subtype_id = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) - ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','=',subtype_id)]) + ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','in',subtype_id)]) + xml_id = False ir_model_browse = irmodel_obj.browse(cr,uid,ir_ids) - return ir_model_browse.name + if ir_model_browse: + xml_id = ir_model_browse[0].name + return xml_id def case_close_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been closed.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - xml_id = self.find_xml_id(cr, uid, ids, name="closed", context) + xml_id = self.find_xml_id(cr, uid, ids, name="closed", context=context) self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been cancelled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context) + xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context=context) self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 252e843cf30..633782ed233 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -174,5 +174,10 @@ crm.lead + + cancelled + crm.lead + + From 296ae6e24baa8918331d57c7c8e21b21a82cb4bc Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:11:01 +0530 Subject: [PATCH 098/175] [IMP]event:changed in event module as per new spec bzr revid: sgo@tinyerp.com-20120913064101-85pfg3kbbqnoufzx --- addons/event/event.py | 20 +++++++++---------- addons/event/event_data.xml | 39 ++++++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/addons/event/event.py b/addons/event/event.py index 8c755456d9c..82c0390ee03 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -287,27 +287,27 @@ class event_event(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Event has been created.") - self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_new", context=context) return True def button_cancel_send_note(self, cr, uid, ids, context=None): message = _("Event has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_cancelled", context=context) return True def button_draft_send_note(self, cr, uid, ids, context=None): message = _("Event has been set to draft.") - self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_new", context=context) return True def button_done_send_note(self, cr, uid, ids, context=None): message = _("Event has been done.") - self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_closed", context=context) return True def button_confirm_send_note(self, cr, uid, ids, context=None): message = _("Event has been confirmed.") - self.message_post(cr, uid, ids, body=message, subtype="confirmed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_confirmed", context=context) return True event_event() @@ -353,7 +353,7 @@ class event_registration(osv.osv): return self.write(cr, uid, ids, {'state': 'draft'}, context=context) def confirm_registration(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_('State set to open'), context=context) + self.message_post(cr, uid, ids, body=_('State set to open'),subtype_xml_id="registration_subtype_confirmed", context=context) return self.write(cr, uid, ids, {'state': 'open'},context=context) def create(self, cr, uid, vals, context=None): @@ -383,13 +383,13 @@ class event_registration(osv.osv): if today >= registration.event_id.date_begin: values = {'state': 'done', 'date_closed': today} self.write(cr, uid, ids, values) - self.message_post(cr, uid, ids, body=_('State set to Done'), subtype="closed", context=context) + self.message_post(cr, uid, ids, body=_('State set to Done'), subtype_xml_id="registration_subtype_closed", context=context) else: raise osv.except_osv(_('Error!'),_("You must wait for the starting day of the event to do this action.") ) return True def button_reg_cancel(self, cr, uid, ids, context=None, *args): - self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype_xml_id="registration_subtype_cancelled", context=context) return self.write(cr, uid, ids, {'state': 'cancel'}) def mail_user(self, cr, uid, ids, context=None): @@ -459,12 +459,12 @@ class event_registration(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Registration has been created.") - self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="registration_subtype_new", context=context) return True def do_draft_send_note(self, cr, uid, ids, context=None): message = _("Registration has been set as draft.") - self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="registration_subtype_new", context=context) return True event_registration() diff --git a/addons/event/event_data.xml b/addons/event/event_data.xml index 608dcdb4e8f..814fd0b179c 100644 --- a/addons/event/event_data.xml +++ b/addons/event/event_data.xml @@ -12,34 +12,51 @@ automatic 100 - + + new + event.event - + closed + event.event - + cancelled + event.event - + confirmed + event.event - - - - - + + + + new + event.registration + - - + + closed + event.registration + + cancelled + event.event + + + + confirmed + event.registration + + From 66e8595b01b0c1d38190b1222d0955b710b6c1db Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:28:54 +0530 Subject: [PATCH 099/175] [IMP]changed in all hr module for subtype bzr revid: sgo@tinyerp.com-20120913065854-7y5jkls3q2jebduv --- addons/hr_holidays/hr_holidays.py | 6 ++-- addons/hr_holidays/hr_holidays_data.xml | 21 ++++---------- addons/hr_recruitment/hr_recruitment.py | 14 ++++----- addons/hr_recruitment/hr_recruitment_data.xml | 29 +++++++------------ .../hr_timesheet_invoice.py | 8 ++--- .../hr_timesheet_invoice_data.xml | 25 +++++----------- 6 files changed, 38 insertions(+), 65 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 4136abbb2f7..4e85313e2e4 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -364,7 +364,7 @@ class hr_holidays(osv.osv): def create_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, ids, - _("The request has been created and is waiting confirmation."),subtype="new", context=context) + _("The request has been created and is waiting confirmation."),subtype_xml_id="hr_holidays_subtype_new", context=context) return True def holidays_confirm_notificate(self, cr, uid, ids, context=None): @@ -384,12 +384,12 @@ class hr_holidays(osv.osv): _("The request has been double validated. The validation process is now over."), context=context) else: self.message_post(cr, uid, [obj.id], - _("The request has been approved. The validation process is now over."), subtype="approved", context=context) + _("The request has been approved. The validation process is now over."), subtype_xml_id="hr_holidays_subtype_approved", context=context) def holidays_refuse_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been refused. The validation process is now over."), subtype="refused", context=context) + _("The request has been refused. The validation process is now over."), subtype_xml_id="hr_holidays_subtype_refused", context=context) class resource_calendar_leaves(osv.osv): diff --git a/addons/hr_holidays/hr_holidays_data.xml b/addons/hr_holidays/hr_holidays_data.xml index ad337b72c62..8ddfb79a527 100644 --- a/addons/hr_holidays/hr_holidays_data.xml +++ b/addons/hr_holidays/hr_holidays_data.xml @@ -50,28 +50,19 @@ Once validated, they are visible in the employee's calendar. HR officers can def brown - + new - + hr.holidays - + approved - + hr.holidays - + refused - + hr.holidays - - - - - - - - - diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 25be4f3c3f1..6d38c4e4e08 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -461,14 +461,14 @@ class hr_applicant(base_stage, osv.Model): """ Override of the (void) default notification method. """ if not stage_id: return True stage_name = self.pool.get('hr.recruitment.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype="stage change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="hr_recruitment_subtype_stage_change", context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): return 'Applicant' def case_open_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been set in progress.") - return self.message_post(cr, uid, ids, body=message, subtype="in progress", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_in_progress", context=context) def case_close_send_note(self, cr, uid, ids, context=None): if context is None: @@ -476,23 +476,23 @@ class hr_applicant(base_stage, osv.Model): for applicant in self.browse(cr, uid, ids, context=context): if applicant.emp_id: message = _("Applicant has been hired and created as an employee.") - self.message_post(cr, uid, [applicant.id], body=message, subtype="hired", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="hr_recruitment_subtype_hired", context=context) else: message = _("Applicant has been hired.") - self.message_post(cr, uid, [applicant.id], body=message, subtype="hired", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="hr_recruitment_subtype_hired", context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): msg = 'Applicant refused.' - return self.message_post(cr, uid, ids, body=msg, subtype="refused", context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id="hr_recruitment_subtype_refused", context=context) def case_reset_send_note(self, cr, uid, ids, context=None): message =_("Applicant has been set as new.") - return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_new", context=context) def create_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been created.") - return self.message_post(cr, uid, ids, body=message, subtype="new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_new", context=context) class hr_job(osv.osv): diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index 30ff9118584..dedeb20a3dc 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -462,38 +462,29 @@ You can automatically receive job application though an email gateway, see the H - + new - + hr.applicant - + hired - + hr.applicant - + refused - + hr.applicant - + stage change - + hr.applicant - + in progress - + hr.applicant - - - - - - - - - diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 4ed61119a5f..e3f54609e95 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -95,25 +95,25 @@ class account_analytic_account(osv.osv): def set_close(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'close'}, context=context) message = _("Contract has been closed.") - self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_closed", context=context) return True def set_cancel(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'cancelled'}, context=context) message = _("Contract has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_invoice_subtype_cancelled", context=context) return True def set_open(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'open'}, context=context) message = _("Contract has been opened.") - self.message_post(cr, uid, ids, body=message, subtype="open", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_open", context=context) return True def set_pending(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'pending'}, context=context) message = _("Contract has been set as pending.") - self.message_post(cr, uid, ids, body=message, subtype="pending", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_pending", context=context) return True account_analytic_account() diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml index 5cc5024d591..29a3233f509 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml @@ -17,32 +17,23 @@ 50.0 - + closed - + account.analytic.account - + pending - + account.analytic.account - + open - + account.analytic.account - + cancelled - + account.analytic.account - - - - - - - - - From 97026e96d30c103a6873f66da0e50b4f47ece37f Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:33:33 +0530 Subject: [PATCH 100/175] [IMP]changed in idea for subtype bzr revid: sgo@tinyerp.com-20120913070333-8mvke4g0h13r6e6d --- addons/idea/idea.py | 8 ++++---- addons/idea/idea_data.xml | 25 ++++++++----------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/addons/idea/idea.py b/addons/idea/idea.py index e33c9b99014..f8346ec2bba 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -67,21 +67,21 @@ class idea_idea(osv.osv): def idea_cancel(self, cr, uid, ids, context={}): self.write(cr, uid, ids, { 'state': 'cancel' }) - self.message_post(cr, uid, ids, body=_('Idea cancelled.'), subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=_('Idea cancelled.'), subtype_xml_id="idea_subtype_cancelled", context=context) return True def idea_open(self, cr, uid, ids, context={}): self.write(cr, uid, ids, { 'state': 'open'}) - self.message_post(cr, uid, ids, body=_('Idea accepted.'), subtype="open", context=context) + self.message_post(cr, uid, ids, body=_('Idea accepted.'), subtype_xml_id="idea_subtype_open", context=context) return True def idea_close(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea closed.'), subtype="closed", context=context) + self.message_post(cr, uid, ids, body=_('Idea closed.'), subtype_xml_id="idea_subtype_closed", context=context) self.write(cr, uid, ids, { 'state': 'close' }) return True def idea_draft(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), subtype="new", context=context) + self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), subtype_xml_id="idea_subtype_new", context=context) self.write(cr, uid, ids, { 'state': 'draft' }) return True idea_idea() diff --git a/addons/idea/idea_data.xml b/addons/idea/idea_data.xml index 36ccf2e992e..b4f3f70d2dd 100644 --- a/addons/idea/idea_data.xml +++ b/addons/idea/idea_data.xml @@ -17,32 +17,23 @@ - + new - + idea.idea - + open - + idea.idea - + cancelled - + idea.idea - + closed - - - - - - - - - - + idea.idea From fa5f1e174e8e0c525edc6e5a43a3d0681a11d77c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:44:30 +0530 Subject: [PATCH 101/175] [IMP]changed in mrp and mrp_operations for subtype bzr revid: sgo@tinyerp.com-20120913071430-o7bml82s6tgnwn4h --- addons/mrp/mrp.py | 10 +++---- addons/mrp/mrp_data.xml | 29 +++++++------------- addons/mrp_operations/mrp_operation_data.xml | 29 +++++++------------- addons/mrp_operations/mrp_operations.py | 10 +++---- 4 files changed, 30 insertions(+), 48 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 40d8d1b7e5f..bc0baae71e8 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1044,27 +1044,27 @@ class mrp_production(osv.osv): # --------------------------------------------------- def create_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), subtype="new", context=context) + self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), subtype_xml_id="mrp_subtype_new", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been canceled.") - self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_cancelled", context=context) return True def action_ready_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is ready to produce.") - self.message_post(cr, uid, ids, body=message, subtype="ready", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_ready", context=context) return True def action_in_production_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is in production.") - self.message_post(cr, uid, ids, body=message, subtype="production", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_production", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been done.") - self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_closed", context=context) return True def action_confirm_send_note(self, cr, uid, ids, context=None): diff --git a/addons/mrp/mrp_data.xml b/addons/mrp/mrp_data.xml index 6ee7cc82dd2..3740f03bdc8 100644 --- a/addons/mrp/mrp_data.xml +++ b/addons/mrp/mrp_data.xml @@ -27,38 +27,29 @@ From the Manufacturing Settings, you can choose to compute production schedules 1 - + new - + mrp.production - + ready - + mrp.production - + production - + mrp.production - + cancelled - + mrp.production - + closed - + mrp.production - - - - - - - - - diff --git a/addons/mrp_operations/mrp_operation_data.xml b/addons/mrp_operations/mrp_operation_data.xml index e2d7f9f0a56..812ce3da536 100644 --- a/addons/mrp_operations/mrp_operation_data.xml +++ b/addons/mrp_operations/mrp_operation_data.xml @@ -31,38 +31,29 @@ - + new - + mrp.production.workcenter.line - + started - + mrp.production.workcenter.line - + pending - + mrp.production.workcenter.line - + cancelled - + mrp.production.workcenter.line - + closed - + mrp.production.workcenter.line - - - - - - - - - diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index a18eb4141ba..6ed636850f1 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -224,7 +224,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been created for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="new", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="new", context=context) return True def action_start_send_note(self, cr, uid, ids, context=None): @@ -232,7 +232,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been started for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="started", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="started", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): @@ -240,7 +240,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been done for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="closed", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="closed", context=context) return True def action_pending_send_note(self, cr, uid, ids, context=None): @@ -248,7 +248,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order is pending for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="pending", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="pending", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): @@ -256,7 +256,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been cancelled for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="cancelled", context=context) return True mrp_production_workcenter_line() From 2e7de7cf6fad0212d3d2a8953fba64d8b5aa77a2 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:50:05 +0530 Subject: [PATCH 102/175] [IMP]changed in mrp_repair for subtype bzr revid: sgo@tinyerp.com-20120913072005-cmlf91arfwpxnv6o --- addons/mrp_repair/mrp_repair.py | 14 +++++----- addons/mrp_repair/mrp_repair_data.xml | 37 ++++++++++----------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index 44624044090..202f9efd391 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -571,40 +571,40 @@ class mrp_repair(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Repair Order for %s has been created." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, subtype="new", context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype_xml_id="mrp_repair_subtype_new", context=context) return True def set_start_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Repair Order for %s has been started." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, subtype="started", context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype_xml_id="mrp_repair_subtype_started", context=context) return True def set_toinvoiced_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _("Draft Invoice of %s %s waiting for validation.") % (repair.invoice_id.amount_total, repair.invoice_id.currency_id.symbol) - self.message_post(cr, uid, [repair.id], body=message, subtype="pending", context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype_xml_id="mrp_repair_subtype_pending", context=context) return True def set_confirm_send_note(self, cr, uid, ids, context=None): for repair in self.browse(cr, uid, ids, context): message = _( "Repair Order for %s has been accepted." % (repair.product_id.name)) - self.message_post(cr, uid, [repair.id], body=message, subtype="accepted", context=context) + self.message_post(cr, uid, [repair.id], body=message, subtype_xml_id="mrp_repair_subtype_accepted", context=context) return True def set_cancel_send_note(self, cr, uid, ids, context=None): message = _("Repair has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_repair_subtype_cancelled", context=context) return True def set_ready_send_note(self, cr, uid, ids, context=None): message = _("Repair Order is now ready to repair.") - self.message_post(cr, uid, ids, body=message, subtype="ready", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_repair_subtype_ready", context=context) return True def set_done_send_note(self, cr, uid, ids, context=None): message = _("Repair Order is closed.") - self.message_post(cr, uid, ids, body=message, subtype="closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_repair_subtype_closed", context=context) return True mrp_repair() diff --git a/addons/mrp_repair/mrp_repair_data.xml b/addons/mrp_repair/mrp_repair_data.xml index b45b7ec3105..6414e07f713 100644 --- a/addons/mrp_repair/mrp_repair_data.xml +++ b/addons/mrp_repair/mrp_repair_data.xml @@ -1,47 +1,38 @@ - + new - + mrp.repair - + started - + mrp.repair - + ready - + mrp.repair - + pending - + mrp.repair - + accepted - + mrp.repair - + cancelled - + mrp.repair - + closed - + mrp.repair - - - - - - - - - From 2e3f2e2458d71cdf693c6ec97e3d9cc28d4a6e75 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 12:59:49 +0530 Subject: [PATCH 103/175] [IMP]changed in procurement for subtype bzr revid: sgo@tinyerp.com-20120913072949-pny1yj3ke2gj2rr3 --- addons/procurement/procurement.py | 12 ++++----- addons/procurement/procurement_data.xml | 35 ++++++++++--------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 1cb695663df..dcb47f1af88 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -496,22 +496,22 @@ class procurement_order(osv.osv): return obj_id def create_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been created."), subtype="new", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been created."), subtype_xml_id="procurement_subtype_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been confirmed."), subtype="confirmed", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been confirmed."), subtype_xml_id="procurement_subtype_confirmed", context=context) def running_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been set to running."), subtype="running", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been set to running."), subtype_xml_id="procurement_subtype_running", context=context) def ready_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), subtype="ready", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), subtype_xml_id="procurement_subtype_ready", context=context) def cancel_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), subtype_xml_id="procurement_subtype_cancelled", context=context) def done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype="closed", context=context) + self.message_post(cr, uid, ids, body=_("Procurement has been done."), subtype_xml_id="procurement_subtype_closed", context=context) procurement_order() diff --git a/addons/procurement/procurement_data.xml b/addons/procurement/procurement_data.xml index 1f60977c4dd..950c487ae53 100644 --- a/addons/procurement/procurement_data.xml +++ b/addons/procurement/procurement_data.xml @@ -32,36 +32,29 @@ - - + + new + procurement.order - + confirmed - + procurement.order - + ready - + procurement.order - + running - + procurement.order - - + + cancelled + procurement.order - + closed - - - - - - - - - - + procurement.order \ No newline at end of file From ad6e9d96e4d6f0f33f48415e13ffebcaf7992b77 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:27:27 +0530 Subject: [PATCH 104/175] [IMP]changed in sale module for subtype update specification bzr revid: sgo@tinyerp.com-20120913085727-7swp0404g99fkf7l --- addons/stock/stock.py | 18 +++++++++++++----- addons/stock/stock_data.xml | 29 +++++++++++++---------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index d577e69e237..50e85fa5191 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1379,13 +1379,13 @@ class stock_picking(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), subtype_xml_id="stock_in_subtype_new", context=context) def scrap_send_note(self, cr, uid, ids, quantity, uom, name, context=None): - return self.message_post(cr, uid, ids, body= _("%s %s %s has been moved to scrap.") % (quantity, uom, name), subtype="moved", context=context) + return self.message_post(cr, uid, ids, body= _("%s %s %s has been moved to scrap.") % (quantity, uom, name),context=context) def back_order_send_note(self, cr, uid, ids, back_name, context=None): - return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), subtype_xml_id="stock_in_subtype_new", context=context) def ship_done_send_note(self, cr, uid, ids, context=None): type_dict = { @@ -1393,12 +1393,20 @@ class stock_picking(osv.osv): 'in': 'received', 'internal': 'moved', } + xml_id_dict = { + 'out':'stock_out_subtype_delivered', + 'in' : 'stock_in_subtype_received' + } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype=type_dict.get(obj.type), context=context) + self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype_xml_id=xml_id_dict.get(obj.type), context=context) def ship_cancel_send_note(self, cr, uid, ids, context=None): + xml_id_dict = { + 'out':'stock_out_subtype_cancelled', + 'in' : 'stock_in_subtype_cancelled' + } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype_xml_id=xml_id_dict.get(obj.type), context=context) stock_picking() diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index f83b0ada388..a59642fa912 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -170,30 +170,27 @@ watch your stock valuation, and track production lots upstream and downstream (b - - + + new + stock.picking.in - + delivered - + stock.picking.out - + received - + stock.picking.in - - + + cancelled + stock.picking.in - - - - - - - - + + cancelled + stock.picking.out From 986e5817d18b149c3d31cc8c123b878a3e6b62b9 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:32:12 +0530 Subject: [PATCH 105/175] [IMP]changed in sale module for subtype update specification bzr revid: sgo@tinyerp.com-20120913090212-8c9jgb38x1d6517j --- addons/sale/sale.py | 10 +++++----- addons/sale/sale_data.xml | 29 ++++++++++------------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 0af625ed7d9..0f01909ac7f 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1032,7 +1032,7 @@ class sale_order(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), subtype_xml_id="sale_subtype_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -1040,7 +1040,7 @@ class sale_order(osv.osv): def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype_xml_id="sale_subtype_cancelled", context=context) def delivery_send_note(self, cr, uid, ids, picking_id, context=None): for order in self.browse(cr, uid, ids, context=context): @@ -1052,15 +1052,15 @@ class sale_order(osv.osv): self.message_post(cr, uid, [order.id], body=_("Delivery Order %s scheduled for %s.") % (picking.name, picking_date_str), context=context) def delivery_end_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Order delivered."), subtype="delivered", context=context) + self.message_post(cr, uid, ids, body=_("Order delivered."), subtype_xml_id="sale_subtype_delivered", context=context) def invoice_paid_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype="paid", context=context) + self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype_xml_id="sale_subtype_paid", context=context) def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype="pending", context=context) + self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype_xml_id="sale_subtype_pending", context=context) def action_cancel_draft_send_note(self, cr, uid, ids, context=None): return self.message_post(cr, uid, ids, body=_('Sale order set to draft.'), context=context) diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml index 2f4b81b27f4..4eca7f60c8f 100644 --- a/addons/sale/sale_data.xml +++ b/addons/sale/sale_data.xml @@ -50,37 +50,28 @@ If you need to manage your sales pipeline (leads, opportunities, phonecalls), you can install the module <i>CRM</i> from the top menu Settings.
                    - + new - + sale.order - + cancelled - + sale.order - + paid - + sale.order - + pending - + sale.order - + delivered - - - - - - - - - - + sale.order From c67edb99bb891c468fedb6b4a373fe9da1843ebc Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:38:34 +0530 Subject: [PATCH 106/175] [IMP]changed in purchase module for subtype update specification bzr revid: sgo@tinyerp.com-20120913090834-5lf57kikymrzsg8z --- addons/purchase/purchase.py | 12 ++++++------ addons/purchase/purchase_data.xml | 29 ++++++++++------------------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index c950c852261..b0f10d3f71f 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -740,7 +740,7 @@ class purchase_order(osv.osv): return [('state', '=', 'draft')] def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Request for quotation created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Request for quotation created."), subtype_xml_id="purchase_subtype_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -758,20 +758,20 @@ class purchase_order(osv.osv): def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype="pending", context=context) + self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype_xml_id="purchase_subtype_pending", context=context) def shipment_done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("""Shipment received."""), subtype="received", context=context) + self.message_post(cr, uid, ids, body=_("""Shipment received."""), subtype_xml_id="purchase_subtype_received", context=context) def invoice_done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype="paid", context=context) + self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype_xml_id="purchase_subtype_paid", context=context) def draft_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Purchase Order has been set to draft."), context=context) + return self.message_post(cr, uid, ids, body=_("Purchase Order has been set to draft."), subtype_xml_id="purchase_subtype_new", context=context) def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype_xml_id="purchase_subtype_cancelled", context=context) purchase_order() diff --git a/addons/purchase/purchase_data.xml b/addons/purchase/purchase_data.xml index a84564b2360..aa62e84e19d 100644 --- a/addons/purchase/purchase_data.xml +++ b/addons/purchase/purchase_data.xml @@ -49,37 +49,28 @@ You can also manage purchase requisitions, see also the Purchase Settings. - + new - + purchase.order - + paid - + purchase.order - + pending - + purchase.order - + received - + purchase.order - + cancelled - + purchase.order - - - - - - - - - From 9524b34e314511191fc2c2265a44e5c9594f645c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:42:08 +0530 Subject: [PATCH 107/175] [IMP]changed in purchase_requisition module for subtype update specification bzr revid: sgo@tinyerp.com-20120913091208-si6e042trpzdyq6m --- .../purchase_requisition.py | 8 +++---- .../purchase_requisition_data.xml | 23 +++++++------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index a3df366381d..5d8d2bb2f87 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -94,13 +94,13 @@ class purchase_requisition(osv.osv): self.message_post(cr, uid, ids, body=_("Draft Requisition has been sent to suppliers."), context=context) def reset_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype="new", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype_xml_id="requisition_subtype_new", context=context) def done_to_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype="closed", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype_xml_id="requisition_subtype_closed", context=context) def cancel_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), subtype="cancelled", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), subtype_xml_id="requisition_subtype_cancelled", context=context) def _planned_date(self, requisition, delay=0.0): company = requisition.company_id @@ -184,7 +184,7 @@ class purchase_requisition(osv.osv): return res def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Purchase Requisition has been created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Purchase Requisition has been created."), subtype_xml_id="requisition_subtype_new", context=context) def create(self, cr, uid, vals, context=None): requisition = super(purchase_requisition, self).create(cr, uid, vals, context=context) diff --git a/addons/purchase_requisition/purchase_requisition_data.xml b/addons/purchase_requisition/purchase_requisition_data.xml index 2b22c2057a1..534bf2fe2a7 100644 --- a/addons/purchase_requisition/purchase_requisition_data.xml +++ b/addons/purchase_requisition/purchase_requisition_data.xml @@ -7,24 +7,17 @@ model="ir.values" name="set"/> - + closed - + purchase.requisition - - + + new + purchase.requisition - - - - - - - - - - - + + cancelled + purchase.requisition \ No newline at end of file From 18ceddcf2ee7086fe2e2d512e415064986febf9c Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:45:02 +0530 Subject: [PATCH 108/175] [IMP]minor changes bzr revid: sgo@tinyerp.com-20120913091502-dvlpgoa3dr72km04 --- addons/event/event_data.xml | 4 ---- addons/mail/tests/test_mail.py | 4 ---- 2 files changed, 8 deletions(-) diff --git a/addons/event/event_data.xml b/addons/event/event_data.xml index 814fd0b179c..bc7f71ef664 100644 --- a/addons/event/event_data.xml +++ b/addons/event/event_data.xml @@ -16,24 +16,20 @@ new event.event - closed event.event - cancelled event.event - confirmed event.event - diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index e3718d23855..9b0586d5d5c 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -636,7 +636,3 @@ class test_mail(common.TransactionCase): msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mail_subtype_comment') notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") - # New post: test automatic subject, signature in html, add a partner, email preference, parent_id previous message -# msg_id2 = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body2,subject=_subject, type='email', subtype='other') -# notif_ids2 = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id2)]) -# self.assertTrue(len(notif_ids2) == 0,"subtype is false cannot show notification on wall") From e6eafcaf22aa4c84ca751f1e6cd2f06a0833c987 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 14:47:57 +0530 Subject: [PATCH 109/175] [IMP]minor changes in account bzr revid: sgo@tinyerp.com-20120913091757-6izlnq34z3v9jd7n --- addons/account_voucher/account_voucher_data.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index dd46a83777e..a59993aae6b 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -14,6 +14,7 @@ If you want to use advanced accounting features, you should install the "Account + new account.voucher From 53a67e065236f549cd07b35406cc59181417ee55 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 15:12:09 +0530 Subject: [PATCH 110/175] [IMP]change in mrp bzr revid: sgo@tinyerp.com-20120913094209-4r0laz8gtmcz1tsq --- addons/mrp_operations/mrp_operations.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index 6ed636850f1..53eaceed066 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -224,7 +224,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been created for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="new", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_new", context=context) return True def action_start_send_note(self, cr, uid, ids, context=None): @@ -232,7 +232,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been started for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="started", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_started", context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): @@ -240,7 +240,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been done for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="closed", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_closed", context=context) return True def action_pending_send_note(self, cr, uid, ids, context=None): @@ -248,7 +248,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order is pending for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="pending", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_pending", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): @@ -256,7 +256,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been cancelled for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="cancelled", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_cancelled", context=context) return True mrp_production_workcenter_line() From 458899673b2d06572ea68b1874b56767d7966a76 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 15:33:07 +0530 Subject: [PATCH 111/175] [IMP]change in mrp operations openerp.py bzr revid: sgo@tinyerp.com-20120913100307-4f49x1my6ajzzfiz --- addons/mrp_operations/__openerp__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mrp_operations/__openerp__.py b/addons/mrp_operations/__openerp__.py index a5bda80f924..ba2e2d88637 100644 --- a/addons/mrp_operations/__openerp__.py +++ b/addons/mrp_operations/__openerp__.py @@ -58,6 +58,7 @@ So, that we can compare the theoretic delay and real delay. 'depends': ['mrp'], 'data': [ 'security/ir.model.access.csv', + 'mrp_operation_data.xml', 'mrp_operations_workflow.xml', 'mrp_operations_view.xml', 'mrp_operations_report.xml', @@ -65,7 +66,7 @@ So, that we can compare the theoretic delay and real delay. 'process/mrp_operation_process.xml', 'mrp_operations_workflow_instance.xml' ], - 'demo': ['mrp_operation_data.xml', + 'demo': [ 'mrp_operations_demo.yml' ], 'test': [ From 17987c7e2c71a695a5d3fcff324c29067ba6b7ab Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 15:54:56 +0530 Subject: [PATCH 112/175] [IMP]crm yml improve for subtype bzr revid: sgo@tinyerp.com-20120913102456-c74asnmmh6kx5270 --- addons/crm/test/process/crm_message_subtype.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index 3dd042c1279..46c6aae7bf4 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -3,24 +3,21 @@ - !record {model: mail.message.subtype, id: mail.mail_subtype_won }: name: won - model_ids: - - crm.model_crm_lead + res_model:crm.lead default: False - I have add the sub_type name email with default true - !record {model: mail.message.subtype, id: mail.mail_subtype_email }: name: email - model_ids: - - crm.model_crm_lead + res_model:crm.lead default: True - I have add the sub_type name comment with default true - !record {model: mail.message.subtype, id: mail.mail_subtype_comment }: name: comment - model_ids: - - crm.model_crm_lead + res_model:crm.lead default: True - I have add the subtypes as won in feeds From d5687b3ed0538d095cc8209c1de78de1a10448b6 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 16:15:18 +0530 Subject: [PATCH 113/175] [IMP]crm yml improve bzr revid: sgo@tinyerp.com-20120913104518-6cse5m221l8n5yc4 --- addons/crm/test/process/crm_message_subtype.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index 46c6aae7bf4..a1ad9a9c39a 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -3,22 +3,14 @@ - !record {model: mail.message.subtype, id: mail.mail_subtype_won }: name: won - res_model:crm.lead + res_model: crm.lead default: False -- - I have add the sub_type name email with default true -- - !record {model: mail.message.subtype, id: mail.mail_subtype_email }: - name: email - res_model:crm.lead - default: True - I have add the sub_type name comment with default true - !record {model: mail.message.subtype, id: mail.mail_subtype_comment }: name: comment - res_model:crm.lead - default: True + res_model: crm.lead - I have add the subtypes as won in feeds - From f554db5c6bc94b3e9fdf5aa67a0030cbb4026df2 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 17:10:44 +0530 Subject: [PATCH 114/175] [IMP]add subtype for crm_claim bzr revid: sgo@tinyerp.com-20120913114044-0spnm47pty5g04wu --- addons/crm_claim/crm_claim.py | 6 +++--- addons/crm_claim/crm_claim_data.xml | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py index 535f6d20367..ce2427b9752 100644 --- a/addons/crm_claim/crm_claim.py +++ b/addons/crm_claim/crm_claim.py @@ -238,16 +238,16 @@ class crm_claim(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): msg = _('Claim has been created.') - return self.message_post(cr, uid, ids, body=msg, context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='claim_subtype_new', context=context) def case_refuse_send_note(self, cr, uid, ids, context=None): msg = _('Claim has been refused.') - return self.message_post(cr, uid, ids, body=msg, context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='claim_subtype_refused', context=context) def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.claim.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id='claim_subtype_stage_change', context=context) class res_partner(osv.osv): diff --git a/addons/crm_claim/crm_claim_data.xml b/addons/crm_claim/crm_claim_data.xml index 33bd280c364..a72c285f506 100644 --- a/addons/crm_claim/crm_claim_data.xml +++ b/addons/crm_claim/crm_claim_data.xml @@ -75,6 +75,32 @@ + + + + new + crm.claim + + + + refused + crm.claim + + + + stage change + crm.claim + + + cancelled + crm.claim + + + + closed + crm.claim + + From 2fbc7e9d046dcebea15b6a43289297e705984212 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 17:21:38 +0530 Subject: [PATCH 115/175] [IMP]improve subtype in crm_claim bzr revid: sgo@tinyerp.com-20120913115138-4rrsmwmlfh4f25s1 --- addons/crm_claim/crm_claim_data.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/crm_claim/crm_claim_data.xml b/addons/crm_claim/crm_claim_data.xml index a72c285f506..e68bc3ad6cb 100644 --- a/addons/crm_claim/crm_claim_data.xml +++ b/addons/crm_claim/crm_claim_data.xml @@ -99,7 +99,6 @@ closed crm.claim - From 8821601a87dc1a35253314673252f40a10e93493 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 14 Sep 2012 11:27:30 +0530 Subject: [PATCH 116/175] [IMP]minor changes bzr revid: sgo@tinyerp.com-20120914055730-c0x2tshrr8j6aa5v --- 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 87c2e22d46b..71f22138c90 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -628,7 +628,7 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids, context=None): + def message_subscribe(self, cr, uid, ids, partner_ids,subtype_ids=None, context=None): """ Add partners to the records followers. """ if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') From a11e752ea2a1533c7db3e037689a8e132ade8bbd Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 14 Sep 2012 11:35:46 +0530 Subject: [PATCH 117/175] [IMP]improve code bzr revid: sgo@tinyerp.com-20120914060546-e0uj8dru6c9pym9y --- addons/base_status/base_stage.py | 14 +++++++------- addons/mail/mail_thread.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index 4b1cc3c6946..2695567e0a1 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -365,13 +365,13 @@ class base_stage(object): def find_xml_id(self,cr,uid,ids,name,context=None): subtype_obj = self.pool.get('mail.message.subtype') - irmodel_obj = self.pool.get('ir.model.data') - subtype_id = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) - ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','in',subtype_id)]) - xml_id = False - ir_model_browse = irmodel_obj.browse(cr,uid,ir_ids) - if ir_model_browse: - xml_id = ir_model_browse[0].name + ir_model_data_obj = self.pool.get('ir.model.data') + subtype_ids = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) + ir_data_ids = ir_model_data_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','in',subtype_ids)]) + xml_id = 'mail_subtype_comment' + ir_model_data_record = ir_model_data_obj.browse(cr,uid,ir_data_ids) + if ir_model_data_record: + xml_id = ir_model_data_record[0].name return xml_id def case_close_send_note(self, cr, uid, ids, context=None): diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 3f034b8875a..137ba3eccda 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -604,7 +604,7 @@ class mail_thread(osv.AbstractModel): subtype_browse = subtype_obj.browse(cr, uid, ref[1],context=context) if self._name == subtype_browse.res_model: values['subtype_id']=subtype_browse.id - else: + if not subtype_browse.res_model: values['subtype_id']=subtype_browse.id values.update({ 'model': context.get('thread_model', self._name) if thread_id else False, @@ -629,7 +629,7 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids, context=None): + def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None): """ Add partners to the records followers. """ if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') From 6537579a9c927264100e3dc5cb843b930566c6ab Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Fri, 14 Sep 2012 15:02:36 +0530 Subject: [PATCH 118/175] [IMP]improve lead code bzr revid: sgo@tinyerp.com-20120914093236-knk88eqvnbd4slct --- addons/crm/crm_lead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 924326c7c02..81ca828dc76 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -842,7 +842,7 @@ class crm_lead(base_stage, format_address, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), mail_subtype_new="crm_subtype_stage_change",context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="crm_subtype_stage_change",context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): From 9ec025be0ed4a896b37b0323fe427e39f6abb13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 13:00:35 +0200 Subject: [PATCH 119/175] [CLEAN] mail message subtype: cleaned model and views. bzr revid: tde@openerp.com-20120919110035-724052iqfkkafm73 --- addons/mail/data/mail_data.xml | 2 +- addons/mail/mail_message_subtype.py | 20 +++++++++++------ addons/mail/mail_message_subtype.xml | 32 ++++++---------------------- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index 8e2af38f2ea..c8eb8829d64 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -12,7 +12,7 @@ - + comment diff --git a/addons/mail/mail_message_subtype.py b/addons/mail/mail_message_subtype.py index 6eb349fc71e..71e8147cfc9 100644 --- a/addons/mail/mail_message_subtype.py +++ b/addons/mail/mail_message_subtype.py @@ -2,7 +2,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2009-today OpenERP SA () +# Copyright (C) 2012-today OpenERP SA () # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -22,15 +22,23 @@ from osv import osv from osv import fields + class mail_message_subtype(osv.osv): - + """ Class holding subtype definition for messages. Subtypes allow to tune + the follower subscription, allowing only some subtypes to be pushed + on the Wall. """ _name = 'mail.message.subtype' _description = 'mail_message_subtype' _columns = { - 'name': fields.char('Message Subtype ', size = 128, - required = True, help = 'Message subtype, gives a more precise type on the message, especially for system notifications. For example, it can be a notification related to a new record (New), or to a stage change in a process (Stage change). Message subtypes allow to precisely tune the notifications the user want to receive on its wall.'), - 'res_model': fields.char('Model',size = 128, help = "link subtype to model"), - 'default': fields.boolean('Default', help = "When subscribing to the document, users will receive by default messages related to this subtype unless they uncheck this subtype"), + 'name': fields.char('Message Subtype ', required=True, + help='Message subtype, gives a more precise type on the message, '\ + 'especially for system notifications. For example, it can be '\ + 'a notification related to a new record (New), or to a stage '\ + 'change in a process (Stage change). Message subtypes allow to '\ + 'precisely tune the notifications the user want to receive on its wall.'), + 'res_model': fields.char('Model', help="link subtype to model"), + 'default': fields.boolean('Default', + help="When subscribing to the document, this subtype will be checked by default."), } _defaults = { 'default': True, diff --git a/addons/mail/mail_message_subtype.xml b/addons/mail/mail_message_subtype.xml index 7d0eed2f4da..c6490d5e61a 100644 --- a/addons/mail/mail_message_subtype.xml +++ b/addons/mail/mail_message_subtype.xml @@ -2,19 +2,14 @@ - - mail.message.subtype.tree mail.message.subtype - tree 10 - + @@ -23,42 +18,27 @@ mail.message.subtype.form mail.message.subtype - form
                    - - - - - - - + + +
                    - + Subtypes mail.message.subtype form tree,form - -

                    - Click to create a message subtype. -

                    - OpenERP's message subtype allows to ease and fasten the - subtype which helps to decrease over crowdy wall comments which displays - only those. -

                    -
                    - +
                    From 64672b176447c662408e853f5980a0f8f6c6f675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 13:43:53 +0200 Subject: [PATCH 120/175] [CLEAN] mail: comment xml_id is now mt_comment. Propagated change. Slighty cleaned code in base_status. bzr revid: tde@openerp.com-20120919114353-8s9lo6tp78tnwj56 --- addons/base_status/base_stage.py | 27 +++++++++---------- .../crm/test/process/crm_message_subtype.yml | 2 +- addons/mail/data/mail_data.xml | 2 +- addons/mail/mail_thread.py | 4 +-- addons/mail/tests/test_mail.py | 2 +- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index 2695567e0a1..859e577bf31 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -349,6 +349,15 @@ class base_stage(object): """ return '' + def find_subtype_xml_id(self, cr, uid, ids, name, context=None): + ir_model_data_obj = self.pool.get('ir.model.data') + subtype_ids = self.pool.get('mail.message.subtype').search(cr, uid, [('res_model', '=', self._name), ('name', '=', name)], context=context) + ir_data_ids = ir_model_data_obj.search(cr, uid, [('model', '=', 'mail.message.subtype'), ('res_id', 'in', subtype_ids)], context=context) + ir_model_data_record = ir_model_data_obj.browse(cr, uid, ir_data_ids, context=context) + if ir_model_data_record: + return ir_model_data_record[0].name + return None + def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Send a notification when the stage changes. This method has to be overriden, because each document will have its particular @@ -360,31 +369,21 @@ class base_stage(object): def case_open_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been opened.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, context=context) + xml_id = self.find_subtype_xml_id(cr, uid, ids, name="open", context=context) + self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True - - def find_xml_id(self,cr,uid,ids,name,context=None): - subtype_obj = self.pool.get('mail.message.subtype') - ir_model_data_obj = self.pool.get('ir.model.data') - subtype_ids = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)]) - ir_data_ids = ir_model_data_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','in',subtype_ids)]) - xml_id = 'mail_subtype_comment' - ir_model_data_record = ir_model_data_obj.browse(cr,uid,ir_data_ids) - if ir_model_data_record: - xml_id = ir_model_data_record[0].name - return xml_id def case_close_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been closed.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - xml_id = self.find_xml_id(cr, uid, ids, name="closed", context=context) + xml_id = self.find_subtype_xml_id(cr, uid, ids, name="closed", context=context) self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): for id in ids: msg = _('%s has been cancelled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context=context) + xml_id = self.find_subtype_xml_id(cr, uid, ids, name="cancel", context=context) self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context) return True diff --git a/addons/crm/test/process/crm_message_subtype.yml b/addons/crm/test/process/crm_message_subtype.yml index a1ad9a9c39a..bec5f730fa7 100644 --- a/addons/crm/test/process/crm_message_subtype.yml +++ b/addons/crm/test/process/crm_message_subtype.yml @@ -8,7 +8,7 @@ - I have add the sub_type name comment with default true - - !record {model: mail.message.subtype, id: mail.mail_subtype_comment }: + !record {model: mail.message.subtype, id: mail.mt_comment }: name: comment res_model: crm.lead - diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index c8eb8829d64..5fe1ee45b1d 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -13,7 +13,7 @@
                    - + comment diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 9ce3a8c8f95..400f3ccaa2d 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -562,8 +562,8 @@ class mail_thread(osv.AbstractModel): "now deprecated res.log.") self.message_post(cr, uid, [id], message, context=context) - def message_post(self, cr, uid, thread_id, body='', subject=False, - type='notification', parent_id=False, attachments=None, subtype_xml_id='mail_subtype_comment', context=None, **kwargs): + def message_post(self, cr, uid, thread_id, body='', subject=False, type='notification', + subtype_xml_id=None, parent_id=False, attachments=None, context=None, **kwargs): """ Post a new message in an existing thread, returning the new mail.message ID. Extra keyword arguments will be used as default column values for the new mail.message record. diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 2dfb7a75136..1ecdc4b6e5f 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -702,7 +702,7 @@ class test_mail(TestMailMockups): _mail_bodyalt2 = 'Pigs rules\nAdmin\n' filter_subtype_id = self.mail_message_subtype.search(cr, uid, [('default','=',True)]) # Post comment with body and subject, comment preference - msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mail_subtype_comment') + msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mt_comment') notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") From f59a9a83bbd7d75fb885717abe13a475e18fa8d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 13:46:12 +0200 Subject: [PATCH 121/175] [CLEAN] sale: cleaned subtypes. bzr revid: tde@openerp.com-20120919114612-6vrcnzl2up2cdqzk --- addons/sale/sale.py | 8 ++++---- addons/sale/sale_data.xml | 18 ++++-------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index cc6e5f71f30..ba85a62ca1d 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1028,7 +1028,7 @@ class sale_order(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), subtype_xml_id="sale_subtype_new", context=context) + self.message_post(cr, uid, [obj.id], body=_("Quotation for %s has been created.") % (obj.partner_id.name), subtype_xml_id="mt_sale_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -1036,7 +1036,7 @@ class sale_order(osv.osv): def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), subtype_xml_id="sale_subtype_cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("Sale Order for %s cancelled.") % (obj.partner_id.name), context=context) def delivery_send_note(self, cr, uid, ids, picking_id, context=None): for order in self.browse(cr, uid, ids, context=context): @@ -1048,7 +1048,7 @@ class sale_order(osv.osv): self.message_post(cr, uid, [order.id], body=_("Delivery Order %s scheduled for %s.") % (picking.name, picking_date_str), context=context) def delivery_end_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Order delivered."), subtype_xml_id="sale_subtype_delivered", context=context) + self.message_post(cr, uid, ids, body=_("Order delivered."), subtype_xml_id="mt_sale_delivered", context=context) def invoice_paid_send_note(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype_xml_id="sale_subtype_paid", context=context) @@ -1056,7 +1056,7 @@ class sale_order(osv.osv): def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype_xml_id="sale_subtype_pending", context=context) + self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), context=context) def action_cancel_draft_send_note(self, cr, uid, ids, context=None): return self.message_post(cr, uid, ids, body=_('Sale order set to draft.'), context=context) diff --git a/addons/sale/sale_data.xml b/addons/sale/sale_data.xml index 4337c4bd1e8..3be79035fc6 100644 --- a/addons/sale/sale_data.xml +++ b/addons/sale/sale_data.xml @@ -44,26 +44,16 @@ If you need to manage your sales pipeline (leads, opportunities, phonecalls), you can install the module <i>CRM</i> from the top menu Settings. - - new + + create sale.order - - cancelled - sale.order - - - + paid sale.order - - pending - sale.order - - - + delivered sale.order From 4fa322cfe5334473676b03e8ac6e9ed06eb552b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 13:51:56 +0200 Subject: [PATCH 122/175] [CLEAN] stock: cleaned subtypes. bzr revid: tde@openerp.com-20120919115156-mi80hp8jprnag506 --- addons/stock/stock.py | 16 ++++++---------- addons/stock/stock_data.xml | 22 +++++----------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 77849e12627..f96c3582a6d 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1379,13 +1379,13 @@ class stock_picking(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), subtype_xml_id="stock_in_subtype_new", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been created.") % (self._get_document_type(obj.type)), subtype_xml_id="mt_stock_new", context=context) def scrap_send_note(self, cr, uid, ids, quantity, uom, name, context=None): - return self.message_post(cr, uid, ids, body= _("%s %s %s has been moved to scrap.") % (quantity, uom, name),context=context) + return self.message_post(cr, uid, ids, body=_("%s %s %s has been moved to scrap.") % (quantity, uom, name), context=context) def back_order_send_note(self, cr, uid, ids, back_name, context=None): - return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), subtype_xml_id="stock_in_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_name), subtype_xml_id="mt_stock_new", context=context) def ship_done_send_note(self, cr, uid, ids, context=None): type_dict = { @@ -1394,19 +1394,15 @@ class stock_picking(osv.osv): 'internal': 'moved', } xml_id_dict = { - 'out':'stock_out_subtype_delivered', - 'in' : 'stock_in_subtype_received' + 'out': 'mt_stock_delivered', + 'in': 'mt_stock_received' } for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, [obj.id], body=_("Products have been %s.") % (type_dict.get(obj.type, 'move done')), subtype_xml_id=xml_id_dict.get(obj.type), context=context) def ship_cancel_send_note(self, cr, uid, ids, context=None): - xml_id_dict = { - 'out':'stock_out_subtype_cancelled', - 'in' : 'stock_in_subtype_cancelled' - } for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), subtype_xml_id=xml_id_dict.get(obj.type), context=context) + self.message_post(cr, uid, [obj.id], body=_("%s has been cancelled.") % (self._get_document_type(obj.type)), context=context) stock_picking() diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index a59642fa912..1ab30af2abc 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -167,30 +167,18 @@ watch your stock valuation, and track production lots upstream and downstream (b - - - new + + + created stock.picking.in - + delivered stock.picking.out - - + received stock.picking.in - - - - cancelled - stock.picking.in - - - cancelled - stock.picking.out From 5e9f78ebfd3b5a996b78fc598417bc68fe33ec9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 14:00:00 +0200 Subject: [PATCH 123/175] [CLEAN] project_issue: cleaned subtypes. bzr revid: tde@openerp.com-20120919120000-62v9f5e24fh3grzd --- addons/project_issue/project_issue.py | 4 +-- addons/project_issue/project_issue_data.xml | 38 +++++++++------------ 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 83eddb83d5e..0677fbfbd75 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -503,7 +503,7 @@ class project_issue(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="issue_subtype_stage_change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="mt_issue_new", context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): """ Override of default prefix for notifications. """ @@ -515,7 +515,7 @@ class project_issue(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Project issue created.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="issue_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_issue_new", context=context) def case_escalate_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml index f6c225a4d00..edd44e52dd2 100644 --- a/addons/project_issue/project_issue_data.xml +++ b/addons/project_issue/project_issue_data.xml @@ -30,27 +30,7 @@ v3.0 - - - - new - project.issue - - - - stage change - project.issue - - - - cancelled - project.issue - - - - closed - project.issue - + mail.group @@ -62,5 +42,21 @@ You can record issues, assign them to a responsible person, and keep track of th Access all issues from the top Project menu, and access the issues of a specific project via the projects gallery view.
                    + + + created + project.issue + + + + stage change + project.issue + + + + closed + project.issue + + From bd998703847e01fdceb565484bbfaf690586d7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 14:03:33 +0200 Subject: [PATCH 124/175] [CLEAN] purchase: cleaned subtypes. bzr revid: tde@openerp.com-20120919120333-sc1vyw0jzfjltin7 --- addons/purchase/purchase.py | 12 ++++++------ addons/purchase/purchase_data.xml | 18 ++++-------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 8bcd6d39ef9..9fe05da33fc 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -741,7 +741,7 @@ class purchase_order(osv.osv): return [('state', '=', 'draft')] def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Request for quotation created."), subtype_xml_id="purchase_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=_("Request for quotation created."), subtype_xml_id="mt_purchase_new", context=context) def confirm_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): @@ -759,20 +759,20 @@ class purchase_order(osv.osv): def invoice_send_note(self, cr, uid, ids, invoice_id, context=None): for order in self.browse(cr, uid, ids, context=context): for invoice in (inv for inv in order.invoice_ids if inv.id == invoice_id): - self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), subtype_xml_id="purchase_subtype_pending", context=context) + self.message_post(cr, uid, [order.id], body=_("Draft Invoice of %s %s is waiting for validation.") % (invoice.amount_total, invoice.currency_id.symbol), context=context) def shipment_done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("""Shipment received."""), subtype_xml_id="purchase_subtype_received", context=context) + self.message_post(cr, uid, ids, body=_("""Shipment received."""), subtype_xml_id="mt_purchase_received", context=context) def invoice_done_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype_xml_id="purchase_subtype_paid", context=context) + self.message_post(cr, uid, ids, body=_("Invoice paid."), subtype_xml_id="mt_purchase_paid", context=context) def draft_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Purchase Order has been set to draft."), subtype_xml_id="purchase_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=_("Purchase Order has been set to draft."), subtype_xml_id="mt_purchase_new", context=context) def cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), subtype_xml_id="purchase_subtype_cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("Purchase Order for %s cancelled.") % (obj.partner_id.name), context=context) purchase_order() diff --git a/addons/purchase/purchase_data.xml b/addons/purchase/purchase_data.xml index aa62e84e19d..25981e2e01a 100644 --- a/addons/purchase/purchase_data.xml +++ b/addons/purchase/purchase_data.xml @@ -49,28 +49,18 @@ You can also manage purchase requisitions, see also the Purchase Settings. - - new + + created purchase.order - + paid purchase.order - - pending - purchase.order - - - + received purchase.order - - cancelled - purchase.order - - From dbcb9b2b1e5048c61819769bacaccf858425fd53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 14:06:02 +0200 Subject: [PATCH 125/175] [CLEAN] purchase_requisition: cleaned subtypes. bzr revid: tde@openerp.com-20120919120602-1klpv75xzs5ngw3n --- .../purchase_requisition/purchase_requisition.py | 14 +++++++------- .../purchase_requisition_data.xml | 13 +++++-------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index 98fbdd1c5b1..7ce03d7a623 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -92,15 +92,15 @@ class purchase_requisition(osv.osv): def in_progress_send_note(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_("Draft Requisition has been sent to suppliers."), context=context) - + def reset_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype_xml_id="requisition_subtype_new", context=context) - + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been set to draft."), subtype_xml_id="mt_requisition_new", context=context) + def done_to_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype_xml_id="requisition_subtype_closed", context=context) - + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been done."), subtype_xml_id="mt_requisition_closed", context=context) + def cancel_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), subtype_xml_id="requisition_subtype_cancelled", context=context) + self.message_post(cr, uid, ids, body=_("Purchase Requisition has been cancelled."), context=context) def _planned_date(self, requisition, delay=0.0): company = requisition.company_id @@ -183,7 +183,7 @@ class purchase_requisition(osv.osv): return res def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Purchase Requisition has been created."), subtype_xml_id="requisition_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=_("Purchase Requisition has been created."), subtype_xml_id="mt_requisition_new", context=context) def create(self, cr, uid, vals, context=None): requisition = super(purchase_requisition, self).create(cr, uid, vals, context=context) diff --git a/addons/purchase_requisition/purchase_requisition_data.xml b/addons/purchase_requisition/purchase_requisition_data.xml index 534bf2fe2a7..7ca50f6a80c 100644 --- a/addons/purchase_requisition/purchase_requisition_data.xml +++ b/addons/purchase_requisition/purchase_requisition_data.xml @@ -6,17 +6,14 @@ id="purchase_default_set" model="ir.values" name="set"/> - - - closed - purchase.requisition - - + + + new purchase.requisition - - cancelled + + closed purchase.requisition From cd1c44568e65c21d1e6740a44a0796bc31662dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 14:13:30 +0200 Subject: [PATCH 126/175] [CLEAN] crm, crm_claim: cleaned subtypes. bzr revid: tde@openerp.com-20120919121330-rc4mv900fhynqu6v --- addons/crm/crm_lead.py | 8 +++--- addons/crm/crm_lead_data.xml | 15 ++++------- addons/crm_claim/crm_claim.py | 6 ++--- addons/crm_claim/crm_claim_data.xml | 42 +++++++++++++---------------- 4 files changed, 30 insertions(+), 41 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 81ca828dc76..a7337b7178f 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -842,7 +842,7 @@ class crm_lead(base_stage, format_address, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="crm_subtype_stage_change",context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="mt_crm_stage",context=context) def case_get_note_msg_prefix(self, cr, uid, lead, context=None): if isinstance(lead, (int, long)): @@ -852,16 +852,16 @@ class crm_lead(base_stage, format_address, osv.osv): def create_send_note(self, cr, uid, ids, context=None): for id in ids: message = _("%s has been created.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=message, subtype_xml_id="crm_subtype_new", context=context) + self.message_post(cr, uid, [id], body=message, subtype_xml_id="mt_crm_new", context=context) return True def case_mark_lost_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been lost.") - return self.message_post(cr, uid, ids, body=message,subtype_xml_id="crm_subtype_lost", context=context) + return self.message_post(cr, uid, ids, body=message,subtype_xml_id="mt_crm_lost", context=context) def case_mark_won_send_note(self, cr, uid, ids, context=None): message = _("Opportunity has been won.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="crm_subtype_won", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_crm_won", context=context) def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None): phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0] diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 633782ed233..e347a7a03af 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -155,29 +155,24 @@ - - new + + created crm.lead - + won crm.lead - + lost crm.lead - + stage change crm.lead - - cancelled - crm.lead - - diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py index ce2427b9752..fc80e320c08 100644 --- a/addons/crm_claim/crm_claim.py +++ b/addons/crm_claim/crm_claim.py @@ -238,16 +238,16 @@ class crm_claim(base_stage, osv.osv): def create_send_note(self, cr, uid, ids, context=None): msg = _('Claim has been created.') - return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='claim_subtype_new', context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='mt_claim_new', context=context) def case_refuse_send_note(self, cr, uid, ids, context=None): msg = _('Claim has been refused.') - return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='claim_subtype_refused', context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id='mt_claim_refused', context=context) def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('crm.claim.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id='claim_subtype_stage_change', context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id='mt_claim_stage', context=context) class res_partner(osv.osv): diff --git a/addons/crm_claim/crm_claim_data.xml b/addons/crm_claim/crm_claim_data.xml index e68bc3ad6cb..5e79220aea8 100644 --- a/addons/crm_claim/crm_claim_data.xml +++ b/addons/crm_claim/crm_claim_data.xml @@ -76,30 +76,24 @@ - - - new - crm.claim - - - - refused - crm.claim - - - - stage change - crm.claim - - - cancelled - crm.claim - - - - closed - crm.claim - + + + created + crm.claim + + + refused + crm.claim + + + + stage change + crm.claim + + + closed + crm.claim + From 27f2ceecac030305c7566bf26c92cc99b54b14fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 14:31:17 +0200 Subject: [PATCH 127/175] [CLEAN] event: cleaned subtypes. bzr revid: tde@openerp.com-20120919123117-ohey5we13wusgi0g --- addons/event/event.py | 20 ++++++++++---------- addons/event/event_data.xml | 34 +++++++++++----------------------- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/addons/event/event.py b/addons/event/event.py index feebd3a3f93..1bd52f2389b 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -293,17 +293,17 @@ class event_event(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Event has been created.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_event_new", context=context) return True def button_cancel_send_note(self, cr, uid, ids, context=None): message = _("Event has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_event_cancel", context=context) return True def button_draft_send_note(self, cr, uid, ids, context=None): message = _("Event has been set to draft.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_new", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_event_new", context=context) return True def button_done_send_note(self, cr, uid, ids, context=None): @@ -313,7 +313,7 @@ class event_event(osv.osv): def button_confirm_send_note(self, cr, uid, ids, context=None): message = _("Event has been confirmed.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_confirmed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_event_confirm", context=context) return True event_event() @@ -359,7 +359,7 @@ class event_registration(osv.osv): return self.write(cr, uid, ids, {'state': 'draft'}, context=context) def confirm_registration(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_('State set to open'),subtype_xml_id="registration_subtype_confirmed", context=context) + self.message_post(cr, uid, ids, body=_('State set to open'),subtype_xml_id="mt_registration_confirm", context=context) return self.write(cr, uid, ids, {'state': 'open'},context=context) def create(self, cr, uid, vals, context=None): @@ -389,13 +389,13 @@ class event_registration(osv.osv): if today >= registration.event_id.date_begin: values = {'state': 'done', 'date_closed': today} self.write(cr, uid, ids, values) - self.message_post(cr, uid, ids, body=_('State set to Done'), subtype_xml_id="registration_subtype_closed", context=context) + self.message_post(cr, uid, ids, body=_('State set to Done'), context=context) else: - raise osv.except_osv(_('Error!'),_("You must wait for the starting day of the event to do this action.") ) + raise osv.except_osv(_('Error!'), _("You must wait for the starting day of the event to do this action.")) return True def button_reg_cancel(self, cr, uid, ids, context=None, *args): - self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype_xml_id="registration_subtype_cancelled", context=context) + self.message_post(cr, uid, ids, body=_('State set to Cancel'), subtype_xml_id="mt_registration_cancel", context=context) return self.write(cr, uid, ids, {'state': 'cancel'}) def mail_user(self, cr, uid, ids, context=None): @@ -465,12 +465,12 @@ class event_registration(osv.osv): def create_send_note(self, cr, uid, ids, context=None): message = _("Registration has been created.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="registration_subtype_new", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True def do_draft_send_note(self, cr, uid, ids, context=None): message = _("Registration has been set as draft.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="registration_subtype_new", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True event_registration() diff --git a/addons/event/event_data.xml b/addons/event/event_data.xml index 251f78973c7..9fa16b77689 100644 --- a/addons/event/event_data.xml +++ b/addons/event/event_data.xml @@ -11,43 +11,31 @@ open - - - new + + + + created event.event - - closed - event.event - - - cancelled + + canceled event.event - + confirmed event.event - - - new - event.registration - - - - closed - event.registration - - - cancelled + + + canceled event.event - + confirmed event.registration From 4312649fb5b1759efdcb6daef6eeda301d800ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 14:33:18 +0200 Subject: [PATCH 128/175] [FIX] mail_thread: moved get_object_reference into if exist. bzr revid: tde@openerp.com-20120919123318-k2wax6npnm1tw1mm --- 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 400f3ccaa2d..a3cd727aeb6 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -600,8 +600,8 @@ class mail_thread(osv.AbstractModel): values = kwargs subtype_obj = self.pool.get('mail.message.subtype') - ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype_xml_id) if subtype_xml_id: + ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype_xml_id) subtype_browse = subtype_obj.browse(cr, uid, ref[1],context=context) if self._name == subtype_browse.res_model: values['subtype_id']=subtype_browse.id From 378966f9f1c0dc9d1f7aca8dbc666eff4cda74d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 15:05:14 +0200 Subject: [PATCH 129/175] [FIX] event: fixed xml_id not existing. bzr revid: tde@openerp.com-20120919130514-oeto9qfiujd3v71e --- addons/event/event.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/event/event.py b/addons/event/event.py index 1bd52f2389b..5797e12355c 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -308,7 +308,7 @@ class event_event(osv.osv): def button_done_send_note(self, cr, uid, ids, context=None): message = _("Event has been done.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="event_subtype_closed", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True def button_confirm_send_note(self, cr, uid, ids, context=None): From b9820db8f0b7c81429dd0c3471cb4835ef11c195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 15:12:40 +0200 Subject: [PATCH 130/175] [CLEAN] hr_holidays, hr_recruitment, idea, mrp: cleaned subtypes. bzr revid: tde@openerp.com-20120919131240-7cc61fqg5eoom9zt --- addons/hr_holidays/hr_holidays.py | 28 +++++++++---------- addons/hr_holidays/hr_holidays_data.xml | 12 ++++---- addons/hr_recruitment/hr_recruitment.py | 14 +++++----- addons/hr_recruitment/hr_recruitment_data.xml | 18 +++--------- addons/idea/idea.py | 18 ++++++------ addons/idea/idea_data.xml | 19 ------------- addons/mrp/mrp.py | 10 +++---- addons/mrp/mrp_data.xml | 22 +++++---------- 8 files changed, 50 insertions(+), 91 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 4e85313e2e4..731efad4d8d 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -352,44 +352,42 @@ class hr_holidays(osv.osv): def needaction_domain_get(self, cr, uid, ids, context=None): # to be tested, otherwise convert into employee_id in ... emp_obj = self.pool.get('hr.employee') - empids = emp_obj.search(cr, uid, [('parent_id.user_id','=',uid)], context=context) - dom = [ - '&', ('state','=','confirm'),('employee_id', 'in', empids) - ] + empids = emp_obj.search(cr, uid, [('parent_id.user_id', '=', uid)], context=context) + dom = ['&', ('state', '=', 'confirm'), ('employee_id', 'in', empids)] # if this user is a hr.manager, he should do second validations if self.pool.get('res.users').has_group(cr, uid, 'base.group_hr_manager'): - dom = ['|'] + dom + [ ('state','=','validate1') ] + dom = ['|'] + dom + [('state', '=', 'validate1')] return dom def create_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, ids, - _("The request has been created and is waiting confirmation."),subtype_xml_id="hr_holidays_subtype_new", context=context) + self.message_post(cr, uid, ids, + _("The request has been created and is waiting confirmation."), context=context) return True - + def holidays_confirm_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been submitted and is waiting for validation by the manager."), context=context) - + _("The request has been submitted and is waiting for validation by the manager."), subtype_xml_id="mt_holidays_confirm", context=context) + def holidays_first_validate_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, [obj.id], _("The request has been approved. A second validation is necessary and is now pending."), context=context) - + def holidays_validate_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): if obj.double_validation: - self.message_post(cr, uid, [obj.id], + self.message_post(cr, uid, [obj.id], _("The request has been double validated. The validation process is now over."), context=context) else: self.message_post(cr, uid, [obj.id], - _("The request has been approved. The validation process is now over."), subtype_xml_id="hr_holidays_subtype_approved", context=context) - + _("The request has been approved. The validation process is now over."), subtype_xml_id="mt_holidays_closed", context=context) + def holidays_refuse_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_post(cr, uid, [obj.id], - _("The request has been refused. The validation process is now over."), subtype_xml_id="hr_holidays_subtype_refused", context=context) + _("The request has been refused. The validation process is now over."), subtype_xml_id="mt_holidays_refused", context=context) class resource_calendar_leaves(osv.osv): diff --git a/addons/hr_holidays/hr_holidays_data.xml b/addons/hr_holidays/hr_holidays_data.xml index 0eb411e90cb..50a3f3fde17 100644 --- a/addons/hr_holidays/hr_holidays_data.xml +++ b/addons/hr_holidays/hr_holidays_data.xml @@ -43,17 +43,17 @@ Once validated, they are visible in the employee's calendar. HR officers can def True brown - - - new + + + + confirmed hr.holidays - - + approved hr.holidays - + refused hr.holidays diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index ec2ea806fec..49a80ef26d6 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -461,14 +461,14 @@ class hr_applicant(base_stage, osv.Model): """ Override of the (void) default notification method. """ if not stage_id: return True stage_name = self.pool.get('hr.recruitment.stage').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="hr_recruitment_subtype_stage_change", context=context) + return self.message_post(cr, uid, ids, body=_("Stage changed to %s.") % (stage_name), context=context) def case_get_note_msg_prefix(self, cr, uid, id, context=None): return 'Applicant' def case_open_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been set in progress.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_in_progress", context=context) + return self.message_post(cr, uid, ids, body=message, context=context) def case_close_send_note(self, cr, uid, ids, context=None): if context is None: @@ -476,23 +476,23 @@ class hr_applicant(base_stage, osv.Model): for applicant in self.browse(cr, uid, ids, context=context): if applicant.emp_id: message = _("Applicant has been hired and created as an employee.") - self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="hr_recruitment_subtype_hired", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="mt_recruitment_hired", context=context) else: message = _("Applicant has been hired.") - self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="hr_recruitment_subtype_hired", context=context) + self.message_post(cr, uid, [applicant.id], body=message, subtype_xml_id="mt_recruitment_hired", context=context) return True def case_cancel_send_note(self, cr, uid, ids, context=None): msg = 'Applicant refused.' - return self.message_post(cr, uid, ids, body=msg, subtype_xml_id="hr_recruitment_subtype_refused", context=context) + return self.message_post(cr, uid, ids, body=msg, subtype_xml_id="mt_recruitment_refused", context=context) def case_reset_send_note(self, cr, uid, ids, context=None): message =_("Applicant has been set as new.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_recruitment_new", context=context) def create_send_note(self, cr, uid, ids, context=None): message = _("Applicant has been created.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="hr_recruitment_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_recruitment_new", context=context) class hr_job(osv.osv): diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index dedeb20a3dc..1fb79227770 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -461,30 +461,20 @@ You can automatically receive job application though an email gateway, see the H - - + + new hr.applicant - - + hired hr.applicant - + refused hr.applicant - - stage change - hr.applicant - - - - in progress - hr.applicant - diff --git a/addons/idea/idea.py b/addons/idea/idea.py index f8346ec2bba..14fbe5eda17 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -66,23 +66,21 @@ class idea_idea(osv.osv): _order = 'name asc' def idea_cancel(self, cr, uid, ids, context={}): - self.write(cr, uid, ids, { 'state': 'cancel' }) - self.message_post(cr, uid, ids, body=_('Idea cancelled.'), subtype_xml_id="idea_subtype_cancelled", context=context) + self.write(cr, uid, ids, {'state': 'cancel'}, context=context) + self.message_post(cr, uid, ids, body=_('Idea cancelled.'), context=context) return True def idea_open(self, cr, uid, ids, context={}): - self.write(cr, uid, ids, { 'state': 'open'}) - self.message_post(cr, uid, ids, body=_('Idea accepted.'), subtype_xml_id="idea_subtype_open", context=context) + self.write(cr, uid, ids, {'state': 'open'}, context=context) + self.message_post(cr, uid, ids, body=_('Idea accepted.'), context=context) return True def idea_close(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea closed.'), subtype_xml_id="idea_subtype_closed", context=context) - self.write(cr, uid, ids, { 'state': 'close' }) + self.write(cr, uid, ids, {'state': 'close'}, context=context) + self.message_post(cr, uid, ids, body=_('Idea closed.'), context=context) return True def idea_draft(self, cr, uid, ids, context={}): - self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), subtype_xml_id="idea_subtype_new", context=context) - self.write(cr, uid, ids, { 'state': 'draft' }) + self.write(cr, uid, ids, {'state': 'draft'}, context=context) + self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), context=context) return True -idea_idea() - diff --git a/addons/idea/idea_data.xml b/addons/idea/idea_data.xml index b4f3f70d2dd..421cb6a9eef 100644 --- a/addons/idea/idea_data.xml +++ b/addons/idea/idea_data.xml @@ -16,25 +16,6 @@ - - - new - idea.idea - - - - open - idea.idea - - - cancelled - idea.idea - - - - closed - idea.idea - diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index bc0baae71e8..b4dece5dfa4 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1044,27 +1044,27 @@ class mrp_production(osv.osv): # --------------------------------------------------- def create_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), subtype_xml_id="mrp_subtype_new", context=context) + self.message_post(cr, uid, ids, body=_("Manufacturing order has been created."), subtype_xml_id="mt_mrp_order_new", context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been canceled.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_cancelled", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_mrp_order_canceled", context=context) return True def action_ready_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is ready to produce.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_ready", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True def action_in_production_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order is in production.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_production", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): message = _("Manufacturing order has been done.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="mrp_subtype_closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_mrp_order_closed", context=context) return True def action_confirm_send_note(self, cr, uid, ids, context=None): diff --git a/addons/mrp/mrp_data.xml b/addons/mrp/mrp_data.xml index 3740f03bdc8..79e202cd8e0 100644 --- a/addons/mrp/mrp_data.xml +++ b/addons/mrp/mrp_data.xml @@ -26,27 +26,19 @@ From the Manufacturing Settings, you can choose to compute production schedules 1 1 - - - new + + + + created mrp.production - - ready + + canceled mrp.production - - production - mrp.production - - - cancelled - mrp.production - - - + closed mrp.production From 10458eb098a79336183532e114a3a38360b92cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 15:35:40 +0200 Subject: [PATCH 131/175] [CLEAN] mrp_operation, analytic, account, account_voucher: cleaned subtypes. bzr revid: tde@openerp.com-20120919133540-e0d8huak2g3v915o --- addons/account/account_invoice.py | 11 +++++++---- addons/account/data/account_data.xml | 15 +++++---------- addons/account_voucher/account_voucher.py | 6 +++--- .../account_voucher/account_voucher_data.xml | 14 +++++++------- addons/analytic/analytic.py | 3 ++- addons/analytic/analytic_data.xml | 5 +++-- addons/mrp_operations/mrp_operation_data.xml | 19 +++++-------------- addons/mrp_operations/mrp_operations.py | 10 +++++----- 8 files changed, 37 insertions(+), 46 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index b8f3a9071a0..a145e5c06be 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1306,16 +1306,19 @@ class account_invoice(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id],body=_("%s created.") % (self._get_document_type(obj.type)), subtype_xml_id="analytic_subtype_new", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s created.") % (self._get_document_type(obj.type)), + subtype_xml_id="mt_invoice_new", context=context) def confirm_paid_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_paid", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s paid.") % (self._get_document_type(obj.type)), + subtype_xml_id="mt_invoice_paid", context=context) def invoice_cancel_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_cancelled", context=context) -account_invoice() + self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), + context=context) + class account_invoice_line(osv.osv): diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index 7689ca2c253..007ef33c8c2 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -560,20 +560,15 @@ Invoice account.invoice - - - new + + + + created account.invoice - - + paid account.invoice - - cancelled - account.invoice - - diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 05a75f5847d..632367b74bc 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1295,17 +1295,17 @@ class account_voucher(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s created." % self._document_type[obj.type or False] - self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_new", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="mt_voucher_new", context=context) def post_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s '%s' is posted." % (self._document_type[obj.type or False], obj.move_id.name) - self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_post", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="mt_voucher_post", context=context) def reconcile_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): message = "%s reconciled." % self._document_type[obj.type or False] - self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_reconcile", context=context) + self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="mt_voucher_reconciled", context=context) account_voucher() diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index a59993aae6b..b69a694faff 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -12,18 +12,18 @@ You can track customer payments easily and automate the reminders. You get an ov If you want to use advanced accounting features, you should install the "Accounting and Finance" module. Module eInvoicing & Payments has been installed. - - - new + + + + created account.voucher - + post account.voucher - - - reconcile + + reconciled account.voucher diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index 250ad98a603..0aa6b5406c0 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -281,7 +281,8 @@ class account_analytic_account(osv.osv): def create_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_post(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), subtype_xml_id="analytic_subtype_new", context=context) + self.message_post(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), + subtype_xml_id="mt_account_new", context=context) account_analytic_account() diff --git a/addons/analytic/analytic_data.xml b/addons/analytic/analytic_data.xml index cfd3b5e9b78..1bee414e66a 100644 --- a/addons/analytic/analytic_data.xml +++ b/addons/analytic/analytic_data.xml @@ -1,10 +1,11 @@ - + + + new account.analytic.account - \ No newline at end of file diff --git a/addons/mrp_operations/mrp_operation_data.xml b/addons/mrp_operations/mrp_operation_data.xml index 812ce3da536..45d79860b0e 100644 --- a/addons/mrp_operations/mrp_operation_data.xml +++ b/addons/mrp_operations/mrp_operation_data.xml @@ -30,27 +30,18 @@ done - - + + new mrp.production.workcenter.line - - started + + canceled mrp.production.workcenter.line - - pending - mrp.production.workcenter.line - - - cancelled - mrp.production.workcenter.line - - - + closed mrp.production.workcenter.line diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index 53eaceed066..efac450f7f2 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -224,7 +224,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been created for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_new", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mt_workcenter_new", context=context) return True def action_start_send_note(self, cr, uid, ids, context=None): @@ -232,7 +232,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been started for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_started", context=context) + self.message_post(cr, uid, [workorder.id], body=message, context=context) return True def action_done_send_note(self, cr, uid, ids, context=None): @@ -240,7 +240,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been done for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_closed", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mt_workcenter_closed", context=context) return True def action_pending_send_note(self, cr, uid, ids, context=None): @@ -248,7 +248,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order is pending for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_pending", context=context) + self.message_post(cr, uid, [workorder.id], body=message, context=context) return True def action_cancel_send_note(self, cr, uid, ids, context=None): @@ -256,7 +256,7 @@ class mrp_production_workcenter_line(osv.osv): for workorder in self.browse(cr, uid, ids): for prod in prod_obj.browse(cr, uid, [workorder.production_id]): message = _("Work order has been cancelled for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mrp_operations_subtype_cancelled", context=context) + self.message_post(cr, uid, [workorder.id], body=message, subtype_xml_id="mt_workcenter_canceled", context=context) return True mrp_production_workcenter_line() From e30e4064587a8ae8167801cb5f4d866270770997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 15:39:50 +0200 Subject: [PATCH 132/175] [CLEAN] hr_timesheet_invoice: cleaned subtypes, moved analytic account subtypes to the related module. bzr revid: tde@openerp.com-20120919133950-upc80g20b711t8c0 --- addons/analytic/analytic_data.xml | 10 +++++++++ .../hr_timesheet_invoice.py | 22 +++++++++---------- .../hr_timesheet_invoice_data.xml | 19 ---------------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/addons/analytic/analytic_data.xml b/addons/analytic/analytic_data.xml index 1bee414e66a..934827b0334 100644 --- a/addons/analytic/analytic_data.xml +++ b/addons/analytic/analytic_data.xml @@ -7,5 +7,15 @@ new account.analytic.account + + closed + account.analytic.account + + + canceled + account.analytic.account + + + \ No newline at end of file diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index e3f54609e95..5dd8053e2c1 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -84,8 +84,8 @@ class account_analytic_account(osv.osv): res['value']['to_invoice'] = ir_model_obj.get_object_reference(cr, uid, 'hr_timesheet_invoice', 'timesheet_invoice_factor1')[1] return res - def on_change_partner_id(self, cr, uid, ids,partner_id, name, context=None): - res = super(account_analytic_account,self).on_change_partner_id(cr, uid, ids,partner_id, name, context=context) + def on_change_partner_id(self, cr, uid, ids, partner_id, name, context=None): + res = super(account_analytic_account, self).on_change_partner_id(cr, uid, ids, partner_id, name, context=context) part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context) pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False if pricelist: @@ -93,27 +93,27 @@ class account_analytic_account(osv.osv): return res def set_close(self, cr, uid, ids, context=None): - self.write(cr, uid, ids, {'state':'close'}, context=context) + self.write(cr, uid, ids, {'state': 'close'}, context=context) message = _("Contract has been closed.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_closed", context=context) + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_account_closed", context=context) return True def set_cancel(self, cr, uid, ids, context=None): - self.write(cr, uid, ids, {'state':'cancelled'}, context=context) - message = _("Contract has been cancelled.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_invoice_subtype_cancelled", context=context) + self.write(cr, uid, ids, {'state': 'cancelled'}, context=context) + message = _("Contract has been canceled.") + self.message_post(cr, uid, ids, body=message, subtype_xml_id="mt_account_canceled", context=context) return True def set_open(self, cr, uid, ids, context=None): - self.write(cr, uid, ids, {'state':'open'}, context=context) + self.write(cr, uid, ids, {'state': 'open'}, context=context) message = _("Contract has been opened.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_open", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True def set_pending(self, cr, uid, ids, context=None): - self.write(cr, uid, ids, {'state':'pending'}, context=context) + self.write(cr, uid, ids, {'state': 'pending'}, context=context) message = _("Contract has been set as pending.") - self.message_post(cr, uid, ids, body=message, subtype_xml_id="analytic_account_subtype_pending", context=context) + self.message_post(cr, uid, ids, body=message, context=context) return True account_analytic_account() diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml index 29a3233f509..462888e0b39 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice_data.xml @@ -16,24 +16,5 @@ 50% 50.0 - - - closed - account.analytic.account - - - pending - account.analytic.account - - - - open - account.analytic.account - - - cancelled - account.analytic.account - - From d85ca655ad0f71bb877811c88009af2df0772408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 15:43:47 +0200 Subject: [PATCH 133/175] [REV] account_voucher: reverted change in notification of account_voucher, somebody took away the message and set back the old message_post way of doing it. bzr revid: tde@openerp.com-20120919134347-0tp2r52dfzddcuh5 --- addons/account_voucher/account_voucher_data.xml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index b69a694faff..938836cc5ce 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -1,17 +1,14 @@ + - - - - OpenERP's electronic invoicing allows to ease and fasten the creation of invoices and collection of customer payments. Invoices are created in a few clicks and your customers receive them by email. They can pay online and/or import them in their own system. - -You can track customer payments easily and automate the reminders. You get an overview of the discussion with your customers on each invoice to ensure a full traceability. - -If you want to use advanced accounting features, you should install the "Accounting and Finance" module. - Module eInvoicing & Payments has been installed. - + + mail.group + + notification + eInvoicing & Payments application installed! + OpenERP's electronic invoicing accelerates the creation of invoices and collection of customer payments. Invoices are created in a few clicks and your customers receive them by email. They can pay online and/or import them in their own system. You can track customer payments easily and automate follow-ups. You get an overview of the discussion with your customers on each invoice for easier traceability. For advanced accounting features, you should install the "Accounting and Finance" module. From e560a74cb550ed1290d165ca1f37657178632549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Sep 2012 15:54:23 +0200 Subject: [PATCH 134/175] [CLEAN] project: cleaned subtypes. bzr revid: tde@openerp.com-20120919135423-ldfd3fx4wtyss7ae --- addons/project/project.py | 22 ++++++-------- addons/project/project_data.xml | 54 ++++++++++++++------------------- 2 files changed, 32 insertions(+), 44 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index f430cd4993a..58bc3714526 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -514,23 +514,19 @@ def Project(): return project_id def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Project has been created."), subtype_xml_id="project_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=_("Project has been created."), subtype_xml_id="mt_project_new", context=context) def set_open_send_note(self, cr, uid, ids, context=None): - message = _("Project has been opened.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_open", context=context) + return self.message_post(cr, uid, ids, body=_("Project has been opened."), context=context) def set_pending_send_note(self, cr, uid, ids, context=None): - message = _("Project is now pending.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_pending", context=context) + return self.message_post(cr, uid, ids, body=_("Project is now pending."), context=context) def set_cancel_send_note(self, cr, uid, ids, context=None): - message = _("Project has been cancelled.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_cancelled", context=context) + return self.message_post(cr, uid, ids, body=_("Project has been canceled."), context=context) def set_close_send_note(self, cr, uid, ids, context=None): - message = _("Project has been closed.") - return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_closed", context=context) + return self.message_post(cr, uid, ids, body=_("Project has been closed."), subtype_xml_id="mt_project_closed", context=context) def write(self, cr, uid, ids, vals, context=None): # if alias_model has been changed, update alias_model_id accordingly @@ -1231,14 +1227,14 @@ class task(base_stage, osv.osv): def stage_set_send_note(self, cr, uid, ids, stage_id, context=None): """ Override of the (void) default notification method. """ stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1] - return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (stage_name), subtype_xml_id="task_subtype_stage_change", context=context) + return self.message_post(cr, uid, ids, body=_("Stage changed to %s.") % (stage_name), + subtype_xml_id="mt_task_change", context=context) def create_send_note(self, cr, uid, ids, context=None): - return self.message_post(cr, uid, ids, body=_("Task has been created."), subtype_xml_id="task_subtype_new", context=context) + return self.message_post(cr, uid, ids, body=_("Task has been created."), subtype_xml_id="mt_task_new", context=context) def case_draft_send_note(self, cr, uid, ids, context=None): - msg = _('Task has been set as draft.') - return self.message_post(cr, uid, ids, body=msg, context=context) + return self.message_post(cr, uid, ids, body=_('Task has been set as draft.'), subtype_xml_id="mt_task_new", context=context) def do_delegation_send_note(self, cr, uid, ids, context=None): for task in self.browse(cr, uid, ids, context=context): diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index 0544b6d4e78..e7f486e834f 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -83,49 +83,41 @@ - - - - new + + + + created project.project - - new - project.task - - - - open - project.project - - - pending - project.project - - - + closed project.project - + + canceled + project.task + + + stage changed + project.task + + + + created + project.task + + closed project.task - - cancelled - project.project - - - - cancelled + + canceled project.task - - - stage change + + stage changed project.task - From 1b79a43833a3d6bee6dfdf8ae5e1340103131394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 09:56:22 +0200 Subject: [PATCH 135/175] [FIX] hr_rcruitment: fixed error in xml file. bzr revid: tde@openerp.com-20120920075622-mn10nv2vu7rkiddx --- addons/hr_recruitment/hr_recruitment_data.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index 1fb79227770..a0a5ca4ab02 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -474,7 +474,6 @@ You can automatically receive job application though an email gateway, see the H refused hr.applicant - From 7df8619cbda6823d199be935980a88c88a6338c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 10:32:48 +0200 Subject: [PATCH 136/175] [FIX] account_voucher: fixed missin record tag in xml file. bzr revid: tde@openerp.com-20120920083248-ayvo8t141e6th3ej --- addons/account_voucher/account_voucher_data.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index 938836cc5ce..65336e9ddcb 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -9,6 +9,7 @@ notification eInvoicing & Payments application installed! OpenERP's electronic invoicing accelerates the creation of invoices and collection of customer payments. Invoices are created in a few clicks and your customers receive them by email. They can pay online and/or import them in their own system. You can track customer payments easily and automate follow-ups. You get an overview of the discussion with your customers on each invoice for easier traceability. For advanced accounting features, you should install the "Accounting and Finance" module. + From ed3518d858392cbdd7fd4780c9985fc27ac0c77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 12:17:04 +0200 Subject: [PATCH 137/175] [CLEAN] Cleaned subtype model, implementation and tests. Added a message_subtype_data field, holding data about subtypes. This will allow to avoid doing too much calls from the front-end. bzr revid: tde@openerp.com-20120920101704-cri6zq7sqi7y660b --- addons/mail/mail_followers.py | 6 +- addons/mail/mail_message.py | 27 +++--- addons/mail/mail_thread.py | 99 +++++++++++++++------- addons/mail/tests/test_mail.py | 89 ++++++++++--------- addons/mail/wizard/mail_compose_message.py | 2 +- 5 files changed, 135 insertions(+), 88 deletions(-) diff --git a/addons/mail/mail_followers.py b/addons/mail/mail_followers.py index 6b1f2d302bc..e77e4a3d4da 100644 --- a/addons/mail/mail_followers.py +++ b/addons/mail/mail_followers.py @@ -45,10 +45,8 @@ class mail_followers(osv.Model): help='Id of the followed resource'), 'partner_id': fields.many2one('res.partner', string='Related Partner', ondelete='cascade', required=True, select=1), - 'subtype_ids': fields.many2many('mail.message.subtype', - 'mail_message_subtyp_rel', - 'subscription_id', 'subtype_id', 'Subtype', - help = "linking some subscription to several subtype for projet/task"), + 'subtype_ids': fields.many2many('mail.message.subtype', string='Subtype', + help="Message subtypes followed, meaning subtypes that will be pushed onto the user's Wall."), } diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 65ee7f41d77..793345ffb32 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -354,27 +354,24 @@ class mail_message(osv.Model): """ Add the related record followers to the destination partner_ids. Call mail_notification.notify to manage the email sending """ - followers_obj = self.pool.get("mail.followers") message = self.browse(cr, uid, newid, context=context) partners_to_notify = set([]) - # add all partner_ids of the message + # message has no subtype_id: pure log message -> no partners, no one notified + if not message.subtype_id: + message.write({'partner_ids': [5]}) + return True + # all partner_ids of the mail.message have to be notified if message.partner_ids: partners_to_notify |= set(partner.id for partner in message.partner_ids) - # add all followers and set add them in partner_ids + # all followers of the mail.message document have to be added as partners and notified if message.model and message.res_id: - record = self.pool.get(message.model).browse(cr, uid, message.res_id, context=context) - extra_notified = set(partner.id for partner in record.message_follower_ids) + fol_obj = self.pool.get("mail.followers") + fol_ids = fol_obj.search(cr, uid, [('res_model', '=', message.model), ('res_id', '=', message.res_id), ('subtype_ids', 'in', message.subtype_id.id)], context=context) + fol_objs = fol_obj.browse(cr, uid, fol_ids, context=context) + extra_notified = set(fol.partner_id.id for fol in fol_objs) missing_notified = extra_notified - partners_to_notify - missing_follow_ids = [] - if message.subtype_id: - for p_id in missing_notified: - follow_ids = followers_obj.search(cr, uid, [('partner_id','=',p_id),('subtype_ids','in',[message.subtype_id.id]),('res_model','=',message.model),('res_id','=',message.res_id)], context=context) - if follow_ids and len(follow_ids): - missing_follow_ids.append(p_id) - subtype_record = self.pool.get('mail.message.subtype').browse(cr, uid, message.subtype_id.id,context=context) - if not subtype_record.res_model: - missing_follow_ids.append(p_id) - message.write({'partner_ids': [(4, p_id) for p_id in missing_follow_ids]}) + if missing_notified: + message.write({'partner_ids': [(4, p_id) for p_id in missing_notified]}) partners_to_notify |= extra_notified self.pool.get('mail.notification').notify(cr, uid, list(partners_to_notify), newid, context=context) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index a3cd727aeb6..39a8e011f3c 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -95,6 +95,7 @@ class many2many_reference(fields.many2many): else: return super(many2many_reference, self).set(cr, model, id, name, values, user, context) + class mail_thread(osv.AbstractModel): ''' mail_thread model is meant to be inherited by any model that needs to act as a discussion topic on which messages can be attached. Public @@ -117,8 +118,10 @@ class mail_thread(osv.AbstractModel): _description = 'Email Thread' def _get_message_data(self, cr, uid, ids, name, args, context=None): + """ Computes: + - message_unread: has uid unread message for the document + - message_summary: html snippet summarizing the Chatter for kanban views """ res = dict((id, dict(message_unread=False, message_summary='')) for id in ids) - user = self.pool.get('res.users').browse(cr, uid, uid, context=context) notif_obj = self.pool.get('mail.notification') notif_ids = notif_obj.search(cr, uid, [ @@ -133,7 +136,35 @@ class mail_thread(osv.AbstractModel): for thread in self.browse(cr, uid, ids, context=context): cls = res[thread.id]['message_unread'] and ' class="oe_kanban_mail_new"' or '' res[thread.id]['message_summary'] = "9 %d + %d" % (cls, len(thread.message_comment_ids), len(thread.message_follower_ids)) - res[thread.id]['message_is_follower'] = user.partner_id.id in [follower.id for follower in thread.message_follower_ids] + return res + + def _get_subscription_data(self, cr, uid, ids, name, args, context=None): + """ Computes: + - message_is_follower: is uid in the document followers + - message_subtype_data: data about document subtypes: which are + available, which are followed if any """ + res = dict((id, dict(message_subtype_data='')) for id in ids) + user_pid = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id'][0] + + # find current model subtypes, add them to a dictionary + subtype_obj = self.pool.get('mail.message.subtype') + subtype_ids = subtype_obj.search(cr, uid, ['|', ('res_model', '=', self._name), ('res_model', '=', False)], context=context) + subtype_dict = dict((subtype.name, dict(default=subtype.default, followed=False)) for subtype in subtype_obj.browse(cr, uid, subtype_ids, context=context)) + + # find the document followers, update the data + fol_obj = self.pool.get('mail.followers') + fol_ids = fol_obj.search(cr, uid, [ + ('partner_id', '=', user_pid), + ('res_id', 'in', ids), + ('res_model', '=', self._name), + ], context=context) + for fol in fol_obj.browse(cr, uid, fol_ids, context=context): + thread_subtype_dict = subtype_dict.copy() + res[fol.res_id]['message_is_follower'] = True + for subtype in fol.subtype_ids: + thread_subtype_dict[subtype.name]['followed'] = True + res[fol.res_id]['message_subtype_data'] = '%s' % thread_subtype_dict + return res def _search_unread(self, cr, uid, obj=None, name=None, domain=None, context=None): @@ -150,8 +181,13 @@ class mail_thread(osv.AbstractModel): return [('id', 'in', res.keys())] _columns = { - 'message_is_follower': fields.function(_get_message_data, - type='boolean', string='Is a Follower', multi='_get_message_data'), + 'message_is_follower': fields.function(_get_subscription_data, + type='boolean', string='Is a Follower', multi='_get_subscription_data,'), + 'message_subtype_data': fields.function(_get_subscription_data, + type='text', string='Subscription data', multi="_get_subscription_data", + help="Holds data about the subtypes. The content of this field "\ + "is a structure holding the current model subtypes, and the "\ + "current document followed subtypes."), 'message_follower_ids': many2many_reference('res.partner', 'mail_followers', 'res_id', 'partner_id', reference_column='res_model', string='Followers'), @@ -563,7 +599,7 @@ class mail_thread(osv.AbstractModel): self.message_post(cr, uid, [id], message, context=context) def message_post(self, cr, uid, thread_id, body='', subject=False, type='notification', - subtype_xml_id=None, parent_id=False, attachments=None, context=None, **kwargs): + subtype=None, parent_id=False, attachments=None, context=None, **kwargs): """ Post a new message in an existing thread, returning the new mail.message ID. Extra keyword arguments will be used as default column values for the new mail.message record. @@ -579,8 +615,8 @@ class mail_thread(osv.AbstractModel): """ context = context or {} attachments = attachments or [] - assert (not thread_id) or isinstance(thread_id, (int,long)) or \ - (isinstance(thread_id, (list, tuple)) and len(thread_id) == 1), "Invalid thread_id" + assert (not thread_id) or isinstance(thread_id, (int, long)) or \ + (isinstance(thread_id, (list, tuple)) and len(thread_id) == 1), "Invalid thread_id" if isinstance(thread_id, (list, tuple)): thread_id = thread_id and thread_id[0] @@ -598,15 +634,13 @@ class mail_thread(osv.AbstractModel): } attachment_ids.append((0, 0, data_attach)) + if subtype: + ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype) + subtype_id = ref and ref[1] or False + else: + subtype_id = False + values = kwargs - subtype_obj = self.pool.get('mail.message.subtype') - if subtype_xml_id: - ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype_xml_id) - subtype_browse = subtype_obj.browse(cr, uid, ref[1],context=context) - if self._name == subtype_browse.res_model: - values['subtype_id']=subtype_browse.id - if not subtype_browse.res_model: - values['subtype_id']=subtype_browse.id values.update({ 'model': context.get('thread_model', self._name) if thread_id else False, 'res_id': thread_id or False, @@ -615,34 +649,44 @@ class mail_thread(osv.AbstractModel): 'type': type, 'parent_id': parent_id, 'attachment_ids': attachment_ids, + 'subtype_id': subtype_id, }) - for x in ('from', 'to', 'cc'): values.pop(x, None) # Avoid warnings + # Avoid warnings about non-existing fields + for x in ('from', 'to', 'cc'): + values.pop(x, None) return self.pool.get('mail.message').create(cr, uid, values, context=context) #------------------------------------------------------ # Followers API #------------------------------------------------------ - def message_subscribe_users(self, cr, uid, ids, user_ids=None, context=None): + def message_subscribe_users(self, cr, uid, ids, user_ids=None, subtype_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not provided, subscribe uid instead. """ - if not user_ids: user_ids = [uid] + if not user_ids: + user_ids = [uid] partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] - return self.message_subscribe(cr, uid, ids, partner_ids, context=context) + return self.message_subscribe(cr, uid, ids, partner_ids, subtype_ids=subtype_ids, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids,subtype_ids=None, context=None): + def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None): """ Add partners to the records followers. """ + self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) + if not subtype_ids: subtype_obj = self.pool.get('mail.message.subtype') - subtype_ids = subtype_obj.search(cr, uid, [('default', '=', 'true'),('res_model', '=', self._name)],context=context) - if subtype_ids: - self.message_subscribe_udpate_subtypes(cr, uid, ids, partner_ids, subtype_ids, context=context) - return self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) + subtype_ids = subtype_obj.search(cr, uid, [('default', '=', True), '|', ('res_model', '=', self._name), ('res_model', '=', False)], context=context) + + fol_obj = self.pool.get('mail.followers') + fol_ids = fol_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids), ('partner_id', 'in', partner_ids)], context=context) + fol_obj.write(cr, uid, fol_ids, {'subtype_ids': [(6, 0, subtype_ids)]}, context=context) + + return True def message_unsubscribe_users(self, cr, uid, ids, user_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not provided, unsubscribe uid instead. """ - if not user_ids: user_ids = [uid] + if not user_ids: + user_ids = [uid] partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_unsubscribe(cr, uid, ids, partner_ids, context=context) @@ -678,9 +722,4 @@ class mail_thread(osv.AbstractModel): ''', (ids, self._name, partner_id)) return True - def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None): - followers_obj = self.pool.get('mail.followers') - followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context=context) - return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 1ecdc4b6e5f..28dd3e6fe4f 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -253,30 +253,65 @@ class test_mail(TestMailMockups): follower_ids = set([follower.partner_id.id for follower in self.mail_followers.browse(cr, uid, fol_obj_ids)]) self.assertEqual(follower_ids, set([partner_bert_id, user_admin.partner_id.id]), 'Bert and Admin should be the followers of dummy mail.group data') - def test_11_message_followers(self): - """ Tests designed for the subscriber API. """ + def test_11_message_followers_and_subtypes(self): + """ Tests designed for the subscriber API as well as message subtypes """ cr, uid = self.cr, self.uid user_admin = self.res_users.browse(cr, uid, uid) group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) - - # Create user Raoul + # Data: user Raoul user_raoul_id = self.res_users.create(cr, uid, {'name': 'Raoul Grosbedon', 'login': 'raoul'}) user_raoul = self.res_users.browse(cr, uid, user_raoul_id) + # Data: message subtypes + self.mail_message_subtype.create(cr, uid, {'name': 'mt_mg_def', 'default': True, 'res_model': 'mail.group'}) + self.mail_message_subtype.create(cr, uid, {'name': 'mt_other_def', 'default': True, 'res_model': 'crm.lead'}) + self.mail_message_subtype.create(cr, uid, {'name': 'mt_all_def', 'default': True, 'res_model': False}) + mt_mg_nodef = self.mail_message_subtype.create(cr, uid, {'name': 'mt_mg_nodef', 'default': False, 'res_model': 'mail.group'}) + mt_all_nodef = self.mail_message_subtype.create(cr, uid, {'name': 'mt_all_nodef', 'default': False, 'res_model': False}) + default_group_subtypes = self.mail_message_subtype.search(cr, uid, [('default', '=', True), '|', ('res_model', '=', 'mail.group'), ('res_model', '=', False)]) - # Subscribe Raoul three times (niak niak) through message_subscribe_users + # ---------------------------------------- + # CASE1: test subscriptions with subtypes + # ---------------------------------------- + + # Do: Subscribe Raoul three times (niak niak) through message_subscribe_users group_pigs.message_subscribe_users([user_raoul_id, user_raoul_id]) group_pigs.message_subscribe_users([user_raoul_id]) group_pigs.refresh() + # Test: 2 followers (Admin and Raoul) follower_ids = [follower.id for follower in group_pigs.message_follower_ids] self.assertEqual(len(follower_ids), 2, 'There should be 2 Pigs fans') self.assertEqual(set(follower_ids), set([user_raoul.partner_id.id, user_admin.partner_id.id]), 'Admin and Raoul should be the only 2 Pigs fans') + # Test: Raoul follows default subtypes + fol_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id), ('partner_id', '=', user_raoul.partner_id.id)]) + fol_obj = self.mail_followers.browse(cr, uid, fol_ids)[0] + fol_subtype_ids = set([subtype.id for subtype in fol_obj.subtype_ids]) + self.assertEqual(set(fol_subtype_ids), set(default_group_subtypes), 'subscription subtypes are incorrect') - # Unsubscribe Raoul twice through message_unsubscribe_users + # Do: Unsubscribe Raoul twice through message_unsubscribe_users group_pigs.message_unsubscribe_users([user_raoul_id, user_raoul_id]) group_pigs.refresh() + # Test: 1 follower (Admin) follower_ids = [follower.id for follower in group_pigs.message_follower_ids] self.assertEqual(follower_ids, [user_admin.partner_id.id], 'Admin must be the only Pigs fan') + # Do: subscribe Admin with subtype_ids + group_pigs.message_subscribe_users([uid], [mt_mg_nodef, mt_all_nodef]) + fol_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id), ('partner_id', '=', user_admin.partner_id.id)]) + fol_obj = self.mail_followers.browse(cr, uid, fol_ids)[0] + fol_subtype_ids = set([subtype.id for subtype in fol_obj.subtype_ids]) + self.assertEqual(set(fol_subtype_ids), set([mt_mg_nodef, mt_all_nodef]), 'subscription subtypes are incorrect') + + # ---------------------------------------- + # CASE2: test mail_thread fields + # ---------------------------------------- + + group_pigs.refresh() + subtype_data = eval(group_pigs.message_subtype_data) + self.assertEqual(set(subtype_data.keys()), set(['comment', 'mt_mg_def', 'mt_all_def', 'mt_mg_nodef', 'mt_all_nodef']), 'mail.group available subtypes incorrect') + self.assertFalse(subtype_data['comment']['followed'], 'Admin should not follow comments in pigs') + self.assertTrue(subtype_data['mt_mg_nodef']['followed'], 'Admin should follow mt_mg_nodef in pigs') + self.assertTrue(subtype_data['mt_all_nodef']['followed'], 'Admin should follow mt_all_nodef in pigs') + def test_20_message_post(self): """ Tests designed for message_post. """ cr, uid = self.cr, self.uid @@ -307,9 +342,12 @@ class test_mail(TestMailMockups): _mail_bodyalt2 = 'Pigs rules\nAdmin' _attachments = [('First', 'My first attachment'), ('Second', 'My second attachment')] + # ---------------------------------------- # CASE1: post comment, body and subject specified + # ---------------------------------------- + self._init_mock_build_email() - msg_id = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body1, subject=_subject, type='comment') + msg_id = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body1, subject=_subject, type='comment', subtype='mt_comment') message = self.mail_message.browse(cr, uid, msg_id) sent_emails = self._build_email_kwargs_list # Test: notifications have been deleted @@ -334,10 +372,13 @@ class test_mail(TestMailMockups): for sent_email in sent_emails: self.assertEqual(sent_email['email_to'], ['b@b'], 'sent_email email_to is incorrect') + # ---------------------------------------- # CASE2: post an email with attachments, parent_id, partner_ids + # ---------------------------------------- + # TESTS: automatic subject, signature in body_html, attachments propagation self._init_mock_build_email() - msg_id2 = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body2, type='email', + msg_id2 = self.mail_group.message_post(cr, uid, self.group_pigs_id, body=_body2, type='email', subtype='mt_comment', partner_ids=[(6, 0, [p_d_id])], parent_id=msg_id, attachments=_attachments) message = self.mail_message.browse(cr, uid, msg_id2) sent_emails = self._build_email_kwargs_list @@ -608,7 +649,7 @@ class test_mail(TestMailMockups): # Post 4 message on group_pigs for dummy in range(4): - group_pigs.message_post(body='My Body') + group_pigs.message_post(body='My Body', subtype='mt_comment') # Check there are 4 new needaction on mail.message notif_ids = self.mail_notification.search(cr, uid, [ @@ -652,6 +693,7 @@ class test_mail(TestMailMockups): def test_60_vote(self): """ Test designed for the vote/unvote feature. """ cr, uid = self.cr, self.uid + user_admin = self.res_users.browse(cr, uid, uid) group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) msg1 = group_pigs.message_post(body='My Body', subject='1') msg1 = self.mail_message.browse(cr, uid, msg1) @@ -677,32 +719,3 @@ class test_mail(TestMailMockups): msg1.refresh() # Test: msg1 has Bert as voter self.assertEqual(set(msg1.vote_user_ids), set([user_bert]), 'after unvoting for Admin, Bert is not the voter') - - def test_70_message_subtype(self): - """ Tests designed for message_subtype. """ - cr, uid = self.cr, self.uid - self.res_users.write(cr, uid, [uid], {'signature': 'Admin', 'email': 'a@a'}) - user_admin = self.res_users.browse(cr, uid, uid) - group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) - - # 0 - Admin - p_a_id = user_admin.partner_id.id - # Subscribe #1, - - group_pigs.message_subscribe_users([uid]) - - # Mail data - _subject = 'Pigs' - _mail_subject = '%s posted on %s' % (user_admin.name, group_pigs.name) - _body1 = 'Pigs rules' - _mail_body1 = 'Pigs rules\n
                    Admin
                    \n' - _mail_bodyalt1 = 'Pigs rules\nAdmin' - _body2 = 'Pigs rules' - _mail_body2 = 'Pigs rules\n
                    Admin
                    \n' - _mail_bodyalt2 = 'Pigs rules\nAdmin\n' - filter_subtype_id = self.mail_message_subtype.search(cr, uid, [('default','=',True)]) - # Post comment with body and subject, comment preference - msg_id = self.mail_group.message_post(cr, uid, [self.group_pigs_id], body=_body1, subject=_subject, type='comment',subtype_xml_id='mt_comment') - notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg_id)]) - self.assertTrue(len(notif_ids) >= 1,"subtype is email and show notification on wall") - diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 760d16dbef2..32d361a3126 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -245,7 +245,7 @@ class mail_compose_message(osv.TransientModel): post_values['attachments'] += new_attachments post_values.update(email_dict) # post the message - active_model_pool.message_post(cr, uid, [res_id], type='comment', context=context, **post_values) + active_model_pool.message_post(cr, uid, [res_id], type='comment', subtype='mt_comment', context=context, **post_values) # post process: update attachments, because id is not necessarily known when adding attachments in Chatter self.pool.get('ir.attachment').write(cr, uid, [attach.id for attach in wizard.attachment_ids], {'res_id': wizard.id}, context=context) From 04c18c2c943fb44090d3540a36e3fd78dbcf1ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 13:49:09 +0200 Subject: [PATCH 138/175] [CLEAN[ mail_followers widget: cleaned subtype management. bzr revid: tde@openerp.com-20120920114909-90s6f5dvol2y0vo7 --- addons/mail/static/src/js/mail_followers.js | 94 +++++++++---------- addons/mail/static/src/xml/mail_followers.xml | 21 ++--- 2 files changed, 54 insertions(+), 61 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index f4710580d81..c048550611b 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -36,14 +36,12 @@ openerp_mail_followers = function(session, mail) { // use actual_mode property on view to know if the view is in create mode anymore this.view.on("change:actual_mode", this, this._check_visibility); this._check_visibility(); - this.fetch_subtype(); this.reinit(); this.bind_events(); }, _check_visibility: function() { this.$el.toggle(this.view.get("actual_mode") !== "create"); - if (this.view.get("actual_mode") !== "create"){this.fetch_subtype();} }, reinit: function() { @@ -56,8 +54,8 @@ openerp_mail_followers = function(session, mail) { this.$('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); }) .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); - this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); self.fetch_subtype(); }); - this.$el.on('click','ul.oe_mail_recthread_subtype', function () {self.update_subtype();}) + this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); }); + this.$el.on('click', 'ul.oe_mail_recthread_subtypes', function () {self.do_update_subscription(); }) this.$el.on('click', 'button.oe_mail_button_invite', function(event) { action = { type: 'ir.actions.act_window', @@ -77,18 +75,30 @@ openerp_mail_followers = function(session, mail) { read_value: function() { var self = this; - return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).pipe(function (results) { - return results[0].message_follower_ids; - }).pipe(this.proxy('set_value')); + return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids', 'message_is_follower', 'message_subtype_data']).pipe(function (results) { + self.set_value(results[0].message_follower_ids, results[0].message_is_follower, results[0].message_subtype_data); + }); }, - set_value: function(value_) { + set_value: function(value_, message_is_follower_value_, message_subtype_data_value_) { this.reinit(); if (! this.view.datarecord.id || session.web.BufferedDataSet.virtual_id_regex.test(this.view.datarecord.id)) { this.$el.find('div.oe_mail_recthread_aside').hide(); return; } + if (message_subtype_data_value_ === undefined) { + this.message_subtype_data_value_ = this.view.fields.message_subtype_data && this.view.fields.message_subtype_data.get_value() || {}; + } + else { + this.message_subtype_data_value_ = message_subtype_data_value_; + } + if (message_is_follower_value_ === undefined) { + this.message_is_follower_value_ = this.view.fields.message_is_follower && this.view.fields.message_is_follower.get_value() || false; + } + else { + this.message_is_follower_value_ = message_is_follower_value_; + } return this.fetch_followers(value_ || this.get_value()); }, @@ -108,63 +118,47 @@ openerp_mail_followers = function(session, mail) { }); if (this.message_is_follower) { this.$el.find('button.oe_mail_button_follow').hide(); - this.$el.find('button.oe_mail_button_unfollow').show(); - this.$el.find('ul.oe_mail_recthread_subtype').show(); } + this.$el.find('button.oe_mail_button_unfollow').show(); + } else { this.$el.find('button.oe_mail_button_follow').show(); this.$el.find('button.oe_mail_button_unfollow').hide(); - this.$el.find('ul.oe_mail_recthread_subtype').hide() - } + } + return this.display_subtypes(this.message_subtype_data_value_); }, - update_subtype: function (){ - var self = this; - var cheklist = new Array(); - _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ - if($(record).is(':checked')) { - cheklist.push(parseInt($(record).attr('id')))} - }); - self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],[self.session.uid],cheklist]) - }, - // Display the subtypes of each records. - display_subtype: function(records) { + + /** Display subtypes: {'name': default, followed} */ + display_subtypes: function (records) { var self = this - var subtype_list = this.$el.find('ul.oe_mail_recthread_subtype').empty(); - var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id]]]) - follower_ids.then(function (record){ - var follower_read = self.follower_model.call('read', [record,['subtype_ids']]); - follower_read.then(function (follower_record){ - if(follower_record.length != 0){ - _(follower_record[0].subtype_ids).each(function (subtype_id){ - var subtype_check = self.$el.find('.oe_msg_subtype_check[id=' + subtype_id + ']') - if(subtype_check.length > 0){ - subtype_check[0].checked=true} - }); - } - }) - }); - _(records).each(function (record) { - record.name = record.name.toLowerCase().replace(/\b[a-z]/g, function(letter) {return letter.toUpperCase();}); - $(session.web.qweb.render('mail.record_thread.subtype', {'record': record})).appendTo(subtype_list); + // this.$el.find('ul.oe_mail_recthread_subtype').show(); + var subtype_list = this.$el.find('ul.oe_mail_recthread_subtypes').empty(); + _(records).each(function (record, record_name) { + record.name = record_name; + record.followed = record.followed || undefined; + $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo(subtype_list); }); }, do_follow: function () { var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); - }, - - //fetch subtype from subtype model - fetch_subtype: function () { - var self = this - var subtype_object = this.sub_model.call('search', [[['res_model','=',this.view.model]]]); - subtype_object.then(function (subtype_ids){ - self.sub_model.call('read', [subtype_ids || self.get_value(),['name', 'default']]).then(self.proxy('display_subtype')); - }); + return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, undefined, context]).pipe(this.proxy('read_value')); }, do_unfollow: function () { var context = new session.web.CompoundContext(this.build_context(), {}); return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); }, + + do_update_subscription: function () { + var context = new session.web.CompoundContext(this.build_context(), {}); + var self = this; + var checklist = new Array(); + _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ + if($(record).is(':checked')) { + checklist.push(parseInt($(record).attr('id')))} + }); + return this.ds_model.call('message_subscribe_users',[[self.view.datarecord.id], undefined, checklist, context]).pipe(this.proxy('read_value')); + }, + }); }; diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 9d7a0077437..b2922753acf 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -7,11 +7,14 @@ -->
                    - + +
                    +

                    Message types to follow

                    +
                      +
                      -

                        @@ -30,18 +33,14 @@ \ -
                      • +
                      • - - + +
                        - - - -
                      • From b1d05506ebe2eb1c262e5dbec05f7305603320f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 13:49:47 +0200 Subject: [PATCH 139/175] [FIX] mail_thread: fixed message_subscribe, not recognizing void list compared to none; misc fixes of subtype. bzr revid: tde@openerp.com-20120920114947-64643cmduzww5i5c --- addons/mail/mail_thread.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 39a8e011f3c..5ad76a44c4f 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -143,13 +143,15 @@ class mail_thread(osv.AbstractModel): - message_is_follower: is uid in the document followers - message_subtype_data: data about document subtypes: which are available, which are followed if any """ - res = dict((id, dict(message_subtype_data='')) for id in ids) + res = dict((id, dict(message_subtype_data='', message_is_follower=False)) for id in ids) user_pid = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id'][0] # find current model subtypes, add them to a dictionary subtype_obj = self.pool.get('mail.message.subtype') subtype_ids = subtype_obj.search(cr, uid, ['|', ('res_model', '=', self._name), ('res_model', '=', False)], context=context) - subtype_dict = dict((subtype.name, dict(default=subtype.default, followed=False)) for subtype in subtype_obj.browse(cr, uid, subtype_ids, context=context)) + subtype_dict = dict((subtype.name, dict(default=subtype.default, followed=False, id=subtype.id)) for subtype in subtype_obj.browse(cr, uid, subtype_ids, context=context)) + for id in ids: + res[id]['message_subtype_data'] = subtype_dict.copy() # find the document followers, update the data fol_obj = self.pool.get('mail.followers') @@ -159,11 +161,11 @@ class mail_thread(osv.AbstractModel): ('res_model', '=', self._name), ], context=context) for fol in fol_obj.browse(cr, uid, fol_ids, context=context): - thread_subtype_dict = subtype_dict.copy() + thread_subtype_dict = res[fol.res_id]['message_subtype_data'] res[fol.res_id]['message_is_follower'] = True for subtype in fol.subtype_ids: thread_subtype_dict[subtype.name]['followed'] = True - res[fol.res_id]['message_subtype_data'] = '%s' % thread_subtype_dict + res[fol.res_id]['message_subtype_data'] = thread_subtype_dict return res @@ -663,6 +665,7 @@ class mail_thread(osv.AbstractModel): def message_subscribe_users(self, cr, uid, ids, user_ids=None, subtype_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not provided, subscribe uid instead. """ + print cr, uid, ids, user_ids, subtype_ids, context if not user_ids: user_ids = [uid] partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] @@ -671,15 +674,14 @@ class mail_thread(osv.AbstractModel): def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None): """ Add partners to the records followers. """ self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) - - if not subtype_ids: + # if subtypes are not specified (and not set to a void list), fetch default ones + if subtype_ids is None: subtype_obj = self.pool.get('mail.message.subtype') subtype_ids = subtype_obj.search(cr, uid, [('default', '=', True), '|', ('res_model', '=', self._name), ('res_model', '=', False)], context=context) - + # update the subscriptions fol_obj = self.pool.get('mail.followers') fol_ids = fol_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids), ('partner_id', 'in', partner_ids)], context=context) fol_obj.write(cr, uid, fol_ids, {'subtype_ids': [(6, 0, subtype_ids)]}, context=context) - return True def message_unsubscribe_users(self, cr, uid, ids, user_ids=None, context=None): From 2a33b4cb266e1c087998e9b47bb60431cce5ece7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 13:57:46 +0200 Subject: [PATCH 140/175] [FIX] mail: fixed tests. bzr revid: tde@openerp.com-20120920115746-6ospayxyyi6y9c3z --- addons/mail/tests/test_mail.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/mail/tests/test_mail.py b/addons/mail/tests/test_mail.py index 28dd3e6fe4f..11bc860fb0f 100644 --- a/addons/mail/tests/test_mail.py +++ b/addons/mail/tests/test_mail.py @@ -306,11 +306,10 @@ class test_mail(TestMailMockups): # ---------------------------------------- group_pigs.refresh() - subtype_data = eval(group_pigs.message_subtype_data) - self.assertEqual(set(subtype_data.keys()), set(['comment', 'mt_mg_def', 'mt_all_def', 'mt_mg_nodef', 'mt_all_nodef']), 'mail.group available subtypes incorrect') - self.assertFalse(subtype_data['comment']['followed'], 'Admin should not follow comments in pigs') - self.assertTrue(subtype_data['mt_mg_nodef']['followed'], 'Admin should follow mt_mg_nodef in pigs') - self.assertTrue(subtype_data['mt_all_nodef']['followed'], 'Admin should follow mt_all_nodef in pigs') + self.assertEqual(set(group_pigs.message_subtype_data.keys()), set(['comment', 'mt_mg_def', 'mt_all_def', 'mt_mg_nodef', 'mt_all_nodef']), 'mail.group available subtypes incorrect') + self.assertFalse(group_pigs.message_subtype_data['comment']['followed'], 'Admin should not follow comments in pigs') + self.assertTrue(group_pigs.message_subtype_data['mt_mg_nodef']['followed'], 'Admin should follow mt_mg_nodef in pigs') + self.assertTrue(group_pigs.message_subtype_data['mt_all_nodef']['followed'], 'Admin should follow mt_all_nodef in pigs') def test_20_message_post(self): """ Tests designed for message_post. """ From 1206b8f7a0c8d2de9cd7ae05eefbd1c84433896f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 13:59:00 +0200 Subject: [PATCH 141/175] [IMP] Addons: added message_is_follower and message_subtype_data invisible fields to all views using Chatter and Followers widgets. bzr revid: tde@openerp.com-20120920115900-vvpfhjvw135vhf91 --- addons/account/account_invoice_view.xml | 6 ++++ .../account_voucher/account_voucher_view.xml | 3 ++ .../voucher_payment_receipt_view.xml | 6 ++++ .../voucher_sales_purchase_view.xml | 6 ++++ addons/analytic/analytic_view.xml | 3 ++ addons/base_calendar/crm_meeting_view.xml | 3 ++ addons/crm/crm_lead_view.xml | 6 ++++ addons/crm/crm_phonecall_view.xml | 3 ++ addons/crm_claim/crm_claim_view.xml | 3 ++ addons/crm_helpdesk/crm_helpdesk_view.xml | 3 ++ addons/event/event_view.xml | 6 ++++ addons/hr_expense/hr_expense_view.xml | 3 ++ addons/hr_holidays/hr_holidays_view.xml | 6 ++++ addons/hr_recruitment/hr_recruitment_view.xml | 3 ++ addons/idea/idea_view.xml | 3 ++ addons/mail/mail_group_view.xml | 6 ++++ addons/mail/mail_thread.py | 1 - addons/mail/res_partner_view.xml | 3 ++ addons/mrp/mrp_view.xml | 6 ++++ addons/mrp_operations/mrp_operations_view.xml | 3 ++ addons/mrp_repair/mrp_repair_view.xml | 3 ++ addons/note/note_view.xml | 32 +++++++++++-------- addons/procurement/procurement_view.xml | 3 ++ addons/product/product_view.xml | 3 ++ addons/project/project_view.xml | 6 ++++ addons/project_issue/project_issue_view.xml | 3 ++ addons/purchase/purchase_view.xml | 3 ++ .../purchase_requisition_view.xml | 3 ++ addons/sale/sale_view.xml | 3 ++ addons/stock/stock_view.xml | 6 ++++ 30 files changed, 133 insertions(+), 14 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 1c4d83106ca..a24c86c58f4 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -279,6 +279,9 @@
                        + + +
                        @@ -438,6 +441,9 @@
                        + + +
                        diff --git a/addons/account_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml index 07647d02fe3..daf1f7a361e 100644 --- a/addons/account_voucher/account_voucher_view.xml +++ b/addons/account_voucher/account_voucher_view.xml @@ -111,6 +111,9 @@
                        + + +
                        diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index c41ed6d5577..0e7e4dd3fe7 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -240,6 +240,9 @@
                        + + +
                        @@ -409,6 +412,9 @@
                        + + +
                        diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml index 5bcecfa268e..2ba0aa6e691 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/voucher_sales_purchase_view.xml @@ -147,6 +147,9 @@
                        + + +
                        @@ -302,6 +305,9 @@
                        + + +
                        diff --git a/addons/analytic/analytic_view.xml b/addons/analytic/analytic_view.xml index 51f5428002f..1613a3a20b0 100644 --- a/addons/analytic/analytic_view.xml +++ b/addons/analytic/analytic_view.xml @@ -54,6 +54,9 @@
                        + + +
                        diff --git a/addons/base_calendar/crm_meeting_view.xml b/addons/base_calendar/crm_meeting_view.xml index b963de68130..88f62c5320a 100644 --- a/addons/base_calendar/crm_meeting_view.xml +++ b/addons/base_calendar/crm_meeting_view.xml @@ -230,6 +230,9 @@
                        + + +
                        diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index f018a355579..4bfa145188c 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -222,6 +222,9 @@
                        + + +
                        @@ -522,6 +525,9 @@
                        + + +
                        diff --git a/addons/crm/crm_phonecall_view.xml b/addons/crm/crm_phonecall_view.xml index 8c1e1c9ec76..160c3bfe388 100644 --- a/addons/crm/crm_phonecall_view.xml +++ b/addons/crm/crm_phonecall_view.xml @@ -151,6 +151,9 @@
                        + + +
                        diff --git a/addons/crm_claim/crm_claim_view.xml b/addons/crm_claim/crm_claim_view.xml index 820fb38e58a..db9a75eca5e 100644 --- a/addons/crm_claim/crm_claim_view.xml +++ b/addons/crm_claim/crm_claim_view.xml @@ -182,6 +182,9 @@
                        + + +
                        diff --git a/addons/crm_helpdesk/crm_helpdesk_view.xml b/addons/crm_helpdesk/crm_helpdesk_view.xml index 5399c9880ca..aec2b8c1e4c 100644 --- a/addons/crm_helpdesk/crm_helpdesk_view.xml +++ b/addons/crm_helpdesk/crm_helpdesk_view.xml @@ -100,6 +100,9 @@
                        + + +
                        diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml index fd396053d5d..b2502c23b06 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -198,6 +198,9 @@
                        + + +
                        @@ -480,6 +483,9 @@
                        + + +
                        diff --git a/addons/hr_expense/hr_expense_view.xml b/addons/hr_expense/hr_expense_view.xml index 5389f88b885..e577d196695 100644 --- a/addons/hr_expense/hr_expense_view.xml +++ b/addons/hr_expense/hr_expense_view.xml @@ -140,6 +140,9 @@
                        + + +
                        diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml index 5a2e0603b88..8ac67fa1723 100644 --- a/addons/hr_holidays/hr_holidays_view.xml +++ b/addons/hr_holidays/hr_holidays_view.xml @@ -122,6 +122,9 @@
                        + + +
                        @@ -159,6 +162,9 @@
                        + + +
                        diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index 08e5f31a2d2..e81da63b73c 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -184,6 +184,9 @@
                        + + +
                        diff --git a/addons/idea/idea_view.xml b/addons/idea/idea_view.xml index eab3d03ceea..3861e86bff8 100644 --- a/addons/idea/idea_view.xml +++ b/addons/idea/idea_view.xml @@ -78,6 +78,9 @@
                        + + +
                        diff --git a/addons/mail/mail_group_view.xml b/addons/mail/mail_group_view.xml index 31beba80ecc..a805fb3b575 100644 --- a/addons/mail/mail_group_view.xml +++ b/addons/mail/mail_group_view.xml @@ -16,6 +16,9 @@ + + + @@ -83,6 +86,9 @@
                        + + +
                        diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 5ad76a44c4f..bf50b582323 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -665,7 +665,6 @@ class mail_thread(osv.AbstractModel): def message_subscribe_users(self, cr, uid, ids, user_ids=None, subtype_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not provided, subscribe uid instead. """ - print cr, uid, ids, user_ids, subtype_ids, context if not user_ids: user_ids = [uid] partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] diff --git a/addons/mail/res_partner_view.xml b/addons/mail/res_partner_view.xml index 2a8430926d5..9589b6409a7 100644 --- a/addons/mail/res_partner_view.xml +++ b/addons/mail/res_partner_view.xml @@ -11,6 +11,9 @@
                        + + +
                        diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index d05893cf778..a379ae9b4cb 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -410,6 +410,9 @@
                        + + +
                        @@ -788,6 +791,9 @@
                        + + +
                        diff --git a/addons/mrp_operations/mrp_operations_view.xml b/addons/mrp_operations/mrp_operations_view.xml index 834f3000472..f069f06fca7 100644 --- a/addons/mrp_operations/mrp_operations_view.xml +++ b/addons/mrp_operations/mrp_operations_view.xml @@ -108,6 +108,9 @@
                        + + +
                        diff --git a/addons/mrp_repair/mrp_repair_view.xml b/addons/mrp_repair/mrp_repair_view.xml index 55cbe49c75b..9158944f952 100644 --- a/addons/mrp_repair/mrp_repair_view.xml +++ b/addons/mrp_repair/mrp_repair_view.xml @@ -190,6 +190,9 @@
                        + + +
                        diff --git a/addons/note/note_view.xml b/addons/note/note_view.xml index 8d943dde44d..4ed2fade43f 100644 --- a/addons/note/note_view.xml +++ b/addons/note/note_view.xml @@ -50,6 +50,7 @@ + @@ -108,19 +109,24 @@ - note.note.form - note.note - -
                        -
                        - - -
                        - - - - - + note.note.form + note.note + +
                        +
                        + + +
                        + +
                        + + + + + +
                        + +
                        diff --git a/addons/procurement/procurement_view.xml b/addons/procurement/procurement_view.xml index bf73b383216..b6138ca78d3 100644 --- a/addons/procurement/procurement_view.xml +++ b/addons/procurement/procurement_view.xml @@ -104,6 +104,9 @@
                        + + +
                        diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml index d04e6f17fe8..05e3d0b2497 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -202,6 +202,9 @@
                        + + +
                        diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index ff8ac943a67..4d7bceb4599 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -154,6 +154,9 @@
                        + + +
                        @@ -482,6 +485,9 @@
                        + + +
                        diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index be7427fe8f4..6d1d0272ab0 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -160,6 +160,9 @@
                        + + +
                        diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 796fd1351a9..9a2bd02f9a2 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -265,6 +265,9 @@
                        + + +
                        diff --git a/addons/purchase_requisition/purchase_requisition_view.xml b/addons/purchase_requisition/purchase_requisition_view.xml index 1fafec92bc7..13ea40df765 100644 --- a/addons/purchase_requisition/purchase_requisition_view.xml +++ b/addons/purchase_requisition/purchase_requisition_view.xml @@ -103,6 +103,9 @@
                        + + +
                        diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 5c2320a7d5c..32d9b03cdff 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -352,6 +352,9 @@
                        + + +
                        diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 83fed186f42..1a8e7c0ff3f 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -918,6 +918,9 @@
                        + + +
                        @@ -1044,6 +1047,9 @@
                        + + +
                        From 6fa56dcba546286157a07771c8c5a35e6648cec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 14:20:24 +0200 Subject: [PATCH 142/175] [IMP] Followers widget: cleaned code, and now more clearly uses message_is_follower and message_subtype_data fields. bzr revid: tde@openerp.com-20120920122024-wf8ilufgrp1vhccd --- addons/mail/static/src/js/mail_followers.js | 41 ++++++++++--------- addons/mail/static/src/xml/mail_followers.xml | 4 +- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index c048550611b..58c53d5556a 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -55,7 +55,7 @@ openerp_mail_followers = function(session, mail) { .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); }); - this.$el.on('click', 'ul.oe_mail_recthread_subtypes', function () {self.do_update_subscription(); }) + this.$el.on('click', 'ul.oe_mail_subtypes', function () {self.do_update_subscription(); }) this.$el.on('click', 'button.oe_mail_button_invite', function(event) { action = { type: 'ir.actions.act_window', @@ -80,6 +80,18 @@ openerp_mail_followers = function(session, mail) { }); }, + get_or_set: function(field_name, value) { + if (this.view.fields[field_name]) { + if (value !== undefined) { + this.view.fields[field_name].set_value(value); + } + return this.view.fields[field_name].get_value(); + } + else { + return value; + } + }, + set_value: function(value_, message_is_follower_value_, message_subtype_data_value_) { this.reinit(); if (! this.view.datarecord.id || @@ -87,36 +99,25 @@ openerp_mail_followers = function(session, mail) { this.$el.find('div.oe_mail_recthread_aside').hide(); return; } - if (message_subtype_data_value_ === undefined) { - this.message_subtype_data_value_ = this.view.fields.message_subtype_data && this.view.fields.message_subtype_data.get_value() || {}; - } - else { - this.message_subtype_data_value_ = message_subtype_data_value_; - } - if (message_is_follower_value_ === undefined) { - this.message_is_follower_value_ = this.view.fields.message_is_follower && this.view.fields.message_is_follower.get_value() || false; - } - else { - this.message_is_follower_value_ = message_is_follower_value_; - } + this.message_is_follower_value_ = this.get_or_set('message_is_follower', message_is_follower_value_) || false; + this.message_subtype_data_value_ = this.get_or_set('message_subtype_data', message_subtype_data_value_) || {}; return this.fetch_followers(value_ || this.get_value()); }, fetch_followers: function (value_) { - return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers')); + return this.ds_follow.call('read', [value_, ['name']]).pipe(this.proxy('display_followers')); }, /** Display the followers, evaluate is_follower directly */ display_followers: function (records) { var self = this; - this.message_is_follower = _.indexOf(_.flatten(_.pluck(records, 'user_ids')), this.session.uid) != -1; var node_user_list = this.$el.find('ul.oe_mail_followers_display').empty(); this.$el.find('div.oe_mail_recthread_followers h4').html(this.options.title + ' (' + records.length + ')'); _(records).each(function (record) { record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id); $(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(node_user_list); }); - if (this.message_is_follower) { + if (this.message_is_follower_value_) { this.$el.find('button.oe_mail_button_follow').hide(); this.$el.find('button.oe_mail_button_unfollow').show(); } @@ -129,9 +130,11 @@ openerp_mail_followers = function(session, mail) { /** Display subtypes: {'name': default, followed} */ display_subtypes: function (records) { - var self = this - // this.$el.find('ul.oe_mail_recthread_subtype').show(); - var subtype_list = this.$el.find('ul.oe_mail_recthread_subtypes').empty(); + if (! this.message_is_follower_value_) { + this.$('div.oe_mail_recthread_subtypes').remove(); + return; + } + var subtype_list = this.$el.find('ul.oe_mail_subtypes').empty(); _(records).each(function (record, record_name) { record.name = record_name; record.followed = record.followed || undefined; diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index b2922753acf..05eb349ea5d 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -10,9 +10,9 @@ -
                        +

                        Message types to follow

                        -
                          +
                            From fda33df8a608fd5063ae45b7f9db73c9e1c65013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 14:39:59 +0200 Subject: [PATCH 143/175] [FIX] Followers widget: fixed bad refreshing when going through various form views. bzr revid: tde@openerp.com-20120920123959-3799cpr57f7ac3u1 --- addons/mail/static/src/js/mail_followers.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 58c53d5556a..1e650ca7125 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -130,11 +130,10 @@ openerp_mail_followers = function(session, mail) { /** Display subtypes: {'name': default, followed} */ display_subtypes: function (records) { + var subtype_list = this.$('ul.oe_mail_subtypes').empty(); if (! this.message_is_follower_value_) { - this.$('div.oe_mail_recthread_subtypes').remove(); return; } - var subtype_list = this.$el.find('ul.oe_mail_subtypes').empty(); _(records).each(function (record, record_name) { record.name = record_name; record.followed = record.followed || undefined; From 3774f6d54572584b4860c712ad7e15b3d25fb1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 20 Sep 2012 16:46:45 +0200 Subject: [PATCH 144/175] [IMP] [FIX] Chatter: fixed load more, message_read and expandables. Cleaned tests. bzr revid: tde@openerp.com-20120920144645-o92edguwjzws3t3e --- addons/mail/mail_message.py | 31 ++++++----- addons/mail/static/src/css/mail.css | 25 ++++----- addons/mail/static/src/js/mail.js | 86 ++++------------------------- addons/mail/static/src/xml/mail.xml | 19 ++++++- addons/mail/tests/test_mail.py | 22 ++++---- 5 files changed, 68 insertions(+), 115 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 362b027f6d1..dee44d9f8b8 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -208,7 +208,7 @@ class mail_message(osv.Model): if parent_message and current_level < level: base_domain += [('parent_id', '=', parent_message['id'])] elif parent_message: - base_domain += [('id', 'child_of', parent_message['id'])] + base_domain += [('id', 'child_of', parent_message['id']), ('id', '!=', parent_message['id'])] if domain: base_domain += domain extension = { 'type': 'expandable', @@ -219,7 +219,7 @@ class mail_message(osv.Model): } return extension - def message_read_tree_flatten(self, cr, uid, parent_message, messages, domain=[], level=0, current_level=0, context=None, limit=None): + def message_read_tree_flatten(self, cr, uid, parent_message, messages, domain=[], level=0, current_level=0, context=None, limit=None, add_expandable=True): """ Given a tree with several roots of following structure : [ {'id': 1, 'child_ids': [ {'id': 11, 'child_ids': [...] },], @@ -238,33 +238,36 @@ class mail_message(osv.Model): child_ids = msg_dict.pop('child_ids', []) msg_dict['child_ids'] = [] return [msg_dict] + child_ids + context = context or {} limit = limit or self._message_read_limit + # Depth-first flattening for message in messages: if message.get('type') == 'expandable': continue - message['child_ids'] = self.message_read_tree_flatten(cr, uid, message, message['child_ids'], domain, level, current_level + 1, context=context) + message['child_ids'] = self.message_read_tree_flatten(cr, uid, message, message['child_ids'], domain, level, current_level + 1, context=context, limit=limit) for child in message['child_ids']: + if child.get('type') == 'expandable': + continue message['child_nbr'] += child['child_nbr'] # Flatten if above maximum depth if current_level < level: return_list = messages else: return_list = [flat_message for message in messages for flat_message in _flatten(message)] + # Add expandable return_list = sorted(return_list, key=itemgetter(context.get('sort_key', 'id')), reverse=context.get('sort_reverse', True)) - if current_level == 0: - expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, [], current_level, level, context=context) - if len(return_list) >= limit: - print 'we need an expandable here' - print 'expandable', expandable - elif current_level <= level: - expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, [], current_level, level, context=context) - print 'expandable', expandable + if return_list and current_level == 0 and add_expandable: + expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, domain, current_level, level, context=context) + return_list.append(expandable) + elif return_list and current_level <= level and add_expandable: + expandable = self.message_read_tree_get_expandable(cr, uid, parent_message, return_list and return_list[-1] or parent_message, domain, current_level, level, context=context) + return_list.append(expandable) return return_list - def message_read(self, cr, uid, ids=False, domain=[], level=0, context=None, limit=None, parent_id=False): + def message_read(self, cr, uid, ids=False, domain=[], level=0, context=None, parent_id=False, limit=None): """ Read messages from mail.message, and get back a structured tree of messages to be displayed as discussion threads. If IDs is set, fetch these records. Otherwise use the domain to fetch messages. @@ -278,11 +281,11 @@ class mail_message(osv.Model): further parents :return list: list of trees of messages """ - limit = limit or self._message_read_limit context = context or {} if not ids: ids = self.search(cr, uid, domain, context=context, limit=limit) messages = self.browse(cr, uid, ids, context=context) + add_expandable = (len(messages) >= limit) # key: ID, value: record tree = {} @@ -305,7 +308,7 @@ class mail_message(osv.Model): tree[msg.id] = record # Flatten the result - result = self.message_read_tree_flatten(cr, uid, None, result, domain, level, context=context) + result = self.message_read_tree_flatten(cr, uid, None, result, domain, level, context=context, limit=limit, add_expandable=add_expandable) return result #------------------------------------------------------ diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 2f9b35f1c95..8e4185b17f9 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -55,16 +55,6 @@ height: 28px; } -.openerp div.oe_mail_msg_content { - position: relative; - width: 486px; -} - -.openerp div.oe_mail_msg_content > li { - float: left; - margin-right: 3px; -} - .openerp div.oe_mail_thread_subthread div.oe_mail_msg_content { width: 440px; } @@ -196,14 +186,16 @@ margin: 0 0 4px 0; } -.openerp .oe_mail_msg_notification, -.openerp .oe_mail_msg_comment, +.openerp .oe_mail_msg_notification, +.openerp .oe_mail_msg_expandable, +.openerp .oe_mail_msg_comment, .openerp .oe_mail_msg_email { padding: 8px; background: white; border-top: 1px solid #ccc; } +.openerp div.oe_mail_thread_subthread .oe_mail_msg_expandable, .openerp div.oe_mail_thread_subthread .oe_mail_msg_comment { background: #eee; } @@ -216,8 +208,15 @@ clear: both; } -.openerp .oe_mail_msg_content { +.openerp div.oe_mail_msg_content { + float: right; + position: relative; + width: 486px; +} + +.openerp div.oe_mail_msg_content > li { float: left; + margin-right: 3px; } .openerp .oe_mail_msg_content:after { diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 3ab566d2e21..eb25084f530 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -32,27 +32,6 @@ openerp.mail = function(session) { }); - /** - * ------------------------------------------------------------ - * Sidebar - * ------------------------------------------------------------ - * - * Override of sidebar do_attachment_new method, to catch attachments added - * through the sidebar and show them in the Chatter composition form. - */ - - // session.web.Sidebar = session.web.Sidebar.extend({ - // do_attachment_new: function(attachment) { - // this._super(attachment); - // var message_ids = this.getParent().fields.message_ids || undefined; - // if (! message_ids) { return; } - // var compose_message_widget = message_ids.thread.compose_message_widget; - // if (! compose_message_widget) { return; } - // compose_message_widget.attachments.push(attachment); - // compose_message_widget.display_attachments(); - // }, - // }); - /** * ------------------------------------------------------------ * ChatterUtils @@ -308,7 +287,6 @@ openerp.mail = function(session) { show_dd_reply_by_email:options.show_dd_reply_by_email != undefined ? options.show_dd_reply_by_email: true, show_dd_delete: options.show_dd_delete || false, show_dd_hide: options.show_dd_hide || false, - show_more: options.show_more || false, truncate_limit: options.truncate_limit || 250, } // datasets and internal vars @@ -346,7 +324,7 @@ openerp.mail = function(session) { bind_events: function() { var self = this; // event: click on 'More' at bottom of thread - this.$el.on('click', 'button.oe_mail_button_more', this.do_message_fetch_more); + this.$el.on('click', 'a.oe_mail_fetch_more', this.do_message_fetch_more); // event: writing in basic textarea of composition form (quick reply) this.$el.find('textarea.oe_mail_compose_textarea').keyup(function (event) { var charCode = (event.which) ? event.which : window.event.keyCode; @@ -421,7 +399,6 @@ openerp.mail = function(session) { 'default_parent_id': this.context.default_parent_id, 'default_content_subtype': 'plain'} ); } - // return this._super(action, on_close); }, /** Instantiate the composition form, with every parameters in context @@ -459,14 +436,14 @@ openerp.mail = function(session) { message_fetch: function (initial_mode, additional_domain, additional_context) { var self = this; // domain and context: options + additional - fetch_domain = _.flatten([this.domain, additional_domain || []], true) - fetch_context = _.extend(this.context, additional_context || {}) + fetch_domain = _.flatten([this.domain, additional_domain || []], true); + fetch_context = _.extend({}, this.context, additional_context || {}); // initial mode: try to use message_data or message_ids if (initial_mode && this.options.message_data) { return this.message_display(this.options.message_data); } message_ids = initial_mode && this.options.message_ids != null && this.options.message_ids || false; - return this.ds_message.call('message_read', [message_ids, fetch_domain, this.options.thread_level, fetch_context] + return this.ds_message.call('message_read', [message_ids, fetch_domain, this.options.thread_level, fetch_context, this.context.default_parent_id || undefined] ).then(this.proxy('message_display')); }, @@ -476,13 +453,12 @@ openerp.mail = function(session) { */ message_display: function (records) { var self = this; - var _expendable = false; _(records).each(function (record) { if (record.type == 'expandable') { - _expendable = true; - self.update_fetch_more(true); self.fetch_more_domain = record.domain; self.fetch_more_context = record.context; + var rendered = session.web.qweb.render('mail.thread.message.expandable', {'record': record}); + $(rendered).appendTo(self.$el.children('div.oe_mail_thread_display:first')); } else { self.display_record(record); @@ -501,9 +477,6 @@ openerp.mail = function(session) { self.thread.appendTo(self.$el.find('div.oe_mail_thread_subthread:last')); } }); - if (! _expendable) { - this.update_fetch_more(false); - } }, /** Displays a record and performs some formatting on the record : @@ -558,15 +531,6 @@ openerp.mail = function(session) { vote_node.html(vote_element); }, - /** Display 'show more' button */ - update_fetch_more: function (new_value) { - if (new_value) { - this.$el.find('div.oe_mail_thread_more:last').show(); - } else { - this.$el.find('div.oe_mail_thread_more:last').hide(); - } - }, - display_user_avatar: function () { var avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid); return this.$el.find('img.oe_mail_icon').attr('src', avatar); @@ -581,45 +545,15 @@ openerp.mail = function(session) { } return this.ds_thread.call('message_post', [ [this.context.default_res_id], body, false, 'comment', this.context.default_parent_id, undefined] - ).then(self.message_fetch()); + ).pipe(self.message_clean()).pipe(self.message_fetch(false)); }, /** Action: 'shows more' to fetch new messages */ - do_message_fetch_more: function () { + do_message_fetch_more: function (event) { + event.stopPropagation(); + $(event.srcElement).parents('li').eq(0).remove(); return this.message_fetch(false, this.fetch_more_domain, this.fetch_more_context); }, - - // TDE: keep currently because need something similar - // /** - // * Create a domain to fetch new comments according to - // * comment already present in comments_structure - // * @param {Object} comments_structure (see chatter utils) - // * @returns {Array} fetch_domain (OpenERP domain style) - // */ - // get_fetch_domain: function (comments_structure) { - // var domain = []; - // var ids = comments_structure.root_ids.slice(); - // var ids2 = []; - // // must be child of current parent - // if (this.options.parent_id) { domain.push(['id', 'child_of', this.options.parent_id]); } - // _(comments_structure.root_ids).each(function (id) { // each record - // ids.push(id); - // ids2.push(id); - // }); - // if (this.options.parent_id != false) { - // ids2.push(this.options.parent_id); - // } - // // must not be children of already fetched messages - // if (ids.length > 0) { - // domain.push('&'); - // domain.push('!'); - // domain.push(['id', 'child_of', ids]); - // } - // if (ids2.length > 0) { - // domain.push(['id', 'not in', ids2]); - // } - // return domain; - // }, }); diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index e3586e723e4..cddccedbf6a 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -101,9 +101,9 @@
                            -
                            + @@ -161,6 +161,21 @@
                            + +
                          • +
                            +
                            + + +
                            +
                          • + - -
                            @@ -441,11 +437,7 @@
                            - - - -
                            diff --git a/addons/account_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml index f06960ba7d2..5e26c366778 100644 --- a/addons/account_voucher/account_voucher_view.xml +++ b/addons/account_voucher/account_voucher_view.xml @@ -108,11 +108,7 @@
                            - - - -
                            diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index 03dc6b33fa2..c41ed6d5577 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -239,11 +239,7 @@
                            - - - -
                            @@ -412,11 +408,7 @@
                            - - - -
                            diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml index 2affc51b667..5bcecfa268e 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/voucher_sales_purchase_view.xml @@ -146,11 +146,7 @@
                            - - - -
                            @@ -305,11 +301,7 @@
                            - - - -
                            diff --git a/addons/analytic/analytic_view.xml b/addons/analytic/analytic_view.xml index 8f25d03ce30..51f5428002f 100644 --- a/addons/analytic/analytic_view.xml +++ b/addons/analytic/analytic_view.xml @@ -53,11 +53,7 @@
                            - - - -
                            diff --git a/addons/base_calendar/crm_meeting_view.xml b/addons/base_calendar/crm_meeting_view.xml index 5c0a3790fd6..b963de68130 100644 --- a/addons/base_calendar/crm_meeting_view.xml +++ b/addons/base_calendar/crm_meeting_view.xml @@ -229,11 +229,7 @@
                            - - - -
                            diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 5f52f3e0d93..f91a8756598 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -223,11 +223,7 @@
                            - - - -
                            @@ -529,11 +525,7 @@
                            - - - -
                            diff --git a/addons/crm/crm_phonecall_view.xml b/addons/crm/crm_phonecall_view.xml index f3ce57f10a9..ea20624d738 100644 --- a/addons/crm/crm_phonecall_view.xml +++ b/addons/crm/crm_phonecall_view.xml @@ -149,11 +149,7 @@
                            - - - -
                            diff --git a/addons/crm_claim/crm_claim_view.xml b/addons/crm_claim/crm_claim_view.xml index 38b7e9891cf..820fb38e58a 100644 --- a/addons/crm_claim/crm_claim_view.xml +++ b/addons/crm_claim/crm_claim_view.xml @@ -181,11 +181,7 @@
                            - - - -
                            diff --git a/addons/crm_helpdesk/crm_helpdesk_view.xml b/addons/crm_helpdesk/crm_helpdesk_view.xml index d914cd601e8..5399c9880ca 100644 --- a/addons/crm_helpdesk/crm_helpdesk_view.xml +++ b/addons/crm_helpdesk/crm_helpdesk_view.xml @@ -99,11 +99,7 @@
                            - - - -
                            diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml index 9f9130ced4d..e7c14aab18f 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -197,11 +197,7 @@
                            - - - -
                            @@ -483,11 +479,7 @@
                            - - - -
                            diff --git a/addons/hr_expense/hr_expense_view.xml b/addons/hr_expense/hr_expense_view.xml index 265c07328e6..8049255afbf 100644 --- a/addons/hr_expense/hr_expense_view.xml +++ b/addons/hr_expense/hr_expense_view.xml @@ -139,11 +139,7 @@
                            - - - -
                            diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml index 84a48e46615..347e2b17ca5 100644 --- a/addons/hr_holidays/hr_holidays_view.xml +++ b/addons/hr_holidays/hr_holidays_view.xml @@ -121,11 +121,7 @@
                            - - - -
                            @@ -162,11 +158,7 @@
                            - - - -
                            diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index 9e3045d766e..08e5f31a2d2 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -183,11 +183,7 @@
                            - - - -
                            diff --git a/addons/idea/idea_view.xml b/addons/idea/idea_view.xml index 7f42eeb3751..eab3d03ceea 100644 --- a/addons/idea/idea_view.xml +++ b/addons/idea/idea_view.xml @@ -77,11 +77,7 @@
                            - - - -
                            diff --git a/addons/mail/mail_group_view.xml b/addons/mail/mail_group_view.xml index 869c76d2110..40f0a754e4f 100644 --- a/addons/mail/mail_group_view.xml +++ b/addons/mail/mail_group_view.xml @@ -15,12 +15,10 @@ - - - - + +
                            @@ -84,12 +82,8 @@
                            - - - -
                            diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 97e78cfdd15..71d4bfd099b 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -169,6 +169,7 @@ class mail_thread(osv.AbstractModel): for subtype in fol.subtype_ids: thread_subtype_dict[subtype.name]['followed'] = True res[fol.res_id]['message_subtype_data'] = thread_subtype_dict + return res def _search_unread(self, cr, uid, obj=None, name=None, domain=None, context=None): @@ -679,6 +680,11 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, subtype_ids=subtype_ids, context=context) + def get_message_subtypes(self, cr, uid, ids, context=None): + """ message_subtype_data: data about document subtypes: which are + available, which are followed if any """ + return self._get_subscription_data(cr, uid, ids, None, None, context=context) + def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None): """ Add partners to the records followers. """ self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) diff --git a/addons/mail/res_partner_view.xml b/addons/mail/res_partner_view.xml index 3ef68ac8c59..2a8430926d5 100644 --- a/addons/mail/res_partner_view.xml +++ b/addons/mail/res_partner_view.xml @@ -9,12 +9,8 @@
                            - - - -
                            diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 895aa57bdc5..3fde4cbc67b 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -14,7 +14,6 @@ margin: 0; } - /* ------------------------------------------------------------ */ /* Wall /* ------------------------------------------------------------ */ @@ -37,6 +36,29 @@ list-style-type: none; } +/* ------------------------------------------------------------ */ +/* Followers +/* ------------------------------------------------------------ */ + +.openerp div.oe_mail_recthread_aside h4 { + display: inline-block; +} +.openerp div.oe_mail_recthread_aside button { + position: relative; +} +.openerp div.oe_mail_recthread_aside label, +.openerp div.oe_mail_recthread_aside input { + cursor:pointer; +} +.openerp div.oe_mail_recthread_subtypes { + display:none; +} +.openerp div.oe_mail_recthread_aside button span { + position: absolute; + top:-7px; + right:5px; +} + /* Specific display of threads in the wall */ /* ------------------------------------------------------------ */ @@ -113,15 +135,6 @@ margin-bottom: 8px; } - -/* ------------------------------------------------------------ */ -/* Followers -/* ------------------------------------------------------------ */ - -.openerp div.oe_mail_recthread_aside h4 { - display: inline-block; -} - /* ------------------------------------------------------------ */ /* Thread /* ------------------------------------------------------------ */ diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 0efbf9ca76e..a3ba6f91a04 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -27,9 +27,9 @@ openerp_mail_followers = function(session, mail) { this.options.image = this.node.attrs.image || 'image_small'; this.options.title = this.node.attrs.title || 'Followers'; this.ds_model = new session.web.DataSetSearch(this, this.view.model); - this.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype') + this.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype'); this.ds_follow = new session.web.DataSetSearch(this, this.field.relation); - this.follower_model = new session.web.DataSetSearch(this,'mail.followers') + this.follower_model = new session.web.DataSetSearch(this,'mail.followers'); }, start: function() { @@ -51,11 +51,12 @@ openerp_mail_followers = function(session, mail) { bind_events: function() { var self = this; - this.$el.find('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); }) - .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); }) - .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); - this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); }); - this.$el.on('click', 'ul.oe_mail_subtypes', function () {self.do_update_subscription(); }) + this.$el.find('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); self.clear_subtypes(); }) + .mouseover(function () { $(this).removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover').find('p').html('Unfollow');}) + .mouseleave(function () { $(this).removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout').find('p').html('Following'); }); + + this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); self.clear_subtypes(); }); + this.$el.on('click', 'ul.oe_mail_subtypes input', function () {self.do_update_subscription(); }) this.$el.on('click', 'button.oe_mail_button_invite', function(event) { action = { type: 'ir.actions.act_window', @@ -71,37 +72,34 @@ openerp_mail_followers = function(session, mail) { } self.do_action(action, function() { self.read_value(); }); }); + + this.$el.find('button span') + .click(function (e) { self.display_subtypes(); e.stopPropagation(); }) }, read_value: function() { var self = this; - return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids', 'message_is_follower', 'message_subtype_data']).pipe(function (results) { - self.set_value(results[0].message_follower_ids, results[0].message_is_follower, results[0].message_subtype_data); + return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).pipe(function (results) { + self.set_value(results[0].message_follower_ids); }); }, - get_or_set: function(field_name, value) { - if (this.view.fields[field_name]) { - if (value !== undefined) { - this.view.fields[field_name].set_value(value); - } - return this.view.fields[field_name].get_value(); - } - else { - return value; - } + set_value: function(value_) { + console.log("set_value", value_); + this.reinit(); + return this.fetch_followers(value_ || this.get_value()); }, - set_value: function(value_, message_is_follower_value_, message_subtype_data_value_) { - this.reinit(); - if (! this.view.datarecord.id || - session.web.BufferedDataSet.virtual_id_regex.test(this.view.datarecord.id)) { - this.$el.find('div.oe_mail_recthread_aside').hide(); - return; + set_is_follower: function(value_) { + for(var i in value_){ + if(value_[i]['user_ids'][0]==this.session.uid) + this.message_is_follower=true; + this.display_buttons(); + return true; } - this.message_is_follower_value_ = this.get_or_set('message_is_follower', message_is_follower_value_) || false; - this.message_subtype_data_value_ = this.get_or_set('message_subtype_data', message_subtype_data_value_) || {}; - return this.fetch_followers(value_ || this.get_value()); + this.message_is_follower=false; + this.display_buttons(); + return false; }, fetch_followers: function (value_, message_is_follower) { @@ -136,12 +134,11 @@ openerp_mail_followers = function(session, mail) { record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id); $(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(node_user_list); }); - this.display_buttons(); - return this.display_subtypes(this.message_subtype_data_value_); + self.set_is_follower(records); }, display_buttons: function () { - if (this.message_is_follower_value_) { + if (this.message_is_follower) { this.$el.find('button.oe_mail_button_follow').hide(); this.$el.find('button.oe_mail_button_unfollow').show(); } @@ -156,24 +153,48 @@ openerp_mail_followers = function(session, mail) { this.$el.find('span.oe_mail_invite_wrapper').show(); }, - /** Display subtypes: {'name': default, followed} */ - display_subtypes: function (records) { - var subtype_list = this.$el.find('ul.oe_mail_subtypes').empty(); - if (! this.message_is_follower_value_) { - return; - } + set_subtypes:function(data){ + var self = this; + var records = data[this.view.datarecord.id].message_subtype_data; _(records).each(function (record, record_name) { record.name = record_name; record.followed = record.followed || undefined; - $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo(subtype_list); + $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo( self.$el.find('ul.oe_mail_subtypes') ); }); }, - + + /** Display subtypes: {'name': default, followed} */ + display_subtypes: function () { + var self = this; + var recthread_subtypes = self.$el.find('.oe_mail_recthread_subtypes'); + subtype_list_ul = self.$el.find('ul.oe_mail_subtypes'); + + if(recthread_subtypes.is(":visible")) { + self.hidden_subtypes(); + } else { + if(subtype_list_ul.is(":empty")) { + var context = new session.web.CompoundContext(this.build_context(), {}); + this.ds_model.call('get_message_subtypes',[[self.view.datarecord.id], context]).pipe(this.proxy('set_subtypes')); + } + + recthread_subtypes.show(); + } + }, + + clear_subtypes: function(){ + this.$el.find('ul.oe_mail_subtypes').empty(); + this.hidden_subtypes(); + }, + + hidden_subtypes: function (){ + this.$el.find('.oe_mail_recthread_subtypes').hide(); + }, + do_follow: function () { var context = new session.web.CompoundContext(this.build_context(), {}); return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, undefined, context]).pipe(this.proxy('read_value')); }, - + do_unfollow: function () { var context = new session.web.CompoundContext(this.build_context(), {}); return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); @@ -182,13 +203,15 @@ openerp_mail_followers = function(session, mail) { do_update_subscription: function () { var context = new session.web.CompoundContext(this.build_context(), {}); var self = this; + var checklist = new Array(); _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ if($(record).is(':checked')) { - checklist.push(parseInt($(record).attr('id')))} + checklist.push(parseInt($(record).data('id')))} }); + return this.ds_model.call('message_subscribe_users',[[self.view.datarecord.id], undefined, checklist, context]).pipe(this.proxy('read_value')); }, }); -}; +}; \ No newline at end of file diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 05eb349ea5d..9d0543bbdca 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -7,9 +7,9 @@ -->
                            - - - + + +

                            Message types to follow

                              @@ -39,8 +39,8 @@
                            • - - + +
                            • diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index b49123b8a38..d05893cf778 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -410,9 +410,6 @@
                              - - -
                              @@ -790,11 +787,7 @@
                              - - - -
                              diff --git a/addons/mrp_operations/mrp_operations_view.xml b/addons/mrp_operations/mrp_operations_view.xml index 715f0a53531..834f3000472 100644 --- a/addons/mrp_operations/mrp_operations_view.xml +++ b/addons/mrp_operations/mrp_operations_view.xml @@ -107,11 +107,7 @@
                              - - - -
                              diff --git a/addons/mrp_repair/mrp_repair_view.xml b/addons/mrp_repair/mrp_repair_view.xml index 94a06e6b40d..55cbe49c75b 100644 --- a/addons/mrp_repair/mrp_repair_view.xml +++ b/addons/mrp_repair/mrp_repair_view.xml @@ -189,11 +189,7 @@
                              - - - -
                              diff --git a/addons/note/note_view.xml b/addons/note/note_view.xml index 789a112b868..19eff9bc250 100644 --- a/addons/note/note_view.xml +++ b/addons/note/note_view.xml @@ -50,7 +50,6 @@ - @@ -119,9 +118,6 @@
                              - - -
                              diff --git a/addons/procurement/procurement_view.xml b/addons/procurement/procurement_view.xml index 64b10bd2bbf..bf73b383216 100644 --- a/addons/procurement/procurement_view.xml +++ b/addons/procurement/procurement_view.xml @@ -103,11 +103,7 @@
                              - - - -
                              diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml index d175ea391d5..c08bbc412e3 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -203,11 +203,7 @@
                              - - - -
                              diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index fa639f46c6d..93d01a5619b 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -152,11 +152,7 @@
                              - - - -
                              @@ -482,11 +478,7 @@
                              - - - -
                              diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index f9e04e7420e..8d54520261f 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -161,11 +161,7 @@
                              - - - -
                              diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 69042a2fa1a..759c0561631 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -285,11 +285,7 @@
                              - - - -
                              diff --git a/addons/purchase_requisition/purchase_requisition_view.xml b/addons/purchase_requisition/purchase_requisition_view.xml index cba22f384ca..80bdd9aa95b 100644 --- a/addons/purchase_requisition/purchase_requisition_view.xml +++ b/addons/purchase_requisition/purchase_requisition_view.xml @@ -103,9 +103,6 @@
                              - - -
                              diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 54fdcb8c140..5c2320a7d5c 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -351,11 +351,7 @@
                              - - - -
                              diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 2f2dc3a2d8a..83fed186f42 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -917,11 +917,7 @@
                              - - - -
                              @@ -1047,11 +1043,7 @@
                              - - - -
                              From ac7adf29d2e59a9dc31e4c59b0969b448bb5742e Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Mon, 24 Sep 2012 12:11:08 +0200 Subject: [PATCH 149/175] [IMP] mail_follower: unfollow when no subtypes following bzr revid: chm@openerp.com-20120924101108-iyhv21w0zkvzb4jb --- addons/mail/static/src/js/mail_followers.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index a3ba6f91a04..85bd4c37987 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -85,7 +85,6 @@ openerp_mail_followers = function(session, mail) { }, set_value: function(value_) { - console.log("set_value", value_); this.reinit(); return this.fetch_followers(value_ || this.get_value()); }, @@ -209,8 +208,11 @@ openerp_mail_followers = function(session, mail) { if($(record).is(':checked')) { checklist.push(parseInt($(record).data('id')))} }); - - return this.ds_model.call('message_subscribe_users',[[self.view.datarecord.id], undefined, checklist, context]).pipe(this.proxy('read_value')); + + if(!checklist.length) + return this.do_unfollow(); + else + return this.ds_model.call('message_subscribe_users',[[self.view.datarecord.id], undefined, checklist, context]).pipe(this.proxy('read_value')); }, }); From 4525190e726a3f9fadeade2fba40c41a69a4bb72 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 25 Sep 2012 10:58:09 +0200 Subject: [PATCH 150/175] [IMP] mail: auto display subtypes on subscription (web) bzr revid: chm@openerp.com-20120925085809-u8f7tvtbdxnftbu4 --- addons/mail/mail_thread.py | 36 +++++++++++++++++---- addons/mail/static/src/js/mail_followers.js | 30 ++++++++++------- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 71d4bfd099b..665ca664994 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -625,10 +625,17 @@ class mail_thread(osv.AbstractModel): ``(name,content)``, where content is NOT base64 encoded :return: ID of newly created mail.message """ + # message_post + # [26] False notification mt_crm_stage False + + # message_post + # [26] False notification mt_crm_won False + context = context or {} attachments = attachments or [] assert (not thread_id) or isinstance(thread_id, (int, long)) or \ (isinstance(thread_id, (list, tuple)) and len(thread_id) == 1), "Invalid thread_id" + if isinstance(thread_id, (list, tuple)): thread_id = thread_id and thread_id[0] @@ -652,9 +659,19 @@ class mail_thread(osv.AbstractModel): else: subtype_id = False + + #auto link messages for same id and object + messages = self.pool.get('mail.message') + model = context.get('thread_model', self._name) if thread_id else False + if model != 'res.partner': + message_ids = messages.search(cr, uid, ['&',('res_id', '=', thread_id),('model','=',model)], context=context) + if len(message_ids): + parent_id = min(message_ids) + + values = kwargs values.update({ - 'model': context.get('thread_model', self._name) if thread_id else False, + 'model': model, 'res_id': thread_id or False, 'body': body, 'subject': subject, @@ -666,12 +683,22 @@ class mail_thread(osv.AbstractModel): # Avoid warnings about non-existing fields for x in ('from', 'to', 'cc'): values.pop(x, None) - return self.pool.get('mail.message').create(cr, uid, values, context=context) + + print "------------------------------------------" + print values, "mail_thread 688" + print "--------≃============----------------------------------" + + return messages.create(cr, uid, values, context=context) #------------------------------------------------------ # Followers API #------------------------------------------------------ + def get_message_subtypes(self, cr, uid, ids, context=None): + """ message_subtype_data: data about document subtypes: which are + available, which are followed if any """ + return self._get_subscription_data(cr, uid, ids, None, None, context=context) + def message_subscribe_users(self, cr, uid, ids, user_ids=None, subtype_ids=None, context=None): """ Wrapper on message_subscribe, using users. If user_ids is not provided, subscribe uid instead. """ @@ -680,11 +707,6 @@ class mail_thread(osv.AbstractModel): partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)] return self.message_subscribe(cr, uid, ids, partner_ids, subtype_ids=subtype_ids, context=context) - def get_message_subtypes(self, cr, uid, ids, context=None): - """ message_subtype_data: data about document subtypes: which are - available, which are followed if any """ - return self._get_subscription_data(cr, uid, ids, None, None, context=context) - def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None): """ Add partners to the records followers. """ self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 85bd4c37987..4ceb936c623 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -51,11 +51,11 @@ openerp_mail_followers = function(session, mail) { bind_events: function() { var self = this; - this.$el.find('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); self.clear_subtypes(); }) + this.$el.find('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); }) .mouseover(function () { $(this).removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover').find('p').html('Unfollow');}) .mouseleave(function () { $(this).removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout').find('p').html('Following'); }); - this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); self.clear_subtypes(); }); + this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); }); this.$el.on('click', 'ul.oe_mail_subtypes input', function () {self.do_update_subscription(); }) this.$el.on('click', 'button.oe_mail_button_invite', function(event) { action = { @@ -101,9 +101,9 @@ openerp_mail_followers = function(session, mail) { return false; }, - fetch_followers: function (value_, message_is_follower) { - this.value = value_; - this.message_is_follower = message_is_follower || (this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value()); + fetch_followers: function (value_) { + this.value = value_ || {}; + this.message_is_follower = (this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value()); return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers'), this.proxy('display_generic')); }, @@ -163,7 +163,7 @@ openerp_mail_followers = function(session, mail) { }, /** Display subtypes: {'name': default, followed} */ - display_subtypes: function () { + display_subtypes: function (visible) { var self = this; var recthread_subtypes = self.$el.find('.oe_mail_recthread_subtypes'); subtype_list_ul = self.$el.find('ul.oe_mail_subtypes'); @@ -180,21 +180,27 @@ openerp_mail_followers = function(session, mail) { } }, - clear_subtypes: function(){ - this.$el.find('ul.oe_mail_subtypes').empty(); - this.hidden_subtypes(); - }, - hidden_subtypes: function (){ this.$el.find('.oe_mail_recthread_subtypes').hide(); }, do_follow: function () { + var self =this; + _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ + $(record).attr('checked','checked'); + }); var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, undefined, context]).pipe(this.proxy('read_value')); + return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, undefined, context]).pipe(function(value_){ + self.read_value(value_); + if(!self.$el.find('.oe_mail_recthread_subtypes').is(":visible")) + self.display_subtypes(true); + }); }, do_unfollow: function () { + _(this.$el.find('.oe_msg_subtype_check')).each(function(record){ + $(record).attr('checked',false); + }); var context = new session.web.CompoundContext(this.build_context(), {}); return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value')); }, From bf3cb4bcd6de46ec86b9bb335008a3722e817276 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 25 Sep 2012 11:12:36 +0200 Subject: [PATCH 151/175] [FIX] mail: rpc with not false value bzr revid: chm@openerp.com-20120925091236-l9ywccbyjsoa31ph --- addons/mail/static/src/js/mail_followers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 4ceb936c623..5836bd94ba1 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -104,7 +104,8 @@ openerp_mail_followers = function(session, mail) { fetch_followers: function (value_) { this.value = value_ || {}; this.message_is_follower = (this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value()); - return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers'), this.proxy('display_generic')); + if(value_) + return this.ds_follow.call('read', [this.value, ['name', 'user_ids']]).pipe(this.proxy('display_followers'), this.proxy('display_generic')); }, /* Display generic info about follower, for people not having access to res_partner */ From 4ddb50dbf920a02bbb6f1c210a1215abd8a0b428 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 26 Sep 2012 09:17:09 +0200 Subject: [PATCH 152/175] [IMP] mail: subtype adapted for css onhover box bzr revid: chm@openerp.com-20120926071709-v51ra4mzn2hp121j --- addons/mail/mail_message.py | 2 + addons/mail/mail_thread.py | 15 ++-- addons/mail/static/src/css/mail.css | 44 ++++++--- addons/mail/static/src/js/mail.js | 90 +++++++++++++------ addons/mail/static/src/js/mail_followers.js | 89 +++++++++--------- addons/mail/static/src/xml/mail.xml | 13 +-- addons/mail/static/src/xml/mail_followers.xml | 16 ++-- 7 files changed, 165 insertions(+), 104 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index fc830a3c214..08834686088 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -201,6 +201,7 @@ class mail_message(osv.Model): partner_ids = self.pool.get('res.partner').name_get(cr, uid, [x.id for x in msg.partner_ids], context=context) except (orm.except_orm, osv.except_osv): partner_ids = [] + return { 'id': msg.id, 'type': msg.type, @@ -216,6 +217,7 @@ class mail_message(osv.Model): 'partner_ids': partner_ids, 'child_ids': [], 'child_nbr': child_nbr, + 'parent_id': msg.parent_id and msg.parent_id.id or False, 'vote_user_ids': vote_ids, 'has_voted': has_voted } diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 665ca664994..f004dd9a900 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -625,11 +625,6 @@ class mail_thread(osv.AbstractModel): ``(name,content)``, where content is NOT base64 encoded :return: ID of newly created mail.message """ - # message_post - # [26] False notification mt_crm_stage False - - # message_post - # [26] False notification mt_crm_won False context = context or {} attachments = attachments or [] @@ -653,6 +648,7 @@ class mail_thread(osv.AbstractModel): } attachment_ids.append((0, 0, data_attach)) + # get subtype if subtype: ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', subtype) subtype_id = ref and ref[1] or False @@ -684,11 +680,10 @@ class mail_thread(osv.AbstractModel): for x in ('from', 'to', 'cc'): values.pop(x, None) - print "------------------------------------------" - print values, "mail_thread 688" - print "--------≃============----------------------------------" - - return messages.create(cr, uid, values, context=context) + added_message_id = messages.create(cr, uid, values, context=context) + added_message = self.pool.get('mail.message').message_read(cr, uid, [added_message_id]) + + return added_message #------------------------------------------------------ # Followers API diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 3fde4cbc67b..497e5940791 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -50,14 +50,6 @@ .openerp div.oe_mail_recthread_aside input { cursor:pointer; } -.openerp div.oe_mail_recthread_subtypes { - display:none; -} -.openerp div.oe_mail_recthread_aside button span { - position: absolute; - top:-7px; - right:5px; -} /* Specific display of threads in the wall */ /* ------------------------------------------------------------ */ @@ -108,7 +100,7 @@ width: 120px; } -.openerp button.oe_mail_button_mouseout { +.openerp .oe_mail_recthread_aside .oe_follower.oe_follow { color: white; background-color: #8a89ba; background-image: -webkit-gradient(linear, left top, left bottom, from(#8a89ba), to(#807fb4)); @@ -118,9 +110,7 @@ background-image: -o-linear-gradient(top, #8a89ba, #807fb4); background-image: linear-gradient(to bottom, #8a89ba, #807fb4); } - -.openerp button.oe_mail_button_mouseover { - display: none; +.openerp .oe_mail_recthread_aside .oe_follower.oe_following { color: white; background-color: #dc5f59; background-image: -webkit-gradient(linear, left top, left bottom, from(#dc5f59), to(#b33630)); @@ -131,10 +121,40 @@ background-image: linear-gradient(to bottom, #dc5f59, #b33630); } + +.openerp .oe_mail_recthread_aside .oe_follower span { + display:none; +} +.openerp .oe_mail_recthread_aside .oe_following span.oe_following, +.openerp .oe_mail_recthread_aside .oe_notfollow span.oe_follow { + display:block; +} + .openerp div.oe_mail_recthread_followers { margin-bottom: 8px; } + +/* ------------------------------------------------------------ */ +/* subtypes +/* ------------------------------------------------------------ */ + +.openerp .oe_mouse_subtypes { + display:inline-block; + position: relative; + z-index: 5; +} +.openerp .oe_mouse_subtypes .oe_recthread_subtypes { + position: absolute; + z-index: 2; +} +.openerp .oe_mouse_subtypes.oe_mouseout .oe_recthread_subtypes { + display: none; +} +.openerp .oe_mouse_subtypes.oe_mouseover .oe_recthread_subtypes { + display: block; +} + /* ------------------------------------------------------------ */ /* Thread /* ------------------------------------------------------------ */ diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 8adba39507c..f4ae9018df1 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -110,8 +110,8 @@ openerp.mail = function(session) { this._super.apply(this, arguments); // customize display: add avatar, clean previous content var user_avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid); - this.$el.find('img.oe_mail_icon').attr('src', user_avatar); - this.$el.find('div.oe_mail_msg_content').empty(); + this.$('img.oe_mail_icon').attr('src', user_avatar); + this.$('div.oe_mail_msg_content').empty(); // create a context for the dataset and default_get of the wizard var context = _.extend({}, this.options.context); this.ds_compose = new session.web.DataSetSearch(this, 'mail.compose.message', context); @@ -139,21 +139,21 @@ openerp.mail = function(session) { disable_autofocus: true, }); // add the form, bind events, activate the form - var msg_node = this.$el.find('div.oe_mail_msg_content'); + var msg_node = this.$('div.oe_mail_msg_content'); return $.when(this.form_view.appendTo(msg_node)).pipe(this.proxy('postprocess_create_form_view')); }, postprocess_create_form_view: function () { // handle attachment button this.fileupload_id = _.uniqueId('oe_fileupload'); - var button_attach = this.$el.find('button.oe_mail_compose_message_attachment'); + var button_attach = this.$('button.oe_mail_compose_message_attachment'); var rendered = session.web.qweb.render('mail.compose_message.add_attachment', {'widget': this}); $(rendered).insertBefore(button_attach); // move the button inside div.oe_hidden_input_file - var input_node = this.$el.find('input[name=ufile]'); + var input_node = this.$('input[name=ufile]'); button_attach.detach().insertAfter(input_node); // set the function called when attachments are added - this.$el.find('input.oe_form_binary_file').change(this.on_attachment_change); + this.$('input.oe_form_binary_file').change(this.on_attachment_change); this.bind_events(); this.form_view.do_show(); }, @@ -161,7 +161,7 @@ openerp.mail = function(session) { on_attachment_change: function (event) { var $target = $(event.target); if ($target.val() !== '') { - this.$el.find('form.oe_form_binary_form').submit(); + this.$('form.oe_form_binary_form').submit(); session.web.blockUI(); } }, @@ -178,11 +178,11 @@ openerp.mail = function(session) { }, display_attachments: function () { - var attach_node = this.$el.find('div.oe_mail_compose_message_attachments'); + var attach_node = this.$('div.oe_mail_compose_message_attachments'); var rendered = session.web.qweb.render('mail.thread.message.attachments', {'record': this}); attach_node.empty(); $(rendered).appendTo(attach_node); - this.$el.find('.oe_mail_msg_attachments').show(); + this.$('.oe_mail_msg_attachments').show(); var composer_attachment_ids = _.pluck(this.attachment_ids, 'id'); var onchange_like = {'value': {'attachment_ids': composer_attachment_ids}} this.form_view.on_processed_onchange(onchange_like, []); @@ -283,6 +283,7 @@ openerp.mail = function(session) { show_dd_delete: options.show_dd_delete || false, show_dd_hide: options.show_dd_hide || false, truncate_limit: options.truncate_limit || 250, + mail_wall: options.mail_wall || this } // datasets and internal vars this.records = {}; @@ -309,7 +310,7 @@ openerp.mail = function(session) { * - show_header_compose: show the composition form in the header */ do_customize_display: function() { if (this.options.show_header_compose) { - this.$el.find('div.oe_mail_thread_action').eq(0).show(); + this.$('div.oe_mail_thread_action').eq(0).show(); } }, @@ -321,7 +322,7 @@ openerp.mail = function(session) { // event: click on 'More' at bottom of thread this.$el.on('click', 'a.oe_mail_fetch_more', this.do_message_fetch_more); // event: writing in basic textarea of composition form (quick reply) - this.$el.find('textarea.oe_mail_compose_textarea').keyup(function (event) { + this.$('textarea.oe_mail_compose_textarea').keyup(function (event) { var charCode = (event.which) ? event.which : window.event.keyCode; if (event.shiftKey && charCode == 13) { this.value = this.value+"\n"; } else if (charCode == 13) { return self.message_post(); } @@ -405,7 +406,7 @@ openerp.mail = function(session) { this.compose_message_widget = new mail.ComposeMessage(this, { 'context': _.extend(context || {}, this.context), }); - var composition_node = this.$el.find('div.oe_mail_thread_action'); + var composition_node = this.$('div.oe_mail_thread_action'); composition_node.empty(); var compose_done = this.compose_message_widget.appendTo(composition_node); return compose_done; @@ -418,7 +419,7 @@ openerp.mail = function(session) { /** Clean the thread */ message_clean: function() { - this.$el.find('div.oe_mail_thread_display').empty(); + this.$('div.oe_mail_thread_display').empty(); }, /** Fetch messages @@ -467,9 +468,10 @@ openerp.mail = function(session) { 'show_reply': self.options.show_reply && self.options.thread_level > 1, 'show_reply_by_email': self.options.show_reply_by_email, 'show_dd_hide': self.options.show_dd_hide, - 'show_dd_delete': self.options.show_dd_delete }); - self.$el.find('li.oe_mail_thread_msg:last').append('
                              '); - self.thread.appendTo(self.$el.find('div.oe_mail_thread_subthread:last')); + 'show_dd_delete': self.options.show_dd_delete, + 'mail_wall': self.options.mail_wall }); + self.$('li.oe_mail_thread_msg:last').append('
                              '); + self.thread.appendTo(self.$('div.oe_mail_thread_subthread:last')); } }); }, @@ -497,7 +499,7 @@ openerp.mail = function(session) { // render, add the expand feature var rendered = session.web.qweb.render('mail.thread.message', {'record': record, 'thread': this, 'options': this.options}); $(rendered).appendTo(this.$el.children('div.oe_mail_thread_display:first')); - this.$el.find('div.oe_mail_msg_body').expander({ + this.$('div.oe_mail_msg_body').expander({ slicePoint: this.options.truncate_limit, expandText: 'read more', userCollapseText: '[^]', @@ -526,19 +528,41 @@ openerp.mail = function(session) { display_user_avatar: function () { var avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid); - return this.$el.find('img.oe_mail_icon').attr('src', avatar); + return this.$('img.oe_mail_icon').attr('src', avatar); }, + /* Display the message if if the msg_id don't exists. + * If the record have a parent, insert parent or inside parent */ + message_fetch_new_data: function(records) { + var self=this; + + _(records).each(function (record) { + if( !self.options.mail_wall.$('.oe_mail_thread_msg[data-msg_id="'+record.id+'"]').size() ) { + self.display_record( record ); + } + }); + }, + + search_thread: function() { + + }, + + animated_destroy: function(animated) { + //graphic effects + this.destroy(); + }, + + /*post a message and flatch the message*/ message_post: function (body) { var self = this; if (! body) { - var comment_node = this.$el.find('textarea'); + var comment_node = this.$('textarea'); var body = comment_node.val(); comment_node.val(''); } return this.ds_thread.call('message_post', [ - [this.context.default_res_id], body, false, 'comment', this.context.default_parent_id, undefined] - ).pipe(self.message_clean()).pipe(self.message_fetch(false)); + [this.context.default_res_id], body, false, 'comment', false, this.context.default_parent_id, undefined]) + .then(this.proxy('message_fetch_new_data')); }, /** Action: 'shows more' to fetch new messages */ @@ -585,7 +609,7 @@ openerp.mail = function(session) { var self = this; this._super.apply(this, arguments); if (! this.view.datarecord.id || session.web.BufferedDataSet.virtual_id_regex.test(this.view.datarecord.id)) { - this.$el.find('oe_mail_thread').hide(); + this.$('oe_mail_thread').hide(); return; } // update context @@ -597,14 +621,14 @@ openerp.mail = function(session) { // create and render Thread widget var show_header_compose = this.view.is_action_enabled('edit') || (this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value()); - this.$el.find('div.oe_mail_recthread_main').empty(); + this.$('div.oe_mail_recthread_main').empty(); var thread = new mail.Thread(self, domain, this.options.context, { 'thread_level': this.options.thread_level, 'show_header_compose': show_header_compose, 'use_composer': show_header_compose, 'show_dd_delete': true, 'show_reply_by_email': show_header_compose }); - return thread.appendTo(this.$el.find('div.oe_mail_recthread_main')); + return thread.appendTo(this.$('div.oe_mail_recthread_main')); }, }); @@ -656,7 +680,7 @@ openerp.mail = function(session) { load_searchview: function (defaults, hidden) { var self = this; this.searchview = new session.web.SearchView(this, this.ds_msg, false, defaults || {}, hidden || false); - return this.searchview.appendTo(this.$el.find('.oe_view_manager_view_search')).then(function () { + return this.searchview.appendTo(this.$('.oe_view_manager_view_search')).then(function () { self.searchview.on_search.add(self.do_searchview_search); }); }, @@ -681,21 +705,29 @@ openerp.mail = function(session) { return self.message_render(); }); }, + + search_thread: function(id) { + var self=this; + + /*this.thread*/ + }, /** Clean and display the threads */ message_render: function () { - this.$el.find('ul.oe_mail_wall_threads').empty(); + this.$('ul.oe_mail_wall_threads').empty(); var domain = this.options.domain.concat(this.search_results['domain']); var render_res = session.web.qweb.render('mail.wall_thread_container', {}); - $(render_res).appendTo(this.$el.find('ul.oe_mail_wall_threads')); - var thread = new mail.Thread(this, domain, this.options.context, + $(render_res).appendTo(this.$('ul.oe_mail_wall_threads')); + + this.thread = new mail.Thread(this, domain, this.options.context, { 'thread_level': this.options.thread_level, 'use_composer': true, 'show_reply': this.options.thread_level > 0, 'show_dd_hide': true, + 'mail_wall': self } ); - return thread.appendTo(this.$el.find('li.oe_mail_wall_thread:last')); + return this.thread.appendTo(this.$('li.oe_mail_wall_thread:last')); }, }); }; diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 5836bd94ba1..47bf9f74223 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -51,13 +51,33 @@ openerp_mail_followers = function(session, mail) { bind_events: function() { var self = this; - this.$el.find('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); }) - .mouseover(function () { $(this).removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover').find('p').html('Unfollow');}) - .mouseleave(function () { $(this).removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout').find('p').html('Following'); }); + this.$('div.oe_mouse_subtypes') + .on('mouseover', function () { + $(this).removeClass('oe_mouseout').addClass('oe_mouseover'); + self.display_subtypes(); + }) + .on('mouseleave', function () { + $(this).removeClass('oe_mouseover').addClass('oe_mouseout'); + self.display_subtypes(); + }); - this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); }); - this.$el.on('click', 'ul.oe_mail_subtypes input', function () {self.do_update_subscription(); }) - this.$el.on('click', 'button.oe_mail_button_invite', function(event) { + this.$('button.oe_follower') + .on('click', function () { + if($(this).hasClass('oe_notfollow')) + self.do_follow(); + else + self.do_unfollow(); + }) + .on('mouseover', function () { + $(this).removeClass('oe_mouseout').addClass('oe_mouseover'); + }) + .on('mouseleave', function () { + $(this).removeClass('oe_mouseover').addClass('oe_mouseout'); + }); + + this.$el.on('click', 'ul.oe_subtypes input', function () { self.do_update_subscription(); }) + + this.$el.on('click', 'button.oe_invite', function(event) { action = { type: 'ir.actions.act_window', res_model: 'mail.wizard.invite', @@ -72,9 +92,6 @@ openerp_mail_followers = function(session, mail) { } self.do_action(action, function() { self.read_value(); }); }); - - this.$el.find('button span') - .click(function (e) { self.display_subtypes(); e.stopPropagation(); }) }, read_value: function() { @@ -111,7 +128,7 @@ openerp_mail_followers = function(session, mail) { /* Display generic info about follower, for people not having access to res_partner */ display_generic: function (error, event) { event.preventDefault(); - var node_user_list = this.$el.find('ul.oe_mail_followers_display').empty(); + var node_user_list = this.$('ul.oe_mail_followers_display').empty(); // format content: Followers (You and 0 other) // Followers (3) var content = this.options.title; if (this.message_is_follower) { @@ -120,7 +137,7 @@ openerp_mail_followers = function(session, mail) { else { content += ' (' + this.value.length + ')' } - this.$el.find('div.oe_mail_recthread_followers h4').html(content); + this.$('div.oe_mail_recthread_followers h4').html(content); this.display_buttons(); return $.when(); }, @@ -128,29 +145,29 @@ openerp_mail_followers = function(session, mail) { /** Display the followers, evaluate is_follower directly */ display_followers: function (records) { var self = this; - var node_user_list = this.$el.find('ul.oe_mail_followers_display').empty(); - this.$el.find('div.oe_mail_recthread_followers h4').html(this.options.title + ' (' + records.length + ')'); - _(records).each(function (record) { + var node_user_list = this.$('ul.oe_mail_followers_display').empty(); + this.$('div.oe_mail_recthread_followers h4').html(this.options.title + (records.length>=5 ? ' (' + records.length + ')' : '') ); + console.log(records); + for(var i=0; i -