From e12390e51d6bdb9726edd8b85b52725fd101b6f5 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Wed, 20 Jun 2012 14:15:30 +0530 Subject: [PATCH 01/48] [FIX] har field added misasinf size attribute bzr revid: jam@tinyerp.com-20120620084530-lw93wwc9fsw6g9ja --- addons/mail/mail_alias.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index b5aa6f6d76a..d4097f82de9 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -39,8 +39,8 @@ class mail_alias(osv.Model): _rec_name = 'alias_name' _columns = { - 'alias_name': fields.char('Mailbox Alias', required=True, - help="The name of the mailbox alias, e.g. `jobs' " + 'alias_name': fields.char('Mailbox Alias', size=255, required=True, + help="The name of the mailbox alias, e.g. 'jobs' " "if you want to catch emails for ",), 'alias_model_id': fields.many2one('ir.model', 'Aliased Model', required=True, help="The model (OpenERP Document Kind) to which this alias " @@ -79,4 +79,4 @@ class mail_alias(osv.Model): return - \ No newline at end of file + From c9c059cabceb2e90081899dfd1160a0f3807e453 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 20 Jun 2012 17:06:04 +0530 Subject: [PATCH 02/48] [ADD] added view of mail alias. bzr revid: tpa@tinyerp.com-20120620113604-x8rnaxaq23g9c4yo --- addons/mail/__openerp__.py | 1 + addons/mail/mail_alias_view.xml | 65 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 addons/mail/mail_alias_view.xml diff --git a/addons/mail/__openerp__.py b/addons/mail/__openerp__.py index 39413a80bed..4436e2beb63 100644 --- a/addons/mail/__openerp__.py +++ b/addons/mail/__openerp__.py @@ -67,6 +67,7 @@ The main features are: 'mail_data.xml', 'mail_group_data.xml', 'res_users_view.xml', + 'mail_alias_view.xml', ], 'installable': True, 'auto_install': False, diff --git a/addons/mail/mail_alias_view.xml b/addons/mail/mail_alias_view.xml new file mode 100644 index 00000000000..00e643b3680 --- /dev/null +++ b/addons/mail/mail_alias_view.xml @@ -0,0 +1,65 @@ + + + + + + + mail.alias.form + mail.alias + form + + +
+ + + + + + + + + +
+
+
+ + + + mail.alias.tree + mail.alias + tree + + + + + + + + + + + + + mail.alias.search + mail.alias + search + + + + + + + + + + Alias + mail.alias + form + tree,form + + + + + +
+
\ No newline at end of file From 4d1a89e006ef3cfa2b6b1b518f744857a76f06ed Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 21 Jun 2012 11:44:05 +0530 Subject: [PATCH 03/48] [ADD] added message_catchall method. bzr revid: tpa@tinyerp.com-20120621061405-uofftetkrptjo6mu --- addons/mail/mail_thread.py | 58 +++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 40824ba5427..08eaad8d139 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -447,11 +447,61 @@ class mail_thread(osv.osv): return msgs - def message_catchall(self, cr, uid, message, context=None): - """TODO proper docstring, inspired by messsage_process()""" - # TODO - pass + def _get_user(self, cr, uid, alias, context): + """ + return user_id based on alias + else return id of admin + """ + user_obj = self.pool.get('res.user') + if alias.alias_user_id: + user_id = alias_id.alias_user_id.id + #if user_id not defined in the alias then search related user using name of Email sender + else if: + frm = msg.get('from') + user_ids = user_obj.search(cr, uid, [('name','=',frm)], context) + if user_ids: + user_id = user_obj.browse(cr, uid, user_ids[0], context).id + return user_id or 1 + + def message_catchall(self, cr, uid, message, context=None): + """ + Process incoming mail and call messsage_process using details of the mail.alias model + else raise Exception so that mailgate script will reject the mail and + send notification mail sender that this mailbox does not exist so your mail have been rejected. + """ + + alias_obj = self.pool.get('mail.alias') + user_obj = self.pool.get('res.user') + mail_message = self.pool.get('mail.compose.message') + + if isinstance(message, xmlrpclib.Binary): + message = str(message.data) + + # Parse Message + # Warning: message_from_string doesn't always work correctly on unicode, + # we must use utf-8 strings here :-( + 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) + + alias_name = msg.get('to') + alias_ids = mail_alias.search(cr, uid, [('alias_name','=',alias_name)],context) + alias_id = mail_alias.browse(cr, uid, alias_ids[0], context) + #if alias found then call message_process method. + if alias_id: + user_id = self._get_user(self, cr, uid, alias_id, context) + self.message_process(self, cr, user_id, alias_id.alias_model_id.id, message, alias_id.alias_defaults or False , False, False, alias_id.alias_force_thread_id or False, context) + #if alis not found give Exception + else: + _logger.warning("This mailbox does not exist so mail gate will reject this mail.") + frm = user_obj.browse(cr, uid, uid, context).user_email + sub = "Mail Rejection" + msg.get('subject') + message = "Respective mailbox does not exist so your mail have been rejected" + msg + mail_message.send_mail(cr, uid, {'email_from': frm,'email_to': msg.get('from'),'subject': sub, 'body_text': message}, context) + + return True #------------------------------------------------------ # Email specific From f23494f29956c001b8037a84116f082afd6f03d3 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 21 Jun 2012 11:49:40 +0530 Subject: [PATCH 04/48] [IMP] change mnu name to Mail Alias bzr revid: tpa@tinyerp.com-20120621061940-3xqu7mipa1gxym8z --- addons/mail/mail_alias_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/mail_alias_view.xml b/addons/mail/mail_alias_view.xml index 00e643b3680..7b3919d1ba4 100644 --- a/addons/mail/mail_alias_view.xml +++ b/addons/mail/mail_alias_view.xml @@ -59,7 +59,7 @@ - + \ No newline at end of file From f64fa15ec072c06001fdc199f965e35bfca8dd2c Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 21 Jun 2012 11:53:33 +0530 Subject: [PATCH 05/48] [IMP] improved code bzr revid: tpa@tinyerp.com-20120621062333-qv7hblle9l6huch1 --- 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 08eaad8d139..644b52df2db 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -457,7 +457,7 @@ class mail_thread(osv.osv): if alias.alias_user_id: user_id = alias_id.alias_user_id.id #if user_id not defined in the alias then search related user using name of Email sender - else if: + else: frm = msg.get('from') user_ids = user_obj.search(cr, uid, [('name','=',frm)], context) if user_ids: From ca0509b340c89b2e507ee9dbb5b417b6dd3f6f68 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 21 Jun 2012 14:37:14 +0530 Subject: [PATCH 06/48] [IMP] improved code. bzr revid: tpa@tinyerp.com-20120621090714-giqg7gynttquiztn --- addons/mail/mail_thread.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 644b52df2db..76cb942b327 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -449,20 +449,21 @@ class mail_thread(osv.osv): def _get_user(self, cr, uid, alias, context): """ - return user_id based on alias - else return id of admin + param alias: browse record of alias. + return: int user_id. """ user_obj = self.pool.get('res.user') + user_id = 1 if alias.alias_user_id: user_id = alias_id.alias_user_id.id #if user_id not defined in the alias then search related user using name of Email sender else: - frm = msg.get('from') - user_ids = user_obj.search(cr, uid, [('name','=',frm)], context) + from_email = msg.get('from') + user_ids = user_obj.search(cr, uid, [('name','=',from_email)], context) if user_ids: user_id = user_obj.browse(cr, uid, user_ids[0], context).id - return user_id or 1 + return user_id def message_catchall(self, cr, uid, message, context=None): """ @@ -492,14 +493,14 @@ class mail_thread(osv.osv): #if alias found then call message_process method. if alias_id: user_id = self._get_user(self, cr, uid, alias_id, context) - self.message_process(self, cr, user_id, alias_id.alias_model_id.id, message, alias_id.alias_defaults or False , False, False, alias_id.alias_force_thread_id or False, context) + self.message_process(self, cr, user_id, alias_id.alias_model_id.id, message, custom_values = alias_id.alias_defaults or {}, thread_id = alias_id.alias_force_thread_id or {}, context) #if alis not found give Exception else: - _logger.warning("This mailbox does not exist so mail gate will reject this mail.") - frm = user_obj.browse(cr, uid, uid, context).user_email + #_logger.warning("This mailbox does not exist so mail gate will reject this mail.") + from_email = user_obj.browse(cr, uid, uid, context).user_email sub = "Mail Rejection" + msg.get('subject') message = "Respective mailbox does not exist so your mail have been rejected" + msg - mail_message.send_mail(cr, uid, {'email_from': frm,'email_to': msg.get('from'),'subject': sub, 'body_text': message}, context) + mail_message.send_mail(cr, uid, {'email_from': from_email,'email_to': msg.get('from'),'subject': sub, 'body_text': message}, context) return True From 9b352a9477e72656ee753630f60a2ac66938d736 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 21 Jun 2012 14:38:25 +0530 Subject: [PATCH 07/48] [IMP] improved code. bzr revid: tpa@tinyerp.com-20120621090825-zvsdepwmgga1lun0 --- addons/mail/mail_alias_view.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_alias_view.xml b/addons/mail/mail_alias_view.xml index 7b3919d1ba4..a59f4549547 100644 --- a/addons/mail/mail_alias_view.xml +++ b/addons/mail/mail_alias_view.xml @@ -47,19 +47,23 @@ + + + + - Alias + Mail Alias mail.alias form tree,form - + \ No newline at end of file From 9cc7d77b08047ff988a00b4d599afca3aae4bdf8 Mon Sep 17 00:00:00 2001 From: "ajay javiya (OpenERP)" Date: Thu, 21 Jun 2012 16:20:53 +0530 Subject: [PATCH 08/48] [Add]: Add Mail alias wizard bzr revid: aja@tinyerp.com-20120621105053-5dxlbq48yczdl5ca --- addons/mail/__openerp__.py | 2 ++ addons/mail/mail_alias_data.xml | 9 +++++ addons/mail/wizard/__init__.py | 2 +- addons/mail/wizard/update_mail_alias.py | 36 +++++++++++++++++++ .../mail/wizard/update_mail_alias_wizard.xml | 34 ++++++++++++++++++ 5 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 addons/mail/mail_alias_data.xml create mode 100644 addons/mail/wizard/update_mail_alias.py create mode 100644 addons/mail/wizard/update_mail_alias_wizard.xml diff --git a/addons/mail/__openerp__.py b/addons/mail/__openerp__.py index 39413a80bed..4b73994b65d 100644 --- a/addons/mail/__openerp__.py +++ b/addons/mail/__openerp__.py @@ -56,7 +56,9 @@ The main features are: 'depends': ['base', 'base_tools'], 'data': [ 'wizard/mail_compose_message_view.xml', + 'wizard/update_mail_alias_wizard.xml', 'mail_message_view.xml', + 'mail_alias_data.xml', 'mail_subscription_view.xml', 'mail_thread_view.xml', 'mail_group_view.xml', diff --git a/addons/mail/mail_alias_data.xml b/addons/mail/mail_alias_data.xml new file mode 100644 index 00000000000..041c1dd3316 --- /dev/null +++ b/addons/mail/mail_alias_data.xml @@ -0,0 +1,9 @@ + + + + + mail.catchall.domain + openerp.my.openerp.com + + + diff --git a/addons/mail/wizard/__init__.py b/addons/mail/wizard/__init__.py index 88b9581f68e..bf35381fc94 100644 --- a/addons/mail/wizard/__init__.py +++ b/addons/mail/wizard/__init__.py @@ -20,5 +20,5 @@ ############################################################################## import mail_compose_message - +import update_mail_alias # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/wizard/update_mail_alias.py b/addons/mail/wizard/update_mail_alias.py new file mode 100644 index 00000000000..b419050d48c --- /dev/null +++ b/addons/mail/wizard/update_mail_alias.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-Today OpenERP SA () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# +############################################################################## + +from osv import orm +from osv import fields + +class transient_update_maildomain(orm.TransientModel): + + _name = "transient.update.maildomain" + _description = "Update Mail Domain" + _columns = { + 'name' : fields.text('Domain', required=True), + } + def update_domain(self, cr, uid, ids, context=None): + config_parameter_pool = self.pool.get("ir.config_parameter") + for record in self.browse(cr, uid, ids, context): + config_parameter_pool.set_param(cr, uid, "mail.catchall.domain", record.name, context) + return {'type': 'ir.actions.act_window_close'} diff --git a/addons/mail/wizard/update_mail_alias_wizard.xml b/addons/mail/wizard/update_mail_alias_wizard.xml new file mode 100644 index 00000000000..5cc5162556d --- /dev/null +++ b/addons/mail/wizard/update_mail_alias_wizard.xml @@ -0,0 +1,34 @@ + + + + + transient.update.maildomain.form + transient.update.maildomain + form + +
+
+
+ + + + +
+
+
+ + + Configure Mail Domain + transient.update.maildomain + form + form + new + + +
+
From 300d8a160ddcdc6f5a630b2c38eaa78ca1cea373 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 21 Jun 2012 18:46:52 +0530 Subject: [PATCH 09/48] [FIX] optional param context tpa hs missed this bzr revid: jam@tinyerp.com-20120621131652-oxx7qyi4bqcdsin4 --- 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 76cb942b327..72491bf5b97 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -493,7 +493,7 @@ class mail_thread(osv.osv): #if alias found then call message_process method. if alias_id: user_id = self._get_user(self, cr, uid, alias_id, context) - self.message_process(self, cr, user_id, alias_id.alias_model_id.id, message, custom_values = alias_id.alias_defaults or {}, thread_id = alias_id.alias_force_thread_id or {}, context) + self.message_process(self, cr, user_id, alias_id.alias_model_id.id, message, custom_values = alias_id.alias_defaults or {}, thread_id = alias_id.alias_force_thread_id or {}, context=context) #if alis not found give Exception else: #_logger.warning("This mailbox does not exist so mail gate will reject this mail.") From ae8f2af54240238829dd10e884c1d923b03b1301 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 22 Jun 2012 10:55:57 +0530 Subject: [PATCH 10/48] [IMP] added mail alias under depedancy of the mail,group bzr revid: jam@tinyerp.com-20120622052557-xmzgdsk85nyv1668 --- addons/mail/__init__.py | 2 +- addons/mail/mail_group.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/mail/__init__.py b/addons/mail/__init__.py index 4c313338ceb..f06b4536040 100644 --- a/addons/mail/__init__.py +++ b/addons/mail/__init__.py @@ -19,11 +19,11 @@ # ############################################################################## +import mail_alias import mail_message import mail_thread import mail_group import mail_subscription -import mail_alias import res_users import res_partner import report diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index 0a8677d7862..e46865473f6 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -48,7 +48,7 @@ class mail_group(osv.osv): _description = 'Discussion group' _name = 'mail.group' _inherit = ['mail.thread'] - + _inherits = {'mail.alias': 'alias_id'} def action_group_join(self, cr, uid, ids, context={}): return self.message_subscribe(cr, uid, ids, context=context); @@ -129,6 +129,7 @@ class mail_group(osv.osv): 'member_count': fields.function(get_member_ids, type='integer', string='Member count', multi='get_member_ids'), 'is_subscriber': fields.function(get_member_ids, type='boolean', string='Joined', multi='get_member_ids'), 'last_month_msg_nbr': fields.function(get_last_month_msg_nbr, type='integer', string='Messages count for last month'), + 'alias_id': fields.many2one('mail.alias', 'Mail Alias') } _defaults = { @@ -136,3 +137,8 @@ class mail_group(osv.osv): 'responsible_id': (lambda s, cr, uid, ctx: uid), 'photo': _get_default_photo, } + + def create(self, cr, uid, vals, context=None): + model_pool = self.pool.get('ir.model.data') + #TODO find the model id and pass and finish the all mail alias needs + return super( mail_group, self).create(cr, uid, vals, context) From 541ec87069818a8250a153abba4e1be0cb981af6 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 22 Jun 2012 14:38:19 +0530 Subject: [PATCH 11/48] [IMP] Added Mail Alis Impmentation for the Mail Group bzr revid: jam@tinyerp.com-20120622090819-ps514pp2x3w5hm0p --- addons/mail/mail_alias.py | 25 +++++++++++++++---------- addons/mail/mail_alias_view.xml | 2 +- addons/mail/mail_group.py | 6 +++++- addons/mail/mail_group_view.xml | 3 +++ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index d4097f82de9..7243660fea2 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -48,7 +48,9 @@ class mail_alias(osv.Model): "existing record will cause the creation of a new record " "of this model (e.g. a Project Task)", # only allow selecting mail_thread models! - domain="[('field_ids', 'in', 'message_ids')]"), + #TODO kept doamin temporarily in comment, need to redefine domain + #domain="[('field_id', 'in', 'message_ids')]" + ), 'alias_user_id': fields.many2one('res.users', 'Owner', help="The owner of records created upon receiving emails on this alias. " "If this field is kept empty the system will attempt to find the right owner " @@ -66,17 +68,20 @@ class mail_alias(osv.Model): 'alias_defaults': '{}', 'alias_user_id': lambda s,c,u,ctx: u } - _sql_constraint = [ - ('mailbox_uniq', 'unique (alias_name)', 'Unfortunately this mail alias is already used, please choose a unique one') + _sql_constraints = [ + ('mailbox_uniq', 'UNIQUE(alias_name)', 'Unfortunately this mail alias is already used, please choose a unique one') ] - def create_unique_alias(self, cr, uid, values, context=None): - # TODO: call create() with `values` after checking that `alias_name` - # is unique. If not unique, append a sequential number after it until - # a unique one if found. - # E.g if create_unique_alias is called with {'alias_name': 'abc'} - # and 'abc', 'abc1', 'abc2' alias exist, replace alias_name with 'abc3'. - return + def create_unique_alias(self, cr, uid, values, sequence = 1 ,context=None): + config_parameter_pool = self.pool.get("ir.config_parameter") + domain = config_parameter_pool.get_param(cr, uid, "mail.catchall.domain", context=context) + prob_alias = "%s%s@%s"%(values['alias_name'], sequence, domain) + search_alias = self.search(cr, uid, [('alias_name', '=', prob_alias)]) + if search_alias: + values = self.create_unique_alias(cr, uid, values, sequence+1, context) + else: + values.update({'alias_name': prob_alias}) + return values diff --git a/addons/mail/mail_alias_view.xml b/addons/mail/mail_alias_view.xml index ecf0bb49ae1..5e59dfe8e0f 100644 --- a/addons/mail/mail_alias_view.xml +++ b/addons/mail/mail_alias_view.xml @@ -11,7 +11,7 @@
- + diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index e46865473f6..7b6c55f5d83 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -140,5 +140,9 @@ class mail_group(osv.osv): def create(self, cr, uid, vals, context=None): model_pool = self.pool.get('ir.model.data') - #TODO find the model id and pass and finish the all mail alias needs + alias_pool = self.pool.get('mail.alias') + model, res_id = model_pool.get_object_reference( cr, uid, "mail", "model_mail_group") + vals.update({'alias_name': "mailing-list", + 'alias_model_id': res_id}) + name = alias_pool.create_unique_alias(cr, uid, vals, context=context) return super( mail_group, self).create(cr, uid, vals, context) diff --git a/addons/mail/mail_group_view.xml b/addons/mail/mail_group_view.xml index b2b34da8472..3bde23d9ddd 100644 --- a/addons/mail/mail_group_view.xml +++ b/addons/mail/mail_group_view.xml @@ -69,6 +69,9 @@ + + + From 2ef9861edb81726a82615a151e8ed45aa8d8d778 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 22 Jun 2012 14:46:58 +0530 Subject: [PATCH 12/48] [IMP] write force_thread_id for the mail_group bzr revid: jam@tinyerp.com-20120622091658-ysxn55f3w79r0lg5 --- addons/mail/mail_alias.py | 2 -- addons/mail/mail_group.py | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index 7243660fea2..54adfa34b23 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -83,5 +83,3 @@ class mail_alias(osv.Model): values.update({'alias_name': prob_alias}) return values - - diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index 7b6c55f5d83..edd692bdd51 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -142,7 +142,10 @@ class mail_group(osv.osv): model_pool = self.pool.get('ir.model.data') alias_pool = self.pool.get('mail.alias') model, res_id = model_pool.get_object_reference( cr, uid, "mail", "model_mail_group") - vals.update({'alias_name': "mailing-list", + vals.update({'alias_name': "mailing-group", 'alias_model_id': res_id}) name = alias_pool.create_unique_alias(cr, uid, vals, context=context) - return super( mail_group, self).create(cr, uid, vals, context) + res = super( mail_group, self).create(cr, uid, vals, context) + record = self.read(cr, uid, res, context) + alias_pool.write(cr, uid, [record['alias_id']], {"alias_force_thread_id":record['id']}, context) + return res From daef4a7eddd4c7d744cdd8ddbff8c3228a4d5d8b Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 22 Jun 2012 16:20:57 +0530 Subject: [PATCH 13/48] [FIX] Imporved the message_catchall, based intial test on fetchmail service bzr revid: jam@tinyerp.com-20120622105057-juecpgoh8xi5x87e --- addons/mail/mail_thread.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 72491bf5b97..ce6094879c3 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -456,7 +456,7 @@ class mail_thread(osv.osv): user_obj = self.pool.get('res.user') user_id = 1 if alias.alias_user_id: - user_id = alias_id.alias_user_id.id + user_id = alias.alias_user_id.id #if user_id not defined in the alias then search related user using name of Email sender else: from_email = msg.get('from') @@ -472,35 +472,36 @@ class mail_thread(osv.osv): send notification mail sender that this mailbox does not exist so your mail have been rejected. """ - alias_obj = self.pool.get('mail.alias') - user_obj = self.pool.get('res.user') - mail_message = self.pool.get('mail.compose.message') - + alias_pool = self.pool.get('mail.alias') + user_pool = self.pool.get('res.user') + mail_compose_pool = self.pool.get('mail.compose.message') + mail_message_pool = self.pool.get('mail.message') if isinstance(message, xmlrpclib.Binary): message = str(message.data) - # Parse Message # Warning: message_from_string doesn't always work correctly on unicode, # we must use utf-8 strings here :-( 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) - + msg = mail_message_pool.parse_message(msg_txt) alias_name = msg.get('to') - alias_ids = mail_alias.search(cr, uid, [('alias_name','=',alias_name)],context) - alias_id = mail_alias.browse(cr, uid, alias_ids[0], context) + alias_ids = alias_pool.search(cr, uid, [('alias_name','=',alias_name)],context) + alias_id = alias_pool.browse(cr, uid, alias_ids[0], context) #if alias found then call message_process method. if alias_id: - user_id = self._get_user(self, cr, uid, alias_id, context) - self.message_process(self, cr, user_id, alias_id.alias_model_id.id, message, custom_values = alias_id.alias_defaults or {}, thread_id = alias_id.alias_force_thread_id or {}, context=context) - #if alis not found give Exception + user_id = self._get_user( cr, uid, alias_id, context) + self.message_process(cr, user_id, alias_id.alias_model_id.model, message, + custom_values = alias_id.alias_defaults or {}, + thread_id = alias_id.alias_force_thread_id or False, + context=context) + #if mail_alias not found give Exception else: #_logger.warning("This mailbox does not exist so mail gate will reject this mail.") - from_email = user_obj.browse(cr, uid, uid, context).user_email + from_email = user_pool.browse(cr, uid, uid, context).user_email sub = "Mail Rejection" + msg.get('subject') message = "Respective mailbox does not exist so your mail have been rejected" + msg - mail_message.send_mail(cr, uid, {'email_from': from_email,'email_to': msg.get('from'),'subject': sub, 'body_text': message}, context) + mail_compose_pool.send_mail(cr, uid, {'email_from': from_email,'email_to': msg.get('from'),'subject': sub, 'body_text': message}, context) return True From 709c0f11c0f92ca6aae02a962ac16e3c414a3978 Mon Sep 17 00:00:00 2001 From: "ajay javiya (OpenERP)" Date: Mon, 25 Jun 2012 16:47:12 +0530 Subject: [PATCH 14/48] [Add]:Implement mail.alias feature for project module bzr revid: aja@tinyerp.com-20120625111712-q710cd4d4t5cbj7v --- addons/project/project.py | 25 ++++++++++++++++++------- addons/project/project_view.xml | 8 +++++++- addons/project_issue/project_issue.py | 4 ++++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 429672d3269..98718d70075 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -55,7 +55,7 @@ class project_task_type(osv.osv): class project(osv.osv): _name = "project.project" _description = "Project" - _inherits = {'account.analytic.account': "analytic_account_id"} + _inherits = {'account.analytic.account': "analytic_account_id","mail.alias":"alias_id"} _inherit = ['ir.needaction_mixin', 'mail.thread'] def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): @@ -164,6 +164,8 @@ class project(osv.osv): for task in self.pool.get('project.task').browse(cr, uid, task_ids, context): res[task.project_id.id] += 1 return res + def _get_alias_model(self, cr, uid, context=None): + return [('model_project_task', "Tasks")] _columns = { 'complete_name': fields.function(_complete_name, string="Project Name", type='char', size=250), @@ -205,8 +207,9 @@ class project(osv.osv): 'task_count': fields.function(_task_count, type='integer', string="Open Tasks"), 'color': fields.integer('Color Index'), 'company_uom_id': fields.related('company_id', 'project_time_mode_id', type='many2one', relation='product.uom'), + 'alias_id': fields.many2one('mail.alias', 'Mail Alias'), + 'alias_model': fields.selection(_get_alias_model, "Alias Model",select="1"), } - def dummy(self, cr, uid, ids, context): return True @@ -221,6 +224,7 @@ class project(osv.osv): 'sequence': 10, 'type_ids': _get_type_common, 'use_tasks': True, + 'alias_model':'model_project_task', } # TODO: Why not using a SQL contraints ? @@ -482,9 +486,17 @@ def Project(): return self.pool.get('res.users').read(cr, uid, sub_ids, context=context) def create(self, cr, uid, vals, context=None): - obj_id = super(project, self).create(cr, uid, vals, context=context) - self.create_send_note(cr, uid, [obj_id], context=context) - return obj_id + model_pool = self.pool.get('ir.model.data') + alias_pool = self.pool.get('mail.alias') + model, res_id = model_pool.get_object_reference( cr, uid, "project", vals.get('alias_model')) + vals.update({'alias_name':"project", + 'alias_model_id': res_id}) + alias_pool.create_unique_alias(cr, uid, vals, context=context) + res = super( project, self).create(cr, uid, vals, context) + record = self.read(cr, uid, res, context) + alias_pool.write(cr, uid, [record['alias_id']], {"alias_force_thread_id":record['id'],'alias_defaults':res}, context) + self.create_send_note(cr, uid, [res], context=context) + return res 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) @@ -504,8 +516,7 @@ def Project(): 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) - - + class task(base_stage, osv.osv): _name = "project.task" _description = "Task" diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index d9cba469bc4..51b7784f030 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -46,6 +46,9 @@ + + + @@ -204,6 +207,7 @@ +
@@ -228,7 +232,9 @@
Deadline
- +
+ +
Progress
/
diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index ad6e7afdbcc..478ef18fb07 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -581,6 +581,9 @@ project_issue() class project(osv.osv): _inherit = "project.project" + def _get_alias_model(self, cr, uid, context=None): + return [('model_project_task', "Tasks"),("model_project_issue", "Issue")] + def _issue_count(self, cr, uid, ids, field_name, arg, context=None): res = dict.fromkeys(ids, 0) issue_ids = self.pool.get('project.issue').search(cr, uid, [('project_id', 'in', ids)]) @@ -593,6 +596,7 @@ class project(osv.osv): 'reply_to' : fields.char('Reply-To Email Address', size=256), 'use_issues' : fields.boolean('Use Issues', help="Check this field if this project manages issues"), 'issue_count': fields.function(_issue_count, type='integer'), + 'alias_model': fields.selection(_get_alias_model, "Alias Model"), } _defaults = { From 89391773341d67a302feb316f9164b5fef9f74df Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Mon, 25 Jun 2012 17:01:33 +0530 Subject: [PATCH 15/48] [IMP] Hr_recruitment:improved code for mail alias. bzr revid: tpa@tinyerp.com-20120625113133-47zigv9xc4uf7dlv --- addons/hr_recruitment/hr_recruitment.py | 15 +++++++++++++++ addons/hr_recruitment/hr_recruitment_data.xml | 8 ++++++++ addons/hr_recruitment/hr_recruitment_demo.yml | 9 +++++++++ addons/hr_recruitment/hr_recruitment_view.xml | 3 +++ addons/mail/mail_thread.py | 11 ++++++----- 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index c893755c7c0..d07236341dd 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -549,10 +549,25 @@ class hr_applicant(base_stage, osv.Model): class hr_job(osv.osv): _inherit = "hr.job" _name = "hr.job" + _inherits = {'mail.alias': 'alias_id'} _columns = { 'survey_id': fields.many2one('survey', 'Interview Form', help="Choose an interview form for this job position and you will be able to print/answer this interview from all applicants who apply for this job"), + 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True), } + def create(self, cr, uid, vals, context=None): + model_pool = self.pool.get('ir.model.data') + alias_pool = self.pool.get('mail.alias') + res_id = model_pool.get_object( cr, uid, "hr_recruitment", "model_hr_applicant") + vals.update({'alias_name': "job", + 'alias_model_id': res_id.id}) + name = alias_pool.create_unique_alias(cr, uid, vals, context=context) + res = super( hr_job, self).create(cr, uid, vals, context) + record = self.read(cr, uid, res, context) + alias_pool.write(cr, uid, [record['alias_id']], {"alias_defaults": {'job_id': record['id']}}, context) + return res + + def action_print_survey(self, cr, uid, ids, context=None): if context is None: context = {} diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index 13436bef45a..edb769c5314 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -449,5 +449,13 @@ + + + Jobs@openerp.my.openerp.com + + + {} + + diff --git a/addons/hr_recruitment/hr_recruitment_demo.yml b/addons/hr_recruitment/hr_recruitment_demo.yml index 59508b83c28..aeade8b672d 100644 --- a/addons/hr_recruitment/hr_recruitment_demo.yml +++ b/addons/hr_recruitment/hr_recruitment_demo.yml @@ -1,3 +1,12 @@ +- + !record {model: mail.alias, id: alias_id_1, view: False}: + alias_name: 'Developer@openerp.my.openerp.com' + alias_model_id: model_hr_applicant + alias_user_id: base.user_root + alias_defaults: '{}' +- + !record {model: hr.job, id: hr.job_developer, view: False}: + alias_id: alias_id_1 - !record {model: hr.applicant, id: hr_case_salesman0}: date: !eval time.strftime('%Y-%m-01 10:35:50') diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index 63263d78c9d..d53bf922db7 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -352,6 +352,9 @@ attrs="{'invisible':[('survey_id','=',False)]}"/>
+ + + diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index ce6094879c3..7cb1e2bda2f 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -473,7 +473,7 @@ class mail_thread(osv.osv): """ alias_pool = self.pool.get('mail.alias') - user_pool = self.pool.get('res.user') + user_pool = self.pool.get('res.users') mail_compose_pool = self.pool.get('mail.compose.message') mail_message_pool = self.pool.get('mail.message') if isinstance(message, xmlrpclib.Binary): @@ -486,10 +486,11 @@ class mail_thread(osv.osv): msg_txt = email.message_from_string(message) msg = mail_message_pool.parse_message(msg_txt) alias_name = msg.get('to') - alias_ids = alias_pool.search(cr, uid, [('alias_name','=',alias_name)],context) - alias_id = alias_pool.browse(cr, uid, alias_ids[0], context) + alias_ids = alias_pool.search(cr, uid, [('alias_name','=',alias_name)]) + #if alias found then call message_process method. - if alias_id: + if alias_ids: + alias_id = alias_pool.browse(cr, uid, alias_ids[0], context) user_id = self._get_user( cr, uid, alias_id, context) self.message_process(cr, user_id, alias_id.alias_model_id.model, message, custom_values = alias_id.alias_defaults or {}, @@ -500,7 +501,7 @@ class mail_thread(osv.osv): #_logger.warning("This mailbox does not exist so mail gate will reject this mail.") from_email = user_pool.browse(cr, uid, uid, context).user_email sub = "Mail Rejection" + msg.get('subject') - message = "Respective mailbox does not exist so your mail have been rejected" + msg + message = "Respective mailbox does not exist so your mail have been rejected" + msg.get('body') mail_compose_pool.send_mail(cr, uid, {'email_from': from_email,'email_to': msg.get('from'),'subject': sub, 'body_text': message}, context) return True From 052f2ace57e20f06980bc8fadf37b32be1921420 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Tue, 26 Jun 2012 11:39:06 +0530 Subject: [PATCH 16/48] [ADD] mail: aded alias feature for users. bzr revid: tpa@tinyerp.com-20120626060906-wn4sniccnw25e2nz --- addons/mail/__openerp__.py | 3 +++ addons/mail/mail_data.xml | 13 +++++++++++++ addons/mail/mail_demo.xml | 17 +++++++++++++++++ addons/mail/res_users.py | 21 +++++++++++++++++++++ addons/mail/res_users_view.xml | 3 +++ 5 files changed, 57 insertions(+) create mode 100644 addons/mail/mail_demo.xml diff --git a/addons/mail/__openerp__.py b/addons/mail/__openerp__.py index 1a416cfd02c..274e861c5c8 100644 --- a/addons/mail/__openerp__.py +++ b/addons/mail/__openerp__.py @@ -70,6 +70,9 @@ The main features are: 'res_users_view.xml', 'mail_alias_view.xml', ], + 'demo_xml': [ + 'mail_demo.xml', + ], 'installable': True, 'auto_install': False, 'certificate': '001056784984222247309', diff --git a/addons/mail/mail_data.xml b/addons/mail/mail_data.xml index c8e8b1a488e..38e3b6a86cc 100644 --- a/addons/mail/mail_data.xml +++ b/addons/mail/mail_data.xml @@ -12,5 +12,18 @@ + + + admin@openerp.my.openerp.com + + + + {} + + + + + + diff --git a/addons/mail/mail_demo.xml b/addons/mail/mail_demo.xml new file mode 100644 index 00000000000..739c4491a37 --- /dev/null +++ b/addons/mail/mail_demo.xml @@ -0,0 +1,17 @@ + + + + + demo@openerp.my.openerp.com + + + + {} + + + + + + + + \ No newline at end of file diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 2223d9e162a..e9532290ec4 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -29,6 +29,7 @@ class res_users(osv.osv): """ _name = 'res.users' _inherit = ['res.users', 'mail.thread'] + _inherits = {'mail.alias': 'alias_id'} _columns = { 'notification_email_pref': fields.selection([ @@ -38,6 +39,7 @@ class res_users(osv.osv): ('none', 'Never') ], 'Receive Feeds by E-mail', required=True, help="Choose in which case you want to receive an email when you receive new feeds."), + 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True), } _defaults = { @@ -56,8 +58,16 @@ class res_users(osv.osv): return init_res def create(self, cr, uid, data, context=None): + # create default alias same as the login + model_pool = self.pool.get('ir.model.data') + alias_pool = self.pool.get('mail.alias') + res_id = model_pool.get_object( cr, uid, "mail", "model_res_users") + data.update({'alias_name': data.get('login'), + 'alias_model_id': res_id.id}) + name = alias_pool.create_unique_alias(cr, uid, data, context=context) user_id = super(res_users, self).create(cr, uid, data, context=context) user = self.browse(cr, uid, [user_id], context=context)[0] + alias_pool.write(cr, uid, [user.alias_id.id], {"alias_force_thread_id": user.id}, context) # make user follow itself self.message_subscribe(cr, uid, [user_id], [user_id], context=context) # create a welcome message to broadcast @@ -66,7 +76,18 @@ class res_users(osv.osv): # TODO: clean the broadcast feature. As this is not cleany specified, temporarily remove the message broadcasting that is not buggy but not very nice. #self.message_broadcast(cr, uid, [user.id], 'Welcome notification', message, context=context) return user_id + + def write(self, cr, uid, ids, vals, context=None): + result = super(res_users, self).write(cr, uid, ids, vals, context=context) + # if login of user have been changed then change alias of user also. + if vals.get('login'): + alias_id = self.browse(cr, uid, ids[0]).alias_id + domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context) + name = vals.get('login') + '@' + domain + self.pool.get('mail.alias').write(cr, uid, [alias_id.id], {'alias_name': name}, context=context) + return result + def message_load_ids(self, cr, uid, ids, limit=100, offset=0, domain=[], ascent=False, root_ids=[False], context=None): """ Override of message_load_ids User discussion page : diff --git a/addons/mail/res_users_view.xml b/addons/mail/res_users_view.xml index 428f53d092e..9af90efebae 100644 --- a/addons/mail/res_users_view.xml +++ b/addons/mail/res_users_view.xml @@ -31,6 +31,9 @@ + + + From 181a6a1e88680dbe6e4aadb4072f731119149d2e Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 26 Jun 2012 16:45:14 +0530 Subject: [PATCH 17/48] [REN] mail/mail_demo.xml => mail/user_mail_alias_demo.xml bzr revid: jam@tinyerp.com-20120626111514-ucdw9cz8lrxgz2u9 --- addons/mail/{mail_demo.xml => user_mail_alias_demo.xml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename addons/mail/{mail_demo.xml => user_mail_alias_demo.xml} (100%) diff --git a/addons/mail/mail_demo.xml b/addons/mail/user_mail_alias_demo.xml similarity index 100% rename from addons/mail/mail_demo.xml rename to addons/mail/user_mail_alias_demo.xml From d1e5f1d5d640ec685809faaa9bc677f14665b5fe Mon Sep 17 00:00:00 2001 From: "ajay javiya (OpenERP)" Date: Tue, 26 Jun 2012 16:51:09 +0530 Subject: [PATCH 18/48] [Add]: Implement mail.alias feature for crm bzr revid: aja@tinyerp.com-20120626112109-bt72oh4z6m6vuutq --- addons/crm/crm.py | 14 ++++++++++++++ addons/crm/crm_data.xml | 12 ++++++++++++ addons/crm/crm_view.xml | 1 + 3 files changed, 27 insertions(+) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 65af3f9e530..88d70a61935 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -97,6 +97,7 @@ class crm_case_stage(osv.osv): class crm_case_section(osv.osv): """ Model for sales teams. """ _name = "crm.case.section" + _inherits = {'mail.alias': 'alias_id'} _description = "Sales Teams" _order = "complete_name" @@ -120,6 +121,7 @@ class crm_case_section(osv.osv): 'note': fields.text('Description'), 'working_hours': fields.float('Working Hours', digits=(16,2 )), 'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'), + 'alias_id': fields.many2one('mail.alias', 'Mail Alias'), } def _get_stage_common(self, cr, uid, context): @@ -155,6 +157,18 @@ class crm_case_section(osv.osv): name = record['parent_id'][1] + ' / ' + name res.append((record['id'], name)) return res + + def create(self, cr, uid, vals, context=None): + model_pool = self.pool.get('ir.model.data') + alias_pool = self.pool.get('mail.alias') + model, res_id = model_pool.get_object_reference( cr, uid, "crm", "model_crm_lead") + vals.update({'alias_name': "sales", + 'alias_model_id': res_id}) + name = alias_pool.create_unique_alias(cr, uid, vals, context=context) + res = super(crm_case_section, self).create(cr, uid, vals, context) + record = self.read(cr, uid, res, context) + alias_pool.write(cr, uid, [record['alias_id']],{'alias_defaults':{'section_id':res,'type':'lead'}},context) + return res class crm_case_categ(osv.osv): """ Category of Case """ diff --git a/addons/crm/crm_data.xml b/addons/crm/crm_data.xml index bab3e4bca5f..b5d40c55099 100644 --- a/addons/crm/crm_data.xml +++ b/addons/crm/crm_data.xml @@ -17,5 +17,17 @@ Sales Department Sales + + sales@openerp.my.openerp.com + + + {'type':'lead'} + + + info@openerp.my.openerp.com + + + {'type':'lead'} + diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml index 257d1cd93f7..b0db330cca9 100644 --- a/addons/crm/crm_view.xml +++ b/addons/crm/crm_view.xml @@ -76,6 +76,7 @@ + From ed885f2e0169ebca765d2dbd8f33906737cab92b Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 26 Jun 2012 17:59:01 +0530 Subject: [PATCH 19/48] [IMP] Consstance write method for the wrting the unique and nautral mail alias bzr revid: jam@tinyerp.com-20120626122901-bkq4smyhw3yop8nz --- addons/mail/mail_alias.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index 54adfa34b23..bdb52ba1f7e 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -20,6 +20,7 @@ ############################################################################## from openerp.osv import fields, osv +from tools.translate import _ class mail_alias(osv.Model): """A Mail Alias is a mapping of an email address with a given OpenERP Document @@ -82,4 +83,22 @@ class mail_alias(osv.Model): else: values.update({'alias_name': prob_alias}) return values - + def write(self, cr, uid, ids, vals, context=None): + config_parameter_pool = self.pool.get("ir.config_parameter") + #TODO: Do we need to check specail charactor like email address parsing + # Like allowing . and _ only. + if 'alias_name' in vals.keys(): + domain = config_parameter_pool.get_param(cr, uid, "mail.catchall.domain", context=context) + #check the new alias, If only alias then concat the domain + #if we have alias_name with random domain we will concat our domain. + if vals.get('alias_name').count("@") == 0: + print "0" + vals.update({'alias_name': "%s@%s"%(vals.get('alias_name'), domain)}) + elif vals.get('alias_name').count("@") == 1: + print "1" + name = "%s@%s"%(vals.get('alias_name').split("@")[0], domain) + vals.update({'alias_name': name}) + else: + raise osv.except_osv(_("Warning !"), _("Invalid mail alias name.\n It should be e.g. 'alias@domain.com' or only alias name 'alias'.")) + return super(mail_alias, self).write(cr, uid, ids, vals, context=context) + From e6ce5efbbd0a017f9a5e21ec8827aad9d53ee990 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 26 Jun 2012 18:19:52 +0530 Subject: [PATCH 20/48] [FIX] deom and some user values bzr revid: jam@tinyerp.com-20120626124952-dj2t0vasmfhsp9go --- addons/mail/__openerp__.py | 2 +- addons/mail/mail_alias.py | 2 -- addons/mail/user_mail_alias_demo.xml | 2 +- addons/project/project_demo.xml | 5 +++++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/mail/__openerp__.py b/addons/mail/__openerp__.py index 7165b61a2be..5c0afc27ec1 100644 --- a/addons/mail/__openerp__.py +++ b/addons/mail/__openerp__.py @@ -71,7 +71,7 @@ The main features are: 'mail_alias_view.xml', ], 'demo_xml': [ - 'mail_demo.xml', + 'user_mail_alias_demo.xml', ], 'installable': True, 'auto_install': False, diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index bdb52ba1f7e..e466bbffb47 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -92,10 +92,8 @@ class mail_alias(osv.Model): #check the new alias, If only alias then concat the domain #if we have alias_name with random domain we will concat our domain. if vals.get('alias_name').count("@") == 0: - print "0" vals.update({'alias_name': "%s@%s"%(vals.get('alias_name'), domain)}) elif vals.get('alias_name').count("@") == 1: - print "1" name = "%s@%s"%(vals.get('alias_name').split("@")[0], domain) vals.update({'alias_name': name}) else: diff --git a/addons/mail/user_mail_alias_demo.xml b/addons/mail/user_mail_alias_demo.xml index 739c4491a37..30e8a76d0ae 100644 --- a/addons/mail/user_mail_alias_demo.xml +++ b/addons/mail/user_mail_alias_demo.xml @@ -14,4 +14,4 @@ - \ No newline at end of file + diff --git a/addons/project/project_demo.xml b/addons/project/project_demo.xml index f685f14c85b..5a276378df1 100644 --- a/addons/project/project_demo.xml +++ b/addons/project/project_demo.xml @@ -66,6 +66,7 @@ ref('base.user_vad')])]" name="members"/> Integrate a Sale and Warehouse Management. + model_project_task @@ -291,6 +292,7 @@ + model_project_task 1 @@ -300,6 +302,7 @@ + model_project_task 20 @@ -308,6 +311,7 @@ + model_project_task 30 @@ -315,6 +319,7 @@ Install, data import, configuration + model_project_task From e5f1acb7066f81a38f104010a67fea09ef06a53b Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Wed, 27 Jun 2012 10:10:23 +0530 Subject: [PATCH 21/48] [FIX] relation constrains bzr revid: jam@tinyerp.com-20120627044023-kp3ue8n7peabjxa1 --- addons/mail/mail_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index edd692bdd51..9da83dd12d3 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -129,7 +129,7 @@ class mail_group(osv.osv): 'member_count': fields.function(get_member_ids, type='integer', string='Member count', multi='get_member_ids'), 'is_subscriber': fields.function(get_member_ids, type='boolean', string='Joined', multi='get_member_ids'), 'last_month_msg_nbr': fields.function(get_last_month_msg_nbr, type='integer', string='Messages count for last month'), - 'alias_id': fields.many2one('mail.alias', 'Mail Alias') + 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True) } _defaults = { From 6ca3ad145fdadf96802b2fb37b18bbff28f4277a Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 27 Jun 2012 11:21:18 +0530 Subject: [PATCH 22/48] [IMP] hr_recruitment:added alias for all demo jobs. bzr revid: tpa@tinyerp.com-20120627055118-0im2u2gp3c6fsypz --- addons/hr_recruitment/hr_recruitment_demo.yml | 93 ++++++++++++++++++- 1 file changed, 90 insertions(+), 3 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment_demo.yml b/addons/hr_recruitment/hr_recruitment_demo.yml index aeade8b672d..fd59c775882 100644 --- a/addons/hr_recruitment/hr_recruitment_demo.yml +++ b/addons/hr_recruitment/hr_recruitment_demo.yml @@ -1,12 +1,99 @@ - - !record {model: mail.alias, id: alias_id_1, view: False}: - alias_name: 'Developer@openerp.my.openerp.com' + !record {model: mail.alias, id: alias_job_devloper, view: False}: + alias_name: 'developer@openerp.my.openerp.com' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' +- + !python {model: mail.alias}: | + self.write(cr, uid, [ref('alias_job_devloper')], {"alias_defaults": {'job_id': ref('hr.job_developer')}}) - !record {model: hr.job, id: hr.job_developer, view: False}: - alias_id: alias_id_1 + alias_id: alias_job_devloper +- + !record {model: mail.alias, id: alias_job_ceo, view: False}: + alias_name: 'ceo@openerp.my.openerp.com' + alias_model_id: model_hr_applicant + alias_user_id: base.user_root + alias_defaults: '{}' +- + !python {model: mail.alias}: | + self.write(cr, uid, [ref('alias_job_ceo')], {'alias_defaults': {'job_id': ref('hr.job_ceo')}}) +- + !record {model: hr.job, id: hr.job_ceo, view: False}: + alias_id: alias_job_ceo +- + !record {model: mail.alias, id: alias_job_cto, view: False}: + alias_name: 'cto@openerp.my.openerp.com' + alias_model_id: model_hr_applicant + alias_user_id: base.user_root + alias_defaults: '{}' +- + !python {model: mail.alias}: | + self.write(cr, uid, [ref('alias_job_cto')], {"alias_defaults": {'job_id': ref('hr.job_cto')}}) +- + !record {model: hr.job, id: hr.job_cto, view: False}: + alias_id: alias_job_cto +- + !record {model: mail.alias, id: alias_job_hr_manager, view: False}: + alias_name: 'hr-manager@openerp.my.openerp.com' + alias_model_id: model_hr_applicant + alias_user_id: base.user_root + alias_defaults: '{}' +- + !python {model: mail.alias}: | + self.write(cr, uid, [ref('alias_job_hr_manager')], {"alias_defaults": {'job_id': ref('hr.job_hr_manager')}}) +- + !record {model: hr.job, id: hr.job_hr_manager, view: False}: + alias_id: alias_job_hr_manager +- + !record {model: mail.alias, id: alias_job_consultant, view: False}: + alias_name: 'consultant@openerp.my.openerp.com' + alias_model_id: model_hr_applicant + alias_user_id: base.user_root + alias_defaults: '{}' +- + !python {model: mail.alias}: | + self.write(cr, uid, [ref('alias_job_consultant')], {"alias_defaults": {'job_id': ref('hr.job_consultant')}}) +- + !record {model: hr.job, id: hr.job_consultant, view: False}: + alias_id: alias_job_consultant +- + !record {model: mail.alias, id: alias_job_hrm, view: False}: + alias_name: 'hrm@openerp.my.openerp.com' + alias_model_id: model_hr_applicant + alias_user_id: base.user_root + alias_defaults: '{}' +- + !python {model: mail.alias}: | + self.write(cr, uid, [ref('alias_job_hrm')], {"alias_defaults": {'job_id': ref('hr.job_hrm')}}) +- + !record {model: hr.job, id: hr.job_hrm, view: False}: + alias_id: alias_job_hrm +- + !record {model: mail.alias, id: alias_job_marketing, view: False}: + alias_name: 'marketing@openerp.my.openerp.com' + alias_model_id: model_hr_applicant + alias_user_id: base.user_root + alias_defaults: '{}' +- + !python {model: mail.alias}: | + self.write(cr, uid, [ref('alias_job_marketing')], {"alias_defaults": {'job_id': ref('hr.job_marketing')}}) +- + !record {model: hr.job, id: hr.job_marketing, view: False}: + alias_id: alias_job_marketing +- + !record {model: mail.alias, id: alias_job_trainee, view: False}: + alias_name: 'trainee@openerp.my.openerp.com' + alias_model_id: model_hr_applicant + alias_user_id: base.user_root + alias_defaults: '{}' +- + !python {model: mail.alias}: | + self.write(cr, uid, [ref('alias_job_trainee')], {"alias_defaults": {'job_id': ref('hr.job_trainee')}}) +- + !record {model: hr.job, id: hr.job_trainee, view: False}: + alias_id: alias_job_trainee - !record {model: hr.applicant, id: hr_case_salesman0}: date: !eval time.strftime('%Y-%m-01 10:35:50') From 003e0aa54692e8235170ad042677865730c1f957 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Wed, 27 Jun 2012 11:29:28 +0530 Subject: [PATCH 23/48] [IMP] Mail alias seqence toggeling bzr revid: jam@tinyerp.com-20120627055928-leq7u98rpqk93q97 --- addons/mail/mail_alias.py | 18 +++++++++++------- addons/mail/res_users.py | 15 +++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index e466bbffb47..04282b40e8b 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -73,16 +73,20 @@ class mail_alias(osv.Model): ('mailbox_uniq', 'UNIQUE(alias_name)', 'Unfortunately this mail alias is already used, please choose a unique one') ] - def create_unique_alias(self, cr, uid, values, sequence = 1 ,context=None): + def create_unique_alias(self, cr, uid, values, sequence=1 ,context=None): config_parameter_pool = self.pool.get("ir.config_parameter") domain = config_parameter_pool.get_param(cr, uid, "mail.catchall.domain", context=context) - prob_alias = "%s%s@%s"%(values['alias_name'], sequence, domain) - search_alias = self.search(cr, uid, [('alias_name', '=', prob_alias)]) - if search_alias: - values = self.create_unique_alias(cr, uid, values, sequence+1, context) + if sequence: + prob_alias = "%s%s@%s"%(values['alias_name'], sequence, domain) + search_alias = self.search(cr, uid, [('alias_name', '=', prob_alias)]) + if search_alias: + values = self.create_unique_alias(cr, uid, values, sequence+1, context) + else: + values.update({'alias_name': prob_alias}) + return values else: - values.update({'alias_name': prob_alias}) - return values + return values.update({'alias_name': "%s@%s"%(values['alias_name'],domain)}) + def write(self, cr, uid, ids, vals, context=None): config_parameter_pool = self.pool.get("ir.config_parameter") #TODO: Do we need to check specail charactor like email address parsing diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index e9532290ec4..358d50b2edc 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -64,7 +64,7 @@ class res_users(osv.osv): res_id = model_pool.get_object( cr, uid, "mail", "model_res_users") data.update({'alias_name': data.get('login'), 'alias_model_id': res_id.id}) - name = alias_pool.create_unique_alias(cr, uid, data, context=context) + name = alias_pool.create_unique_alias(cr, uid, data, sequence=False ,context=context) user_id = super(res_users, self).create(cr, uid, data, context=context) user = self.browse(cr, uid, [user_id], context=context)[0] alias_pool.write(cr, uid, [user.alias_id.id], {"alias_force_thread_id": user.id}, context) @@ -78,14 +78,13 @@ class res_users(osv.osv): return user_id def write(self, cr, uid, ids, vals, context=None): - result = super(res_users, self).write(cr, uid, ids, vals, context=context) # if login of user have been changed then change alias of user also. - if vals.get('login'): - alias_id = self.browse(cr, uid, ids[0]).alias_id - domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context) - name = vals.get('login') + '@' + domain - self.pool.get('mail.alias').write(cr, uid, [alias_id.id], {'alias_name': name}, context=context) - return result + if 'login' in vals.keys(): + for user in self.browse(cr, uid, ids, context=context): + domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context) + name = "%s@%s"%(vals['login'], domain) + self.pool.get('mail.alias').write(cr, uid, [user.alias_id.id], {'alias_name': name}, context=context) + return super(res_users, self).write(cr, uid, ids, vals, context=context) def message_load_ids(self, cr, uid, ids, limit=100, offset=0, domain=[], ascent=False, root_ids=[False], context=None): From b8a5dc28d0d8a2844a9e6b53126176c6be8cfbe0 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Wed, 27 Jun 2012 11:54:12 +0530 Subject: [PATCH 24/48] [FIX] Coding imp bzr revid: jam@tinyerp.com-20120627062412-482k3z8frrwvf80c --- addons/crm/crm.py | 4 ++-- addons/hr_recruitment/hr_recruitment.py | 4 ++-- addons/mail/mail_group.py | 2 +- addons/mail/res_users.py | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 88d70a61935..cd514081a0a 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -164,10 +164,10 @@ class crm_case_section(osv.osv): model, res_id = model_pool.get_object_reference( cr, uid, "crm", "model_crm_lead") vals.update({'alias_name': "sales", 'alias_model_id': res_id}) - name = alias_pool.create_unique_alias(cr, uid, vals, context=context) + alias_pool.create_unique_alias(cr, uid, vals, context=context) res = super(crm_case_section, self).create(cr, uid, vals, context) record = self.read(cr, uid, res, context) - alias_pool.write(cr, uid, [record['alias_id']],{'alias_defaults':{'section_id':res,'type':'lead'}},context) + alias_pool.write(cr, uid, [record['alias_id']],{'alias_defaults':{ 'section_id': res, 'type': 'lead'}}, context) return res class crm_case_categ(osv.osv): diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index d07236341dd..844264043b5 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -561,10 +561,10 @@ class hr_job(osv.osv): res_id = model_pool.get_object( cr, uid, "hr_recruitment", "model_hr_applicant") vals.update({'alias_name': "job", 'alias_model_id': res_id.id}) - name = alias_pool.create_unique_alias(cr, uid, vals, context=context) + alias_pool.create_unique_alias(cr, uid, vals, context=context) res = super( hr_job, self).create(cr, uid, vals, context) record = self.read(cr, uid, res, context) - alias_pool.write(cr, uid, [record['alias_id']], {"alias_defaults": {'job_id': record['id']}}, context) + alias_pool.write(cr, uid, [record['alias_id']], {"alias_defaults": {'job_id': res}}, context) return res diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index 9da83dd12d3..1b147ca9525 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -144,7 +144,7 @@ class mail_group(osv.osv): model, res_id = model_pool.get_object_reference( cr, uid, "mail", "model_mail_group") vals.update({'alias_name': "mailing-group", 'alias_model_id': res_id}) - name = alias_pool.create_unique_alias(cr, uid, vals, context=context) + alias_pool.create_unique_alias(cr, uid, vals, context=context) res = super( mail_group, self).create(cr, uid, vals, context) record = self.read(cr, uid, res, context) alias_pool.write(cr, uid, [record['alias_id']], {"alias_force_thread_id":record['id']}, context) diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 358d50b2edc..c769e3eff04 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -64,10 +64,10 @@ class res_users(osv.osv): res_id = model_pool.get_object( cr, uid, "mail", "model_res_users") data.update({'alias_name': data.get('login'), 'alias_model_id': res_id.id}) - name = alias_pool.create_unique_alias(cr, uid, data, sequence=False ,context=context) + alias_pool.create_unique_alias(cr, uid, data, sequence=False ,context=context) user_id = super(res_users, self).create(cr, uid, data, context=context) - user = self.browse(cr, uid, [user_id], context=context)[0] - alias_pool.write(cr, uid, [user.alias_id.id], {"alias_force_thread_id": user.id}, context) + user = self.read(cr, uid, user_id, context=context) + alias_pool.write(cr, uid, [user['alias_id']], {"alias_force_thread_id": user_id}, context) # make user follow itself self.message_subscribe(cr, uid, [user_id], [user_id], context=context) # create a welcome message to broadcast From 2ca7cac3c2f675acf4e415cb133e468693a161e8 Mon Sep 17 00:00:00 2001 From: "ajay javiya (OpenERP)" Date: Wed, 27 Jun 2012 14:05:52 +0530 Subject: [PATCH 25/48] [IMP]:Improve mail.alias in crm module bzr revid: aja@tinyerp.com-20120627083552-xfbrng224lvtudv6 --- addons/crm/crm.py | 20 +++++++++++--------- addons/crm/crm_data.xml | 14 +++++--------- addons/crm/crm_demo.xml | 9 ++++++++- addons/crm/crm_view.xml | 2 +- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 88d70a61935..48057f719f9 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -121,7 +121,7 @@ class crm_case_section(osv.osv): 'note': fields.text('Description'), 'working_hours': fields.float('Working Hours', digits=(16,2 )), 'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'), - 'alias_id': fields.many2one('mail.alias', 'Mail Alias'), + 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True), } def _get_stage_common(self, cr, uid, context): @@ -161,14 +161,16 @@ class crm_case_section(osv.osv): def create(self, cr, uid, vals, context=None): model_pool = self.pool.get('ir.model.data') alias_pool = self.pool.get('mail.alias') - model, res_id = model_pool.get_object_reference( cr, uid, "crm", "model_crm_lead") - vals.update({'alias_name': "sales", - 'alias_model_id': res_id}) - name = alias_pool.create_unique_alias(cr, uid, vals, context=context) - res = super(crm_case_section, self).create(cr, uid, vals, context) - record = self.read(cr, uid, res, context) - alias_pool.write(cr, uid, [record['alias_id']],{'alias_defaults':{'section_id':res,'type':'lead'}},context) - return res + if not vals.get('alias_id'): + model, res_id = model_pool.get_object_reference( cr, uid, "crm", "model_crm_lead") + vals.update({'alias_name': "sales", + 'alias_model_id': res_id}) + alias_pool.create_unique_alias(cr, uid, vals, context=context) + res = super(crm_case_section, self).create(cr, uid, vals, context) + record = self.read(cr, uid, res, context) + alias_pool.write(cr, uid, [record['alias_id']],{'alias_defaults':{'section_id':res,'type':'lead'}},context) + return res + return super(crm_case_section, self).create(cr, uid, vals, context) class crm_case_categ(osv.osv): """ Category of Case """ diff --git a/addons/crm/crm_data.xml b/addons/crm/crm_data.xml index b5d40c55099..396d8c39c6e 100644 --- a/addons/crm/crm_data.xml +++ b/addons/crm/crm_data.xml @@ -13,21 +13,17 @@ e-mail - - Sales Department - Sales - sales@openerp.my.openerp.com {'type':'lead'} - - info@openerp.my.openerp.com - - - {'type':'lead'} + + + Sales Department + Sales + diff --git a/addons/crm/crm_demo.xml b/addons/crm/crm_demo.xml index f345d86d030..1e5d837f818 100644 --- a/addons/crm/crm_demo.xml +++ b/addons/crm/crm_demo.xml @@ -12,10 +12,18 @@ + + info@openerp.my.openerp.com + + + {'type':'lead'} + + Sales Marketing Department Sales Marketing + @@ -23,6 +31,5 @@ True - diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml index b0db330cca9..d0e1ff72344 100644 --- a/addons/crm/crm_view.xml +++ b/addons/crm/crm_view.xml @@ -76,7 +76,7 @@ - + From 486b3e8ec1da61d3c65dfa780e749ac11d79bc61 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 27 Jun 2012 15:39:31 +0530 Subject: [PATCH 26/48] [IMP] remove alias_id field from view when catchall domain is not set. bzr revid: tpa@tinyerp.com-20120627100931-3cug0k2cvd2fe0qy --- addons/crm/crm.py | 14 +++++++++++++- addons/crm/crm_view.xml | 2 +- addons/hr_recruitment/hr_recruitment.py | 12 ++++++++++++ addons/mail/mail_alias_view.xml | 2 +- addons/mail/mail_group.py | 12 ++++++++++++ addons/mail/res_users.py | 12 ++++++++++++ addons/project/project.py | 17 ++++++++++++++++- 7 files changed, 67 insertions(+), 4 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 88d70a61935..ba2f59dbe8d 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -121,7 +121,7 @@ class crm_case_section(osv.osv): 'note': fields.text('Description'), 'working_hours': fields.float('Working Hours', digits=(16,2 )), 'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'), - 'alias_id': fields.many2one('mail.alias', 'Mail Alias'), + 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True), } def _get_stage_common(self, cr, uid, context): @@ -158,6 +158,18 @@ class crm_case_section(osv.osv): res.append((record['id'], name)) return res + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + res = super(crm_case_section,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) + if view_type == 'form': + domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context) + if not domain: + doc = etree.XML(res['arch']) + alias_node = doc.xpath("//field[@name='alias_id']")[0] + parent = alias_node.getparent() + parent.remove(alias_node) + res['arch'] = etree.tostring(doc) + return res + def create(self, cr, uid, vals, context=None): model_pool = self.pool.get('ir.model.data') alias_pool = self.pool.get('mail.alias') diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml index b0db330cca9..d0e1ff72344 100644 --- a/addons/crm/crm_view.xml +++ b/addons/crm/crm_view.xml @@ -76,7 +76,7 @@ - + diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index d07236341dd..960f24f50b5 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -555,6 +555,18 @@ class hr_job(osv.osv): 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True), } + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + res = super(hr_job,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) + if view_type == 'form': + domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context) + if not domain: + doc = etree.XML(res['arch']) + alias_node = doc.xpath("//field[@name='alias_id']")[0] + parent = alias_node.getparent() + parent.remove(alias_node) + res['arch'] = etree.tostring(doc) + return res + def create(self, cr, uid, vals, context=None): model_pool = self.pool.get('ir.model.data') alias_pool = self.pool.get('mail.alias') diff --git a/addons/mail/mail_alias_view.xml b/addons/mail/mail_alias_view.xml index 5e59dfe8e0f..c9b130c6a74 100644 --- a/addons/mail/mail_alias_view.xml +++ b/addons/mail/mail_alias_view.xml @@ -13,7 +13,7 @@ - + diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index 9da83dd12d3..fbbdb85d9d1 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -138,6 +138,18 @@ class mail_group(osv.osv): 'photo': _get_default_photo, } + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + res = super(mail_group,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) + if view_type == 'form': + domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context) + if not domain: + doc = etree.XML(res['arch']) + alias_node = doc.xpath("//field[@name='alias_id']")[0] + parent = alias_node.getparent() + parent.remove(alias_node) + res['arch'] = etree.tostring(doc) + return res + def create(self, cr, uid, vals, context=None): model_pool = self.pool.get('ir.model.data') alias_pool = self.pool.get('mail.alias') diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 358d50b2edc..822096816c5 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -57,6 +57,18 @@ class res_users(osv.osv): self.SELF_WRITEABLE_FIELDS.append('notification_email_pref') return init_res + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + res = super(res_users,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) + if view_type == 'form': + domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context) + if not domain: + doc = etree.XML(res['arch']) + alias_node = doc.xpath("//field[@name='alias_id']")[0] + parent = alias_node.getparent() + parent.remove(alias_node) + res['arch'] = etree.tostring(doc) + return res + def create(self, cr, uid, data, context=None): # create default alias same as the login model_pool = self.pool.get('ir.model.data') diff --git a/addons/project/project.py b/addons/project/project.py index b0337a4c88b..a071f527abf 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -217,7 +217,7 @@ class project(osv.osv): 'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'task_count': fields.function(_task_count, type='integer', string="Open Tasks"), 'color': fields.integer('Color Index'), - 'alias_id': fields.many2one('mail.alias', 'Mail Alias'), + 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True), 'alias_model': fields.selection(_get_alias_model, "Alias Model",select="1"), 'privacy_visibility': fields.selection([('public','Public'), ('followers','Followers Only')], 'Privacy / Visibility'), 'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','Pending'),('close','Closed')], 'Status', required=True,), @@ -254,6 +254,21 @@ class project(osv.osv): (_check_dates, 'Error! project start-date must be lower then project end-date.', ['date_start', 'date']) ] + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + res = super(project,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) + if view_type == 'form': + domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context) + if not domain: + doc = etree.XML(res['arch']) + alias_node = doc.xpath("//field[@name='alias_id']")[0] + parent = alias_node.getparent() + parent.remove(alias_node) + model_node = doc.xpath("//field[@name='alias_model']")[0] + parent = model_node.getparent() + parent.remove(model_node) + res['arch'] = etree.tostring(doc) + return res + def set_template(self, cr, uid, ids, context=None): res = self.setActive(cr, uid, ids, value=False, context=context) return res From c39f2c831305fcced7fab4c5d2bd24c45490215e Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 27 Jun 2012 15:50:05 +0530 Subject: [PATCH 27/48] [IMP] improved code. bzr revid: tpa@tinyerp.com-20120627102005-6pfj8ukxya3qkbf6 --- addons/crm/crm.py | 1 + addons/hr_recruitment/hr_recruitment.py | 2 +- addons/mail/mail_group.py | 1 + addons/mail/res_users.py | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index ba2f59dbe8d..957c5124b21 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -21,6 +21,7 @@ import base64 import time +from lxml import etree from osv import fields from osv import osv import tools diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 960f24f50b5..b29b03637b7 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -22,7 +22,7 @@ from base_status.base_stage import base_stage import time from datetime import datetime, timedelta - +from lxml import etree from osv import fields, osv from crm import crm import tools diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index fbbdb85d9d1..97d2c5fcbb3 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -30,6 +30,7 @@ from PIL import Image import StringIO import tools from tools.translate import _ +from lxml import etree class mail_group(osv.osv): """ diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 822096816c5..eaf800b7b53 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -21,6 +21,7 @@ from osv import osv, fields from tools.translate import _ +from lxml import etree class res_users(osv.osv): """ Update of res.users class From 1b4dcb550be821d1204474e1af21432a3a63c624 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 27 Jun 2012 16:38:25 +0530 Subject: [PATCH 28/48] [IMP] project_issue: set model of alias based on selected model of project view. bzr revid: tpa@tinyerp.com-20120627110825-6faxpbfahfut713h --- addons/project_issue/project_issue.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 1020ea8a72f..5ddf104f869 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -608,6 +608,18 @@ class project(osv.osv): _constraints = [ (_check_escalation, 'Error! You cannot assign escalation to the same project!', ['project_escalation_id']) ] + + def write(self, cr, uid, ids, vals, context=None): + # if alias_model have been changed then change alias_model_id of alias also. + if vals.get('alias_model'): + module = 'project' + if vals.get('alias_model') == "model_project_issue": + module = 'project_issue' + model = self.pool.get('ir.model.data').get_object( cr, uid, module, vals.get('alias_model')) + alias_id = self.browse(cr, uid, ids[0], context).alias_id + self.pool.get('mail.alias').write(cr, uid, [alias_id.id], {'alias_model_id': model.id}, context=context) + return super(project, self).write(cr, uid, ids, vals, context=context) + project() class account_analytic_account(osv.osv): From f9b3bdbaedce3c27acf84b4eededccc262f5d556 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 27 Jun 2012 16:59:27 +0530 Subject: [PATCH 29/48] [IMP] project; make model_id required field. bzr revid: tpa@tinyerp.com-20120627112927-eobyl4a2gmz1lbx2 --- addons/project/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/project/project.py b/addons/project/project.py index a071f527abf..6fff66b1bb8 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -218,7 +218,7 @@ class project(osv.osv): 'task_count': fields.function(_task_count, type='integer', string="Open Tasks"), 'color': fields.integer('Color Index'), 'alias_id': fields.many2one('mail.alias', 'Mail Alias', ondelete="cascade", required=True), - 'alias_model': fields.selection(_get_alias_model, "Alias Model",select="1"), + 'alias_model': fields.selection(_get_alias_model, "Alias Model",select="1", required=True), 'privacy_visibility': fields.selection([('public','Public'), ('followers','Followers Only')], 'Privacy / Visibility'), 'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','Pending'),('close','Closed')], 'Status', required=True,), 'followers': fields.function(_get_followers, method=True, fnct_search=_search_followers, From d2637e5c4d92825317392e98525a20fedf9b693e Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Thu, 28 Jun 2012 11:45:21 +0530 Subject: [PATCH 30/48] [IMP] rmeove alias_id field from kanban. bzr revid: tpa@tinyerp.com-20120628061521-ztf6gj5ydnz9gofy --- addons/project/project.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 6fff66b1bb8..d8102bf6837 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -256,16 +256,21 @@ class project(osv.osv): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(project,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) - if view_type == 'form': + if view_type == 'form' or view_type == 'kanban': domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context) if not domain: doc = etree.XML(res['arch']) alias_node = doc.xpath("//field[@name='alias_id']")[0] parent = alias_node.getparent() parent.remove(alias_node) - model_node = doc.xpath("//field[@name='alias_model']")[0] - parent = model_node.getparent() - parent.remove(model_node) + if view_type == "form": + model_node = doc.xpath("//field[@name='alias_model']")[0] + parent = model_node.getparent() + parent.remove(model_node) + else: + model_node = doc.xpath("//field[@name='alias_id']")[0] + parent = model_node.getparent() + parent.remove(model_node) res['arch'] = etree.tostring(doc) return res @@ -518,7 +523,7 @@ def Project(): def create(self, cr, uid, vals, context=None): model_pool = self.pool.get('ir.model.data') alias_pool = self.pool.get('mail.alias') - model, res_id = model_pool.get_object_reference( cr, uid, "project", vals.get('alias_model')) + model, res_id = model_pool.get_object_reference( cr, uid, "project", vals.get('alias_model','model_project_task')) vals.update({'alias_name':"project", 'alias_model_id': res_id}) alias_pool.create_unique_alias(cr, uid, vals, context=context) From 2e67521464858305c6d1253fdc03ceab61e66d35 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 28 Jun 2012 14:09:51 +0530 Subject: [PATCH 31/48] [FIX] imp the crm alias defaile section id bzr revid: jam@tinyerp.com-20120628083951-4rtvovu2d2veod52 --- addons/crm/crm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 78e96a25c06..238029a3f58 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -181,7 +181,7 @@ class crm_case_section(osv.osv): alias_pool.create_unique_alias(cr, uid, vals, context=context) res = super(crm_case_section, self).create(cr, uid, vals, context) record = self.read(cr, uid, res, context) - alias_pool.write(cr, uid, [record['alias_id']],{'alias_defaults':{'section_id':res,'type':'lead'}},context) + alias_pool.write(cr, uid, [record['alias_id']],{'alias_defaults':{'section_id':record['id'],'type':'lead'}},context) return res return super(crm_case_section, self).create(cr, uid, vals, context) From 8dc8821d97ed9d9aa481739b718cc1ddd9506666 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Thu, 28 Jun 2012 17:40:40 +0530 Subject: [PATCH 32/48] [FIX] project do not add force_thread_id bzr revid: jam@tinyerp.com-20120628121040-fkuirdthib3d3jke --- addons/project/project.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 0015b493a5f..aa32fbb16e2 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -529,8 +529,7 @@ def Project(): alias_pool.create_unique_alias(cr, uid, vals, context=context) res = super( project, self).create(cr, uid, vals, context) record = self.read(cr, uid, res, context) - alias_pool.write(cr, uid, [record['alias_id']], {"alias_force_thread_id":record['id'], - 'alias_defaults':{'project_id': res}}, context) + alias_pool.write(cr, uid, [record['alias_id']], {'alias_defaults':{'project_id': record['id']}}, context) self.create_send_note(cr, uid, [res], context=context) return res From f80b4696240af994b242041c39075fdf2b50e5f2 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 29 Jun 2012 10:28:24 +0530 Subject: [PATCH 33/48] [IMP] mail: improved openerp_mailgate.py script which uses message_catchall method. bzr revid: tpa@tinyerp.com-20120629045824-xgo1y5i22gmlhdbk --- .../mail/static/scripts/openerp_mailgate.py | 45 +++---------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/addons/mail/static/scripts/openerp_mailgate.py b/addons/mail/static/scripts/openerp_mailgate.py index 68ae20d35e3..be9cb8f03fa 100755 --- a/addons/mail/static/scripts/openerp_mailgate.py +++ b/addons/mail/static/scripts/openerp_mailgate.py @@ -94,32 +94,21 @@ class RPCProxy(object): return self.rpc.execute(self.dbname, self.user_id, self.passwd, *request, **kwargs) class EmailParser(object): - def __init__(self, uid, password, model, email_default, dbname, host, port): + def __init__(self, uid, password, dbname, host, port): self.rpc = RPCProxy(uid, password, host=host, port=port, dbname=dbname) - try: - self.model_id = int(model) - self.model = str(model) - except: - self.model_id = self.rpc('ir.model', 'search', [('model', '=', model)])[0] - self.model = str(model) - self.email_default = email_default - def parse(self, message, custom_values=None, save_original=None): + def parse(self, message): # pass message as bytes because we don't know its encoding until we parse its headers # and hence can't convert it to utf-8 for transport res_id = self.rpc('mail.thread', - 'message_process', - self.model, - xmlrpclib.Binary(message), - custom_values or {}, - save_original or False) + 'message_catchall', + xmlrpclib.Binary(message)) def configure_parser(): parser = optparse.OptionParser(usage='usage: %prog [options]', version='%prog v1.1') group = optparse.OptionGroup(parser, "Note", - "This program parse a mail from standard input and communicate " - "with the OpenERP server for case management in the CRM module.") + "This program parse a mail from standard input and communicate ") parser.add_option_group(group) parser.add_option("-u", "--user", dest="userid", help="ID of the user in OpenERP", @@ -127,9 +116,6 @@ def configure_parser(): parser.add_option("-p", "--password", dest="password", help="Password of the user in OpenERP", default=config.OPENERP_DEFAULT_PASSWORD) - parser.add_option("-o", "--model", dest="model", - help="Name or ID of crm model", - default="crm.lead") parser.add_option("-m", "--default", dest="default", help="Default eMail in case of any trouble.", default=None) @@ -142,13 +128,6 @@ def configure_parser(): parser.add_option("--port", dest="port", help="Port of the OpenERP Server", default=config.OPENERP_PORT) - parser.add_option("--custom-values", dest="custom_values", - help="Add Custom Values to the object", - default=None) - parser.add_option("-s", dest="save_original", - action="store_true", - help="Attach a copy of original email to the message entry", - default=False) return parser @@ -162,24 +141,12 @@ def main(): email_parser = EmailParser(options.userid, options.password, - options.model, - options.default, dbname=options.dbname, host=options.host, port=options.port) - - msg_txt = sys.stdin.read() - - custom_values = {} try: - custom_values = dict(eval(options.custom_values or {} )) - except: - import traceback - traceback.print_exc() - - try: - email_parser.parse(msg_txt, custom_values, options.save_original or False) + email_parser.parse(msg_txt) except Exception: msg = '\n'.join([ 'parameters', From 76e0385a72462b19d07ee35bcad4cad55d1e6454 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 29 Jun 2012 10:30:01 +0530 Subject: [PATCH 34/48] [IMP] mail: improved code of mail rejection reply. bzr revid: tpa@tinyerp.com-20120629050001-l1fax044kvpydo9y --- addons/mail/mail_thread.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index f60516f5546..b8afc94a3e0 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -529,8 +529,9 @@ class mail_thread(osv.osv): #_logger.warning("This mailbox does not exist so mail gate will reject this mail.") from_email = user_pool.browse(cr, uid, uid, context).user_email sub = "Mail Rejection" + msg.get('subject') - message = "Respective mailbox does not exist so your mail have been rejected" + msg.get('body') - mail_compose_pool.send_mail(cr, uid, {'email_from': from_email,'email_to': msg.get('from'),'subject': sub, 'body_text': message}, context) + message = "Respective mailbox does not exist so your mail have been rejected"+'\n' + msg.get('body') + msg_id = mail_compose_pool.create(cr, uid ,{'email_from': from_email,'email_to': msg.get('from'),'subject': sub, 'body_text': message}) + mail_compose_pool.send_mail(cr, uid, [msg_id], context) return True From bd9e2c9fe1132f2731f3973f55d8dc226e3e18ee Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 29 Jun 2012 10:31:37 +0530 Subject: [PATCH 35/48] [FIX] updated the message bzr revid: jam@tinyerp.com-20120629050137-sy5mfipxhpeooeh4 --- addons/mail/mail_alias.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index 04282b40e8b..bd2425d4d9a 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -101,6 +101,6 @@ class mail_alias(osv.Model): name = "%s@%s"%(vals.get('alias_name').split("@")[0], domain) vals.update({'alias_name': name}) else: - raise osv.except_osv(_("Warning !"), _("Invalid mail alias name.\n It should be e.g. 'alias@domain.com' or only alias name 'alias'.")) + raise osv.except_osv(_("Warning !"), _("Invalid mail alias name.\n It should be e.g. 'alias@mail.domain.com' or only alias name 'alias'.")) return super(mail_alias, self).write(cr, uid, ids, vals, context=context) From 622e613bdbf35ec60aa34be4bd68efae5cbce83f Mon Sep 17 00:00:00 2001 From: "ajay javiya (OpenERP)" Date: Fri, 29 Jun 2012 12:00:37 +0530 Subject: [PATCH 36/48] [IMP]: Improve in mail.alias bzr revid: aja@tinyerp.com-20120629063037-fx2u2g6jmcm13ank --- addons/crm/crm_view.xml | 2 +- addons/hr_recruitment/hr_recruitment_view.xml | 2 +- addons/mail/mail_group_view.xml | 4 ++-- addons/project/project_view.xml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml index d0e1ff72344..5b3a02f0f27 100644 --- a/addons/crm/crm_view.xml +++ b/addons/crm/crm_view.xml @@ -76,7 +76,7 @@ - + diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index 3ab2e320928..56d0da979ee 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -349,7 +349,7 @@ - + diff --git a/addons/mail/mail_group_view.xml b/addons/mail/mail_group_view.xml index 75f5d38c1d8..b0a71335138 100644 --- a/addons/mail/mail_group_view.xml +++ b/addons/mail/mail_group_view.xml @@ -70,12 +70,12 @@
- +
- +
diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index e385d880cd4..7e330cbdfb6 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -55,7 +55,7 @@ - + From 8a351d8ee860701573e7e6f1a2fcdef34b607e55 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 29 Jun 2012 12:50:39 +0530 Subject: [PATCH 37/48] [IMP] crm: improved view and code bzr revid: tpa@tinyerp.com-20120629072039-xqckkz4tzok87fu4 --- addons/crm/crm_demo.xml | 16 +++++++++------- addons/crm/crm_view.xml | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/crm/crm_demo.xml b/addons/crm/crm_demo.xml index 1e5d837f818..3f495099365 100644 --- a/addons/crm/crm_demo.xml +++ b/addons/crm/crm_demo.xml @@ -1,5 +1,14 @@ + + + info@openerp.my.openerp.com + + + {'type':'lead'} + + + @@ -12,13 +21,6 @@ - - info@openerp.my.openerp.com - - - {'type':'lead'} - - Sales Marketing Department Sales Marketing diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml index d0e1ff72344..d79c09034cf 100644 --- a/addons/crm/crm_view.xml +++ b/addons/crm/crm_view.xml @@ -71,12 +71,12 @@ + - From 494acb39555fff2f18a3ff4669a41b68ab97c258 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 29 Jun 2012 14:16:21 +0530 Subject: [PATCH 38/48] [FIX] remove domain do nto store the domian bzr revid: jam@tinyerp.com-20120629084621-bkt7d22ajtyqkb3g --- addons/crm/crm_data.xml | 2 +- addons/crm/crm_demo.xml | 2 +- addons/hr_recruitment/hr_recruitment_data.xml | 2 +- addons/hr_recruitment/hr_recruitment_demo.yml | 16 ++++++------- addons/mail/mail_alias.py | 23 ++----------------- addons/mail/mail_data.xml | 2 +- addons/mail/res_users.py | 4 +--- addons/mail/user_mail_alias_demo.xml | 2 +- 8 files changed, 16 insertions(+), 37 deletions(-) diff --git a/addons/crm/crm_data.xml b/addons/crm/crm_data.xml index f4d4d8bd8b0..9192b52e7b8 100644 --- a/addons/crm/crm_data.xml +++ b/addons/crm/crm_data.xml @@ -14,7 +14,7 @@ email - sales@openerp.my.openerp.com + sales {'type':'lead'} diff --git a/addons/crm/crm_demo.xml b/addons/crm/crm_demo.xml index 1e5d837f818..a5d69534284 100644 --- a/addons/crm/crm_demo.xml +++ b/addons/crm/crm_demo.xml @@ -13,7 +13,7 @@ - info@openerp.my.openerp.com + info {'type':'lead'} diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index edb769c5314..aed3fe1667e 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -451,7 +451,7 @@ - Jobs@openerp.my.openerp.com + Jobs {} diff --git a/addons/hr_recruitment/hr_recruitment_demo.yml b/addons/hr_recruitment/hr_recruitment_demo.yml index fd59c775882..c616e9e7e95 100644 --- a/addons/hr_recruitment/hr_recruitment_demo.yml +++ b/addons/hr_recruitment/hr_recruitment_demo.yml @@ -1,6 +1,6 @@ - !record {model: mail.alias, id: alias_job_devloper, view: False}: - alias_name: 'developer@openerp.my.openerp.com' + alias_name: 'job-developer' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -12,7 +12,7 @@ alias_id: alias_job_devloper - !record {model: mail.alias, id: alias_job_ceo, view: False}: - alias_name: 'ceo@openerp.my.openerp.com' + alias_name: 'job-ceo' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -24,7 +24,7 @@ alias_id: alias_job_ceo - !record {model: mail.alias, id: alias_job_cto, view: False}: - alias_name: 'cto@openerp.my.openerp.com' + alias_name: 'job-cto' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -36,7 +36,7 @@ alias_id: alias_job_cto - !record {model: mail.alias, id: alias_job_hr_manager, view: False}: - alias_name: 'hr-manager@openerp.my.openerp.com' + alias_name: 'job-hr-manager' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -48,7 +48,7 @@ alias_id: alias_job_hr_manager - !record {model: mail.alias, id: alias_job_consultant, view: False}: - alias_name: 'consultant@openerp.my.openerp.com' + alias_name: 'job-consultant' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -60,7 +60,7 @@ alias_id: alias_job_consultant - !record {model: mail.alias, id: alias_job_hrm, view: False}: - alias_name: 'hrm@openerp.my.openerp.com' + alias_name: 'job-hrm' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -72,7 +72,7 @@ alias_id: alias_job_hrm - !record {model: mail.alias, id: alias_job_marketing, view: False}: - alias_name: 'marketing@openerp.my.openerp.com' + alias_name: 'job-marketing' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' @@ -84,7 +84,7 @@ alias_id: alias_job_marketing - !record {model: mail.alias, id: alias_job_trainee, view: False}: - alias_name: 'trainee@openerp.my.openerp.com' + alias_name: 'job-trainees' alias_model_id: model_hr_applicant alias_user_id: base.user_root alias_defaults: '{}' diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index bd2425d4d9a..a7bc82e79d8 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -74,10 +74,8 @@ class mail_alias(osv.Model): ] def create_unique_alias(self, cr, uid, values, sequence=1 ,context=None): - config_parameter_pool = self.pool.get("ir.config_parameter") - domain = config_parameter_pool.get_param(cr, uid, "mail.catchall.domain", context=context) if sequence: - prob_alias = "%s%s@%s"%(values['alias_name'], sequence, domain) + prob_alias = "%s%s"%(values['alias_name'], sequence) search_alias = self.search(cr, uid, [('alias_name', '=', prob_alias)]) if search_alias: values = self.create_unique_alias(cr, uid, values, sequence+1, context) @@ -85,22 +83,5 @@ class mail_alias(osv.Model): values.update({'alias_name': prob_alias}) return values else: - return values.update({'alias_name': "%s@%s"%(values['alias_name'],domain)}) - - def write(self, cr, uid, ids, vals, context=None): - config_parameter_pool = self.pool.get("ir.config_parameter") - #TODO: Do we need to check specail charactor like email address parsing - # Like allowing . and _ only. - if 'alias_name' in vals.keys(): - domain = config_parameter_pool.get_param(cr, uid, "mail.catchall.domain", context=context) - #check the new alias, If only alias then concat the domain - #if we have alias_name with random domain we will concat our domain. - if vals.get('alias_name').count("@") == 0: - vals.update({'alias_name': "%s@%s"%(vals.get('alias_name'), domain)}) - elif vals.get('alias_name').count("@") == 1: - name = "%s@%s"%(vals.get('alias_name').split("@")[0], domain) - vals.update({'alias_name': name}) - else: - raise osv.except_osv(_("Warning !"), _("Invalid mail alias name.\n It should be e.g. 'alias@mail.domain.com' or only alias name 'alias'.")) - return super(mail_alias, self).write(cr, uid, ids, vals, context=context) + return values.update({'alias_name': "%s"%(values['alias_name'])}) diff --git a/addons/mail/mail_data.xml b/addons/mail/mail_data.xml index 38e3b6a86cc..2448b89fcd6 100644 --- a/addons/mail/mail_data.xml +++ b/addons/mail/mail_data.xml @@ -14,7 +14,7 @@ - admin@openerp.my.openerp.com + admin diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 100f73e0c6d..a4f560e86dc 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -94,9 +94,7 @@ class res_users(osv.osv): # if login of user have been changed then change alias of user also. if 'login' in vals.keys(): for user in self.browse(cr, uid, ids, context=context): - domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context) - name = "%s@%s"%(vals['login'], domain) - self.pool.get('mail.alias').write(cr, uid, [user.alias_id.id], {'alias_name': name}, context=context) + self.pool.get('mail.alias').write(cr, uid, [user.alias_id.id], {'alias_name': vals['login']}, context=context) return super(res_users, self).write(cr, uid, ids, vals, context=context) diff --git a/addons/mail/user_mail_alias_demo.xml b/addons/mail/user_mail_alias_demo.xml index 30e8a76d0ae..eea7d521776 100644 --- a/addons/mail/user_mail_alias_demo.xml +++ b/addons/mail/user_mail_alias_demo.xml @@ -2,7 +2,7 @@ - demo@openerp.my.openerp.com + demo From e461bc1b7cf603ff3660a559b311f1b31bec95c5 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 29 Jun 2012 14:18:33 +0530 Subject: [PATCH 39/48] [ADD] added access rigts for mail.alias bzr revid: tpa@tinyerp.com-20120629084833-sjjsvf0wnc7xh1by --- 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 011e8b27dc5..a675c009bdd 100644 --- a/addons/mail/security/ir.model.access.csv +++ b/addons/mail/security/ir.model.access.csv @@ -5,3 +5,4 @@ access_mail_thread,mail.thread,model_mail_thread,base.group_user,1,1,1,0 access_mail_subscription,mail.subscription,model_mail_subscription,,1,1,1,1 access_mail_notification,mail.notification,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,mail.alias,model_mail_alias,base.group_user,1,1,1,0 From 7145a83ffb2a9ce47fd9d34f9cf7d17056d08d43 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 29 Jun 2012 14:36:05 +0530 Subject: [PATCH 40/48] [IMP] Added name_get for the mai alias bzr revid: jam@tinyerp.com-20120629090605-8m77sksz8680tmaw --- addons/mail/mail_alias.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index a7bc82e79d8..064e9e93535 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -72,7 +72,23 @@ class mail_alias(osv.Model): _sql_constraints = [ ('mailbox_uniq', 'UNIQUE(alias_name)', 'Unfortunately this mail alias is already used, please choose a unique one') ] - + + def name_get(self, cr, uid, ids, context=None): + """ + Return the mail alias display alias_name, inclusing the Implicit and dynamic + Email Alias Domain from config. + e.g. `jobs@openerp.my.openerp.com` or `sales@openerp.my.openerp.com` + """ + if context is None: + context = {} + res = [] + config_parameter_pool = self.pool.get("ir.config_parameter") + domain = config_parameter_pool.get_param(cr, uid, "mail.catchall.domain", context=context) + for record in self.read(cr, uid, ids, ['alias_name'], context=context): + domain_alias = "%s@%s"%(record['alias_name'], domain) + res.append((record['id'], domain_alias)) + return res + def create_unique_alias(self, cr, uid, values, sequence=1 ,context=None): if sequence: prob_alias = "%s%s"%(values['alias_name'], sequence) From 09264aadb85e3b2e7b1a5ba8fd630a11218ac6ce Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 29 Jun 2012 14:39:27 +0530 Subject: [PATCH 41/48] [FIX] Check mail alias via email send to and alias bzr revid: jam@tinyerp.com-20120629090927-wnr7veggj05zv2z8 --- addons/mail/mail_thread.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index c6dcc4c3919..7accd3eb869 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -510,7 +510,7 @@ class mail_thread(osv.osv): message = message.encode('utf-8') msg_txt = email.message_from_string(message) msg = mail_message_pool.parse_message(msg_txt) - alias_name = msg.get('to') + alias_name = msg.get('to').split("0")[0] alias_ids = alias_pool.search(cr, uid, [('alias_name','=',alias_name)]) #if alias found then call message_process method. if alias_ids: @@ -522,7 +522,7 @@ class mail_thread(osv.osv): context=context) else: #if Mail box for the intended Mail Alias then give logger warning - _logger.warning("No Mail Alias Foound for the name '%s'"%(alias_name)) + _logger.warning("No Mail Alias Found for the name '%s'."%(alias_name)) #raise return True From f9f4ae0c1acb69736f03eea76c44e13c2086d16f Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 29 Jun 2012 14:52:21 +0530 Subject: [PATCH 42/48] [FIX] Split email with @ bzr revid: jam@tinyerp.com-20120629092221-7pkj4bcl0hurja0f --- 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 7accd3eb869..72993e8ce53 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -510,7 +510,7 @@ class mail_thread(osv.osv): message = message.encode('utf-8') msg_txt = email.message_from_string(message) msg = mail_message_pool.parse_message(msg_txt) - alias_name = msg.get('to').split("0")[0] + alias_name = msg.get('to').split("@")[0] alias_ids = alias_pool.search(cr, uid, [('alias_name','=',alias_name)]) #if alias found then call message_process method. if alias_ids: From 72cfa2e5248361b420c3f578104b64839c57668d Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 29 Jun 2012 15:35:16 +0530 Subject: [PATCH 43/48] [FIX] Usabality and code refector bzr revid: jam@tinyerp.com-20120629100516-tsctb16dm2afjcqu --- addons/mail/mail_alias_view.xml | 3 ++- addons/mail/res_users.py | 1 - addons/mail/wizard/update_mail_alias_wizard.xml | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/mail/mail_alias_view.xml b/addons/mail/mail_alias_view.xml index c9b130c6a74..e72143bdb9a 100644 --- a/addons/mail/mail_alias_view.xml +++ b/addons/mail/mail_alias_view.xml @@ -66,7 +66,8 @@ + sequence="50" + groups="base.group_no_one"/> diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index a4f560e86dc..e9a9d1222b7 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -77,7 +77,6 @@ class res_users(osv.osv): res_id = model_pool.get_object( cr, uid, "mail", "model_res_users") data.update({'alias_name': data.get('login'), 'alias_model_id': res_id.id}) - name = alias_pool.create_unique_alias(cr, uid, data, sequence=False ,context=context) user_id = super(res_users, self).create(cr, uid, data, context=context) user = self.browse(cr, uid, user_id, context=context) alias_pool.write(cr, uid, [user.alias_id.id], {"alias_force_thread_id": user.id}, context) diff --git a/addons/mail/wizard/update_mail_alias_wizard.xml b/addons/mail/wizard/update_mail_alias_wizard.xml index 40ae80ab790..2e23420ea6b 100644 --- a/addons/mail/wizard/update_mail_alias_wizard.xml +++ b/addons/mail/wizard/update_mail_alias_wizard.xml @@ -10,6 +10,8 @@
@@ -30,6 +32,7 @@ + sequence="100" + groups="base.group_no_one"/> From f3db89aa8c98828c81602fd16a74d9c485d6151a Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 29 Jun 2012 15:52:18 +0530 Subject: [PATCH 44/48] [FIX] Script to suppoert message_prcoess and message_catchall bzr revid: jam@tinyerp.com-20120629102218-52ia76s2aablamro --- addons/mail/mail_thread.py | 2 +- .../mail/static/scripts/openerp_mailgate.py | 53 ++++++++++++++++--- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 72993e8ce53..84049c9473d 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -523,7 +523,7 @@ class mail_thread(osv.osv): else: #if Mail box for the intended Mail Alias then give logger warning _logger.warning("No Mail Alias Found for the name '%s'."%(alias_name)) - #raise + raise return True #------------------------------------------------------ diff --git a/addons/mail/static/scripts/openerp_mailgate.py b/addons/mail/static/scripts/openerp_mailgate.py index cb291473107..9d046027b6e 100755 --- a/addons/mail/static/scripts/openerp_mailgate.py +++ b/addons/mail/static/scripts/openerp_mailgate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################## # @@ -94,19 +94,33 @@ class RPCProxy(object): return self.rpc.execute(self.dbname, self.user_id, self.passwd, *request, **kwargs) class EmailParser(object): - def __init__(self, uid, password, dbname, host, port): + def __init__(self, uid, password, dbname, host, port, model=False, email_default=False): self.rpc = RPCProxy(uid, password, host=host, port=port, dbname=dbname) + if model: + try: + self.model_id = int(model) + self.model = str(model) + except: + self.model_id = self.rpc('ir.model', 'search', [('model', '=', model)])[0] + self.model = str(model) + self.email_default = email_default - def parse(self, message): + def parse(self, method, message, custom_values=None, save_original=None): # pass message as bytes because we don't know its encoding until we parse its headers # and hence can't convert it to utf-8 for transport - res_id = self.rpc('mail.thread', 'message_catchall', xmlrpclib.Binary(message)) + res_id = self.rpc('mail.thread', + method, + self.model, + xmlrpclib.Binary(message), + custom_values or {}, + save_original or False) def configure_parser(): parser = optparse.OptionParser(usage='usage: %prog [options]', version='%prog v1.1') group = optparse.OptionGroup(parser, "Note", - "This program parse a mail from standard input and communicate ") + "This program parse a mail from standard input and communicate " + "with the OpenERP server for case management in the CRM module.") parser.add_option_group(group) parser.add_option("-u", "--user", dest="userid", help="ID of the user in OpenERP", @@ -114,6 +128,12 @@ def configure_parser(): parser.add_option("-p", "--password", dest="password", help="Password of the user in OpenERP", default=config.OPENERP_DEFAULT_PASSWORD) + parser.add_option("-o", "--model", dest="model", + help="Name or ID of crm model", + default="crm.lead") + parser.add_option("-m", "--default", dest="default", + help="Default eMail in case of any trouble.", + default=None) parser.add_option("-d", "--dbname", dest="dbname", help="Database name (default: %default)", default=config.OPENERP_DEFAULT_DATABASE) @@ -123,6 +143,13 @@ def configure_parser(): parser.add_option("--port", dest="port", help="Port of the OpenERP Server", default=config.OPENERP_PORT) + parser.add_option("--custom-values", dest="custom_values", + help="Add Custom Values to the object", + default=None) + parser.add_option("-s", dest="save_original", + action="store_true", + help="Attach a copy of original email to the message entry", + default=False) return parser @@ -132,16 +159,26 @@ def main(): """ parser = configure_parser() (options, args) = parser.parse_args() - - + method = "message_process" email_parser = EmailParser(options.userid, options.password, + options.model, + options.default, dbname=options.dbname, host=options.host, port=options.port) msg_txt = sys.stdin.read() + custom_values = {} + if not options.model: + method = "message_catchall" try: - email_parser.parse(msg_txt) + custom_values = dict(eval(options.custom_values or {} )) + except: + import traceback + traceback.print_exc() + + try: + email_parser.parse(msg_txt, custom_values, options.save_original or False) except Exception: msg = '\n'.join([ 'parameters', From 58f095d89df5d7d4294629dbafbae46f07e87ff4 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 29 Jun 2012 16:10:21 +0530 Subject: [PATCH 45/48] [FIX] mailgate script bzr revid: jam@tinyerp.com-20120629104021-bdacv1hwqwnglj7a --- addons/mail/static/scripts/openerp_mailgate.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/addons/mail/static/scripts/openerp_mailgate.py b/addons/mail/static/scripts/openerp_mailgate.py index 9d046027b6e..64dafc56785 100755 --- a/addons/mail/static/scripts/openerp_mailgate.py +++ b/addons/mail/static/scripts/openerp_mailgate.py @@ -1,4 +1,4 @@ -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:#!/usr/bin/env python +#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################## # @@ -157,28 +157,29 @@ def main(): """ Receive the email via the stdin and send it to the OpenERP Server """ + parser = configure_parser() (options, args) = parser.parse_args() method = "message_process" email_parser = EmailParser(options.userid, options.password, - options.model, - options.default, - dbname=options.dbname, - host=options.host, - port=options.port) + options.dbname, + options.host, + options.port, + model=options.model, + email_default= options.default) msg_txt = sys.stdin.read() custom_values = {} if not options.model: method = "message_catchall" try: - custom_values = dict(eval(options.custom_values or {} )) + custom_values = dict(eval(options.custom_values or "{}" )) except: import traceback traceback.print_exc() try: - email_parser.parse(msg_txt, custom_values, options.save_original or False) + email_parser.parse(method, msg_txt, custom_values, options.save_original or False) except Exception: msg = '\n'.join([ 'parameters', From 6c7360f42b426b09434db9b855e920917427fa29 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Fri, 29 Jun 2012 16:12:38 +0530 Subject: [PATCH 46/48] [IMP] mail: improved view to set mail domain from general settings. bzr revid: tpa@tinyerp.com-20120629104238-q4cbs6go5t1vjbqy --- .../mail/wizard/update_mail_alias_wizard.xml | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/addons/mail/wizard/update_mail_alias_wizard.xml b/addons/mail/wizard/update_mail_alias_wizard.xml index 2e23420ea6b..4580266adde 100644 --- a/addons/mail/wizard/update_mail_alias_wizard.xml +++ b/addons/mail/wizard/update_mail_alias_wizard.xml @@ -29,10 +29,22 @@ new
- + > + + + General Settings + base.config.settings + + form + + + +