diff --git a/addons/document_change/__init__.py b/addons/document_change/__init__.py index 636a81b4e1b..2cf5916bbfe 100644 --- a/addons/document_change/__init__.py +++ b/addons/document_change/__init__.py @@ -20,5 +20,6 @@ ############################################################################## import document_change +import document_change_mailgate # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document_change/document_change.py b/addons/document_change/document_change.py index 0b248289469..02dcaf11888 100644 --- a/addons/document_change/document_change.py +++ b/addons/document_change/document_change.py @@ -147,8 +147,7 @@ class doucment_change_process(osv.osv): 'state':fields.selection([('draft', 'Draft'),('progress', 'Progress'),('confirmed', 'To Validate'), ('done', 'Done'),('done', 'Done'),('cancel','Cancelled')], 'Status'), 'process_phase_ids':fields.one2many('document.change.process.phase','process_id','Phase'), 'process_document_ids': fields.many2many('ir.attachment','document_changed_process_rel','process_id','change_id','Document To Change'), - 'pending_directory_id' :fields.many2one('document.directory','Pending Directory ID'), - 'email_notification_ids':fields.one2many('document.change.process.mail','process_id','Notifications'), + 'pending_directory_id' :fields.many2one('document.directory','Pending Directory ID'), } _defaults = { 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'document.change.process'), diff --git a/addons/document_change/document_change_mailgate.py b/addons/document_change/document_change_mailgate.py new file mode 100644 index 00000000000..ecc6522004f --- /dev/null +++ b/addons/document_change/document_change_mailgate.py @@ -0,0 +1,99 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 time +import re +import os + +import mx.DateTime +import base64 + +from tools.translate import _ + +import tools +from osv import fields,osv,orm +from osv.orm import except_orm + +class document_file(osv.osv): + _inherit = "ir.attachment" + + _columns = { + 'email_notification_ids':fields.one2many('document.email.notes','document_id','Phase', readonly=True), + } + + def msg_new(self, cr, uid, msg): + raise Exception(_('Sorry, Not Allowed to create document')) + return False + + def msg_update(self, cr, uid, id, msg, data={}, default_act='pending'): + mailgate_obj = self.pool.get('mail.gateway') + msg_actions, body_data = mailgate_obj.msg_act_get(msg) + email_notify_data = { + 'name' : msg['Subject'], + 'description' : body_data, + 'email' : msg['From'], + } + data.update({ + 'email_notification_ids': [(0, 0, email_notify_data)], + }) + res = self.write(cr, uid, [id], data) + return res + + def emails_get(self, cr, uid, ids, context={}): + res = [] + if isinstance(ids, (str, int, long)): + select = [ids] + else: + select = ids + for document in self.browse(cr, uid, select): + user_email = (document.user_id and document.user_id.address_id and document.user_id.address_id.email) or False + res += [(user_email, False, False, False)] + if isinstance(ids, (str, int, long)): + return len(res) and res[0] or False + return res + + def msg_send(self, cr, uid, id, *args, **argv): + return True + +document_file() + + +class document_email_notes(osv.osv): + _name = "document.email.notes" + _description = "EMail Conversation Detail" + + def _note_get(self, cursor, user, ids, name, arg, context=None): + res = {} + for hist in self.browse(cursor, user, ids, context or {}): + res[hist.id] = (hist.email or '/') + ' (' + str(hist.create_date) + ')\n' + res[hist.id] += (hist.description or '') + return res + + _columns = { + 'name': fields.char("Name", size=64, required=True, select=True), + 'description': fields.text('Description'), + 'note': fields.function(_note_get, method=True, string="Description", type="text"), + 'email': fields.char('Email', size=84), + 'create_date': fields.datetime('Created Date'), + 'action': fields.char('Action', size=64), + 'document_id': fields.many2one('ir.attachment','Document', required=True), + } +document_email_notes() diff --git a/addons/document_change/document_change_view.xml b/addons/document_change/document_change_view.xml index 273e0d2a638..6c37c4c981c 100644 --- a/addons/document_change/document_change_view.xml +++ b/addons/document_change/document_change_view.xml @@ -250,6 +250,21 @@ + + + + + + +
+ + + + + + + + @@ -439,19 +454,7 @@ - - - - - - - -
- - - - -
+
@@ -505,4 +508,4 @@ src_model="document.change.process"/> - \ No newline at end of file +