From 8de978bb714bcaf14d8a1b2c7f9039057dd2e26a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Beau?= Date: Wed, 3 Apr 2013 17:14:57 +0200 Subject: [PATCH] [ADD] add file-email --- __init__.py | 24 +++++++++++++++++++++ __openerp__.py | 42 +++++++++++++++++++++++++++++++++++++ file_buffer.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 __init__.py create mode 100644 __openerp__.py create mode 100644 file_buffer.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 00000000..91628407 --- /dev/null +++ b/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# file_email for OpenERP +# Copyright (C) 2012-TODAY Akretion . +# @author Sébastien BEAU +# +# 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 file_buffer + diff --git a/__openerp__.py b/__openerp__.py new file mode 100644 index 00000000..592affad --- /dev/null +++ b/__openerp__.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# file_buffer_from_mail for OpenERP +# Copyright (C) 2012-TODAY Akretion . +# @author Sébastien BEAU +# +# 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 . +# +############################################################################### + +{ + '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, +} diff --git a/file_buffer.py b/file_buffer.py new file mode 100644 index 00000000..8e5fe50e --- /dev/null +++ b/file_buffer.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# file_email for OpenERP +# Copyright (C) 2012-TODAY Akretion . +# @author Sébastien BEAU +# +# 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 . +# +############################################################################### + +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 + + + + + +