[IMP] document_change: connect document with mailgate
bzr revid: hmo@tinyerp.com-20100122124916-x16z5237eg9h1pkj
This commit is contained in:
@@ -20,5 +20,6 @@
|
||||
##############################################################################
|
||||
|
||||
import document_change
|
||||
import document_change_mailgate
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 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()
|
||||
@@ -250,6 +250,21 @@
|
||||
<field name="write_date" readonly="1"/>
|
||||
<field name="write_uid" readonly="1"/>
|
||||
</group>
|
||||
|
||||
<field name="email_notification_ids" colspan="4" mode="tree, form" readonly="1" widget="one2many_list" nolabel="1">
|
||||
<tree string="Notifications">
|
||||
<field name="email"/>
|
||||
<field name="create_date"/>
|
||||
</tree>
|
||||
<form string="Notifications">
|
||||
<field name="email"/>
|
||||
<field name="create_date"/>
|
||||
<field name="name" string="Subject" colspan="4"/>
|
||||
<separator string="Description" colspan="4"/>
|
||||
<field colspan="4" name="description" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -439,19 +454,7 @@
|
||||
<field name="state"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Notifications">
|
||||
<field name="email_notification_ids" mode="tree,form" widget="one2many_list" nolabel="1">
|
||||
<tree string="Notifications" editable="True">
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
</tree>
|
||||
<form string="Notifications">
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
@@ -505,4 +508,4 @@
|
||||
src_model="document.change.process"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user