Browse Source

[IMP] Give users the possibility to view emails

[IMP] Add 'action_needed' flag to mails - default on for new messages received
pull/78/head
Ronald Portier 12 years ago
parent
commit
fc0cd8a45c
  1. 22
      mail_client_view/__init__.py
  2. 48
      mail_client_view/__openerp__.py
  3. 1
      mail_client_view/model/__init__.py
  4. 40
      mail_client_view/model/mail_message.py
  5. 11
      mail_client_view/view/mail_user_menu.xml
  6. 98
      mail_client_view/view/mail_user_view.xml

22
mail_client_view/__init__.py

@ -0,0 +1,22 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2013 Therp BV (<http://therp.nl>)
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import model

48
mail_client_view/__openerp__.py

@ -0,0 +1,48 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2013 Therp BV (<http://therp.nl>)
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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': '',
}

1
mail_client_view/model/__init__.py

@ -0,0 +1 @@
import mail_message

40
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.'
),
}

11
mail_client_view/view/mail_user_menu.xml

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<openerp>
<data>
<menuitem
id="mail_user_menu"
name="Messages"
parent="base.menu_address_book"
action="mail.action_view_mail_message"
sequence="80" />
</data>
</openerp>

98
mail_client_view/view/mail_user_view.xml

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record
id="view_mail_action_needed_search"
model="ir.ui.view">
<field name="name">view_mail_action_needed_search</field>
<field name="model">mail.message</field>
<field
name="inherit_id"
ref="mail.view_email_message_search" />
<field
name="arch"
type="xml">
<data>
<field
name="email_from"
position="before">
<separator orientation="vertical"/>
<filter
icon="terp-check"
name="action"
string="Action needed"
domain="[('action_needed','=',True)]" />
</field>
</data>
</field>
</record>
<record
id="view_mail_action_needed_tree"
model="ir.ui.view">
<field name="name">view_mail_action_needed_tree</field>
<field name="model">mail.message</field>
<field
name="inherit_id"
ref="mail.view_email_message_tree" />
<field
name="arch"
type="xml">
<data>
<field
name="state"
position="after">
<field
name="action_needed"
invisible="True" />
<button
name="set_action_needed_off"
attrs="{'invisible': [('action_needed','=',False)]}"
string="confirm action done"
icon="gtk-no"
type="object" />
<button
name="set_action_needed_on"
attrs="{'invisible': [('action_needed','=',True)]}"
string="set action needed"
icon="gtk-yes"
type="object" />
</field>
</data>
</field>
</record>
<record
id="view_mail_action_needed_form"
model="ir.ui.view">
<field name="name">view_mail_action_needed_form</field>
<field name="model">mail.message</field>
<field
name="inherit_id"
ref="mail.view_email_message_form" />
<field
name="arch"
type="xml">
<data>
<button
name="%(mail.action_email_compose_message_wizard)d"
position="after">
<field
name="action_needed"
invisible="True" />
<button
name="set_action_needed_off"
attrs="{'invisible': [('action_needed','=',False)]}"
string="confirm action done"
icon="gtk-no"
type="object" />
<button
name="set_action_needed_on"
attrs="{'invisible': [('action_needed','=',True)]}"
string="set action needed"
icon="gtk-yes"
type="object" />
</button>
</data>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save