[IMP] mail_gateway: removed wizard to open documents and make button action for that

bzr revid: hmo@tinyerp.com-20101001075412-adm78felx8gch3e3
This commit is contained in:
Harry (OpenERP) 2010-10-01 13:24:12 +05:30
parent c45d00dd4b
commit 179b2393dd
7 changed files with 53 additions and 127 deletions

View File

@ -21,7 +21,6 @@
import mail_gateway
import res_partner
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -31,7 +31,6 @@
'depends': ['base'],
'init_xml': [],
'update_xml': [
'wizard/mail_gateway_document_view.xml',
"mail_gateway_view.xml",
"res_partner_view.xml",
'security/ir.model.access.csv'

View File

@ -179,6 +179,50 @@ class mailgate_message(osv.osv):
'''
Mailgateway Message
'''
def open_document(self, cr, uid, ids, context):
""" To Open Document
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: the ID of messages
@param context: A standard dictionary
"""
action_data = False
if ids:
message_id = ids[0]
mailgate_data = self.browse(cr, uid, message_id)
model = mailgate_data.model
res_id = mailgate_data.res_id
action_pool = self.pool.get('ir.actions.act_window')
action_ids = action_pool.search(cr, uid, [('res_model', '=', model)])
if action_ids:
action_data = action_pool.read(cr, uid, action_ids[0], context=context)
action_data.update({
'res_id': res_id,
'nodestroy': True
})
return action_data
def open_attachment(self, cr, uid, ids, context):
""" To Open attachments
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: the ID of messages
@param context: A standard dictionary
"""
action_data = False
action_pool = self.pool.get('ir.actions.act_window')
action_ids = action_pool.search(cr, uid, [('res_model', '=', 'ir.attachment')])
if action_ids:
action_data = action_pool.read(cr, uid, action_ids[0], context=context)
action_data.update({
'domain': [('res_id','in',ids),('res_model','=',self._name)],
'nodestroy': True
})
return action_data
def truncate_data(self, cr, uid, data, context=None):
data_list = data and data.split('\n') or []
if len(data_list) > 3:
@ -548,4 +592,4 @@ class mailgate_tool(osv.osv_memory):
mailgate_tool()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -24,10 +24,13 @@
</group>
<group col="2" colspan="2">
<separator string="Message Details" colspan="4"/>
<field name="model" readonly="1"/>
<field name="model" readonly="1"/>
<group col="3" colspan="2">
<field name="res_id" readonly="1"/>
<field name="message_id" />
<field name="ref_id" />
<button name="open_document" string="Open Document" type="object" icon="gtk-jump-to"/>
</group>
<field name="message_id" />
<field name="ref_id" />
</group>
<separator string="Description" colspan="4"/>
<field name="description" nolabel="1" colspan="4" />
@ -53,6 +56,8 @@
<field name="user_id" string="Owner"/>
<field name="message_id" string="Message" invisible="1"/>
<field name="partner_id" invisible="1"/>
<button name="open_document" string="Open Document" type="object" icon="gtk-jump-to"/>
<button name="open_attachment" string="Open Attachments" type="object" icon="gtk-jump-to"/>
</tree>
</field>
</record>

View File

@ -1,24 +0,0 @@
# -*- 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 mail_gateway_document
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,59 +0,0 @@
# -*- 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/>.
#
##############################################################################
from osv import fields, osv
class mail_gateway_document(osv.osv_memory):
""" Mail Gateway Document """
_name = "mail.gateway.document"
_description = "Mail Gateway Document"
def open_document(self, cr, uid, ids, context):
""" To Open Document
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param ids: the ID or list of IDs if we want more than one
@param context: A standard dictionary
"""
result = []
document_id = context.get('active_id', False)
mailgate_obj = self.pool.get('mailgate.message')
mailgate_data = mailgate_obj.browse(cr, uid, document_id)
model = mailgate_data.model
res_id = mailgate_data.res_id
view_obj = self.pool.get('ir.ui.view')
view_id = view_obj.search(cr, uid, [('model', '=', model),('type','=','tree')])
return {
'domain' : "[('id','=',%d)]"%(res_id),
'view_mode': 'tree,form',
'view_type': 'form',
'view_id': view_id or False,
'res_model': model,
'res_id': res_id,
'context': context,
'type': 'ir.actions.act_window',
}
mail_gateway_document()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_mail_gateway_document" model="ir.ui.view">
<field name="name">Open Document</field>
<field name="model">mail.gateway.document</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Open Document">
<label string="" colspan="2" />
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="open_document" string="Open Document" type="object" icon="gtk-ok"/>
</form>
</field>
</record>
<record id="action_view_mail_gateway_document" model="ir.actions.act_window">
<field name="name">Open Document</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mail.gateway.document</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<act_window id="action_view_mail_gateway_document_window"
name="Open Document"
res_model="mail.gateway.document"
src_model="mailgate.message"
view_mode="form"
target="new"
view_type="form"
key2="client_action_multi"/>
</data>
</openerp>