mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-24 09:28:42 -06:00
[ADD] add file-email
This commit is contained in:
commit
8de978bb71
24
__init__.py
Normal file
24
__init__.py
Normal 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
42
__openerp__.py
Normal 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
57
file_buffer.py
Normal 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user