[ADD] add file-email

This commit is contained in:
Sébastien Beau 2013-04-03 17:14:57 +02:00
commit 8de978bb71
3 changed files with 123 additions and 0 deletions

24
__init__.py Normal file
View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# file_email for OpenERP
# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>.
# @author Sébastien BEAU <sebastien.beau@akretion.com>
#
# 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 file_buffer

42
__openerp__.py Normal file
View File

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# file_buffer_from_mail for OpenERP
# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>.
# @author Sébastien BEAU <sebastien.beau@akretion.com>
#
# 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': 'file_buffer_from_mail',
'version': '0.1',
'category': 'Generic Modules/Others',
'license': 'AGPL-3',
'description': """Abstract module for importing and processing the
attachment of an email. The attachment of the email will be imported
as a file_buffer and then in your custom module you can process it.
An example of processing can be found in account_statement_email
""",
'author': 'Akretion',
'website': 'http://www.akretion.com/',
'depends': ['file_buffer'],
'init_xml': [],
'update_xml': [
],
'demo_xml': [],
'installable': True,
'active': False,
}

57
file_buffer.py Normal file
View File

@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# file_email for OpenERP
# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>.
# @author Sébastien BEAU <sebastien.beau@akretion.com>
#
# 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 openerp.osv import fields
from openerp.osv.orm import Model
class file_buffer(Model):
_inherit = "file.buffer"
def _prepare_data_for_file_buffer(self, cr, uid, msg, context=None):
"""Method to prepare the data for creating a file buffer.
:param msg: a dictionnary with the email data
:type: dict
:return: a list of dictionnary that containt the file buffer data
:rtype: list
"""
return []
def message_new(self, cr, uid, msg, custom_values, context=None):
create_ids = []
res = self._get_vals_for_file_buffer(cr, uid, msg, context=context)
if res:
for vals in res:
file_id = self.create(cr, uid, vals, context=context)
self.create_file_buffer_attachment(cr, uid, file_id,
datas, file_name,
context=context,
extension=vals['extension'])
create_ids = file_id
return create_ids
return None