From fc0cd8a45c154cd3f1ee641f66240981cb55c665 Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Tue, 16 Apr 2013 22:54:16 +0200 Subject: [PATCH 1/2] [IMP] Give users the possibility to view emails [IMP] Add 'action_needed' flag to mails - default on for new messages received --- mail_client_view/__init__.py | 22 ++++++ mail_client_view/__openerp__.py | 48 ++++++++++++ mail_client_view/model/__init__.py | 1 + mail_client_view/model/mail_message.py | 40 ++++++++++ mail_client_view/view/mail_user_menu.xml | 11 +++ mail_client_view/view/mail_user_view.xml | 98 ++++++++++++++++++++++++ 6 files changed, 220 insertions(+) create mode 100644 mail_client_view/__init__.py create mode 100644 mail_client_view/__openerp__.py create mode 100644 mail_client_view/model/__init__.py create mode 100644 mail_client_view/model/mail_message.py create mode 100644 mail_client_view/view/mail_user_menu.xml create mode 100644 mail_client_view/view/mail_user_view.xml diff --git a/mail_client_view/__init__.py b/mail_client_view/__init__.py new file mode 100644 index 000000000..1483b2269 --- /dev/null +++ b/mail_client_view/__init__.py @@ -0,0 +1,22 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2013 Therp BV () +# All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import model diff --git a/mail_client_view/__openerp__.py b/mail_client_view/__openerp__.py new file mode 100644 index 000000000..a9fbdb959 --- /dev/null +++ b/mail_client_view/__openerp__.py @@ -0,0 +1,48 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2013 Therp BV () +# All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'User email access', + 'version': '6.1.r0025', + 'description': ''' + Adds a menu to the customer address book that enables ordinary users to + look at customer or other mail. Also adds an 'action needed' boolean to + mail messages, to quickly select all mails that still have to be acted on. + + The action_needed flag will be shown to users in a tree view as a red + circle, no action needed will be green. In a form users either have the + button 'confirm action done' (if action needed), or the button 'set + action needed. + ''', + 'author': 'Therp BV', + 'website': 'http://www.therp.nl', + 'category': 'Tools', + 'depends': ['mail'], + 'data': [ + 'view/mail_user_menu.xml', + 'view/mail_user_view.xml', + ], + 'js': [], + 'installable': True, + 'active': False, + 'certificate': '', +} diff --git a/mail_client_view/model/__init__.py b/mail_client_view/model/__init__.py new file mode 100644 index 000000000..afbe2318c --- /dev/null +++ b/mail_client_view/model/__init__.py @@ -0,0 +1 @@ +import mail_message diff --git a/mail_client_view/model/mail_message.py b/mail_client_view/model/mail_message.py new file mode 100644 index 000000000..e338ffc84 --- /dev/null +++ b/mail_client_view/model/mail_message.py @@ -0,0 +1,40 @@ +# -*- coding: UTF-8 -*- +''' +Created on 16 apr. 2013 + +@author: Therp BV + +http://www.therp.nl +''' +from openerp.osv import osv +from openerp.osv import fields + + +class mail_message(osv.osv): + '''Extend mail_message with action_needed flag''' + _inherit = 'mail.message' + + def set_action_needed_off(self, cr, user, ids, args): + self.write(cr, user, ids, {'action_needed': False}) + return True + + def set_action_needed_on(self, cr, user, ids, args): + self.write(cr, user, ids, {'action_needed': True, }) + return True + + def create(self, cr, user, vals, context=None): + # Set newly received messages as needing action, unless an + # explicit value for action_needed has been passed. + if ((not 'action_needed' in vals) + and ('state' in vals) + and (vals['state'] == 'received')): + vals['action_needed'] = True + mm_id = super(mail_message, self).create(cr, user, vals, context) + return mm_id + + _columns = { + 'action_needed': fields.boolean('Action needed', + help='Action needed is True whenever a new mail is received, or' + ' when a user flags a message as needing attention.' + ), + } diff --git a/mail_client_view/view/mail_user_menu.xml b/mail_client_view/view/mail_user_menu.xml new file mode 100644 index 000000000..cb00ead02 --- /dev/null +++ b/mail_client_view/view/mail_user_menu.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/mail_client_view/view/mail_user_view.xml b/mail_client_view/view/mail_user_view.xml new file mode 100644 index 000000000..5ede2fe28 --- /dev/null +++ b/mail_client_view/view/mail_user_view.xml @@ -0,0 +1,98 @@ + + + + + view_mail_action_needed_search + mail.message + + + + + + + + + + + + view_mail_action_needed_tree + mail.message + + + + + + + + + + + From ddbfaca3298da3ae66a1fb26fb1d4dc24d03433f Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Wed, 17 Apr 2013 23:57:08 +0200 Subject: [PATCH 2/2] [FIX] - Some changes to make code consistent with 6.1 style. --- mail_client_view/model/mail_message.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mail_client_view/model/mail_message.py b/mail_client_view/model/mail_message.py index e338ffc84..eb5fdd5ba 100644 --- a/mail_client_view/model/mail_message.py +++ b/mail_client_view/model/mail_message.py @@ -6,35 +6,34 @@ Created on 16 apr. 2013 http://www.therp.nl ''' -from openerp.osv import osv +from openerp.osv.orm import Model from openerp.osv import fields -class mail_message(osv.osv): +class mail_message(Model): '''Extend mail_message with action_needed flag''' _inherit = 'mail.message' - def set_action_needed_off(self, cr, user, ids, args): - self.write(cr, user, ids, {'action_needed': False}) + def set_action_needed_off(self, cr, user, ids, context=None): + self.write(cr, user, ids, {'action_needed': False}, context=context) return True - def set_action_needed_on(self, cr, user, ids, args): - self.write(cr, user, ids, {'action_needed': True, }) + def set_action_needed_on(self, cr, user, ids, context=None): + self.write(cr, user, ids, {'action_needed': True}, context=context) return True def create(self, cr, user, vals, context=None): # Set newly received messages as needing action, unless an # explicit value for action_needed has been passed. if ((not 'action_needed' in vals) - and ('state' in vals) - and (vals['state'] == 'received')): + and ('state' in vals) and (vals['state'] == 'received')): vals['action_needed'] = True - mm_id = super(mail_message, self).create(cr, user, vals, context) + mm_id = super(mail_message, self).create( + cr, user, vals, context=context) return mm_id _columns = { 'action_needed': fields.boolean('Action needed', help='Action needed is True whenever a new mail is received, or' - ' when a user flags a message as needing attention.' - ), + ' when a user flags a message as needing attention.'), }