1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as
9
# published by the Free Software Foundation, either version 3 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Affero General Public License for more details.
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
29
from tools.translate import _
32
from osv import fields,osv,orm
33
from osv.orm import except_orm
35
class document_file(osv.osv):
36
_inherit = "ir.attachment"
39
'email_notification_ids':fields.one2many('document.email.notes','document_id','Phase', readonly=True),
42
def msg_new(self, cr, uid, msg):
43
raise Exception(_('Sorry, Not Allowed to create document'))
46
def msg_update(self, cr, uid, id, msg, data={}, default_act='pending'):
47
mailgate_obj = self.pool.get('mail.gateway')
48
msg_actions, body_data = mailgate_obj.msg_act_get(msg)
50
'name' : msg['Subject'],
51
'description' : body_data,
52
'email' : msg['From'],
55
'email_notification_ids': [(0, 0, email_notify_data)],
57
res = self.write(cr, uid, [id], data)
60
def emails_get(self, cr, uid, ids, context={}):
62
if isinstance(ids, (str, int, long)):
66
for document in self.browse(cr, uid, select):
67
user_email = (document.user_id and document.user_id.address_id and document.user_id.address_id.email) or False
68
res += [(user_email, False, False, False)]
69
if isinstance(ids, (str, int, long)):
70
return len(res) and res[0] or False
73
def msg_send(self, cr, uid, id, *args, **argv):
79
class document_email_notes(osv.osv):
80
_name = "document.email.notes"
81
_description = "EMail Conversation Detail"
83
def _note_get(self, cursor, user, ids, name, arg, context=None):
85
for hist in self.browse(cursor, user, ids, context or {}):
86
res[hist.id] = (hist.email or '/') + ' (' + str(hist.create_date) + ')\n'
87
res[hist.id] += (hist.description or '')
91
'name': fields.char("Name", size=64, required=True, select=True),
92
'description': fields.text('Description'),
93
'note': fields.function(_note_get, method=True, string="Description", type="text"),
94
'email': fields.char('Email', size=84),
95
'create_date': fields.datetime('Created Date'),
96
'action': fields.char('Action', size=64),
97
'document_id': fields.many2one('ir.attachment','Document', required=True),
99
document_email_notes()