diff --git a/attachment_metadata/__openerp__.py b/attachment_metadata/__openerp__.py
index 42319532..232b1f84 100644
--- a/attachment_metadata/__openerp__.py
+++ b/attachment_metadata/__openerp__.py
@@ -32,6 +32,7 @@
""",
'depends': [
'base',
+ 'mail'
],
'data': [
'attachment_view.xml',
diff --git a/attachment_metadata/attachment.py b/attachment_metadata/attachment.py
index b75ff47a..47fc3fea 100644
--- a/attachment_metadata/attachment.py
+++ b/attachment_metadata/attachment.py
@@ -31,6 +31,7 @@ from base64 import b64decode
class IrAttachmentMetadata(models.Model):
_name = 'ir.attachment.metadata'
_inherits = {'ir.attachment': 'attachment_id'}
+ _inherit = ['mail.thread', 'ir.needaction_mixin']
internal_hash = fields.Char(store=True, compute='_compute_hash')
external_hash = fields.Char()
diff --git a/external_file_location/attachment_view.xml b/external_file_location/attachment_view.xml
index b17e8ad7..b11b6c4f 100644
--- a/external_file_location/attachment_view.xml
+++ b/external_file_location/attachment_view.xml
@@ -72,7 +72,7 @@
form
tree,form
- [('task_id', '!=', False)]
+
diff --git a/file_email/__init__.py b/file_email/__init__.py
index c2827724..d219d134 100644
--- a/file_email/__init__.py
+++ b/file_email/__init__.py
@@ -20,5 +20,5 @@
#
###############################################################################
-import file_document
+import attachment_metadata
import fetchmail
diff --git a/file_email/__openerp__.py b/file_email/__openerp__.py
index 0d88bca3..e3709038 100644
--- a/file_email/__openerp__.py
+++ b/file_email/__openerp__.py
@@ -27,16 +27,16 @@
'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_document and then in your custom module you can process it.
+ as a attachment_metadata 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_document', 'fetchmail'],
+ 'depends': ['external_file_location', 'fetchmail'],
'init_xml': [],
'update_xml': [
"fetchmail_view.xml",
- "file_document_view.xml",
+ "attachment_metadata_view.xml",
],
'demo_xml': [],
'installable': True,
diff --git a/file_email/file_document.py b/file_email/attachment_metadata.py
similarity index 77%
rename from file_email/file_document.py
rename to file_email/attachment_metadata.py
index 655c4bcb..60536962 100644
--- a/file_email/file_document.py
+++ b/file_email/attachment_metadata.py
@@ -24,22 +24,21 @@ from openerp.osv import fields, orm
import base64
-class file_document(orm.Model):
- _inherit = "file.document"
+class IrAttachmentMetadata(orm.Model):
+ _inherit = "ir.attachment.metadata"
_columns = {
'fetchmail_server_id': fields.many2one('fetchmail.server', 'Email Server'),
}
-
def message_process(self, cr, uid, model, message, custom_values=None,
save_original=False, strip_attachments=False,
thread_id=None, context=None):
if context is None:
context = {}
context['no_post'] = True
- return super(file_document, self).message_process(self, cr, uid, model,
+ return super(IrAttachmentMetadata, self).message_process(self, cr, uid, model,
message,
custom_values=custom_values,
save_original=save_original,
@@ -52,7 +51,7 @@ class file_document(orm.Model):
content_subtype='html', **kwargs):
if context.get('no_post'):
return None
- return super(file_document, self).message_post(cr, uid, thread_id,
+ return super(IrAttachmentMetadata, self).message_post(cr, uid, thread_id,
body=body,
subject=subject,
type='notification',
@@ -63,7 +62,7 @@ class file_document(orm.Model):
content_subtype=content_subtype,
**kwargs)
- def _get_file_document_data(self, cr, uid, condition, msg, att, context=None):
+ def _get_attachment_metadata_data(self, cr, uid, condition, msg, att, context=None):
values = {
'file_type': condition.server_id.file_type,
'name': msg['subject'],
@@ -80,22 +79,22 @@ class file_document(orm.Model):
if condition.from_email in msg['from'] and condition.mail_subject in msg['subject']:
for att in msg['attachments']:
if condition.file_extension in att[0]:
- vals = self._get_file_document_data(cr, uid, condition, msg, att, context=context)
+ vals = self._get_attachment_metadata_data(cr, uid, condition, msg, att, context=context)
break
return vals
- def _prepare_data_for_file_document(self, cr, uid, msg, context=None):
- """Method to prepare the data for creating a file document.
+ def _prepare_data_for_attachment_metadata(self, cr, uid, msg, context=None):
+ """Method to prepare the data for creating a attachment metadata.
:param msg: a dictionnary with the email data
:type: dict
- :return: a list of dictionnary that containt the file document data
+ :return: a list of dictionnary that containt the attachment metadata data
:rtype: list
"""
res = []
server_id = context.get('default_fetchmail_server_id', False)
- doc_file_condition_obj = self.pool.get('file.document.condition')
+ doc_file_condition_obj = self.pool.get('ir.attachment.metadata.condition')
cond_ids = doc_file_condition_obj.search(cr, uid, [('server_id', '=', server_id)])
if cond_ids:
for cond in doc_file_condition_obj.browse(cr, uid, cond_ids):
@@ -109,10 +108,10 @@ class file_document(orm.Model):
def message_new(self, cr, uid, msg, custom_values, context=None):
created_ids = []
- res = self._prepare_data_for_file_document(cr, uid, msg, context=context)
+ res = self._prepare_data_for_attachment_metadata(cr, uid, msg, context=context)
if res:
for vals in res:
- default = context.get('default_file_document_vals')
+ default = context.get('default_attachment_metadata_vals')
if default:
for key in default:
if not key in vals:
@@ -124,20 +123,20 @@ class file_document(orm.Model):
return None
-class file_document_condition(orm.Model):
- _name = "file.document.condition"
- _description = "File Document Conditions"
+class IrAttachmentMetadataCondition(orm.Model):
+ _name = "ir.attachment.metadata.condition"
+ _description = "Attachment Metadata Conditions"
- def _get_file_document_condition_type(self, cr, uid, context=None):
- return self.get_file_document_condition_type(cr, uid, context=context)
+ def _get_attachment_metadata_condition_type(self, cr, uid, context=None):
+ return self.get_attachment_metadata_condition_type(cr, uid, context=context)
- def get_file_document_condition_type(self, cr, uid, context=None):
+ def get_attachment_metadata_condition_type(self, cr, uid, context=None):
return [('normal', 'Normal')]
_columns = {
'from_email': fields.char('Email', size=64),
'mail_subject': fields.char('Mail Subject', size=64),
- 'type': fields.selection(_get_file_document_condition_type,
+ 'type': fields.selection(_get_attachment_metadata_condition_type,
'Type', help="Create your own type if the normal type \
do not correspond to your need", required=True),
'file_extension' : fields.char('File Extension', size=64,
diff --git a/file_email/attachment_metadata_view.xml b/file_email/attachment_metadata_view.xml
new file mode 100644
index 00000000..4b23fbfa
--- /dev/null
+++ b/file_email/attachment_metadata_view.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+ ir.attachment.metadata.search
+ ir.attachment.metadata
+ search
+
+
+
+
+
+
+
+
+
+
+ view_attachment_metadata_condition_tree
+ ir.attachment.metadata.condition
+
+
+
+
+
+
+
+
+
+
+
+
+ view_attachment_metadata_condition_form
+ ir.attachment.metadata.condition
+
+
+
+
+
+
+ Configuration
+ ir.attachment.metadata.condition
+ form
+ tree,form
+
+
+
+
+
+
+
diff --git a/file_email/fetchmail.py b/file_email/fetchmail.py
index d9a12610..15db7424 100644
--- a/file_email/fetchmail.py
+++ b/file_email/fetchmail.py
@@ -36,7 +36,7 @@ class fetchmail_server(orm.Model):
'file_type': fields.selection(_get_file_type, 'File Type',
help='The file type will show some special option'),
'company_id': fields.many2one('res.company', 'Company', required=True),#Why this field do not exist by default?
- 'file_document_condition_ids': fields.one2many('file.document.condition', 'server_id', 'File Document ')
+ 'attachment_metadata_condition_ids': fields.one2many('ir.attachment.metadata.condition', 'server_id', 'Attachment')
}
_defaults = {
@@ -49,7 +49,7 @@ class fetchmail_server(orm.Model):
ctx = {}
else:
ctx = context.copy()
- ctx['default_file_document_vals'] = {}
+ ctx['default_attachment_metadata_vals'] = {}
server = self.browse(cr, uid, server_id, context=context)
ctx['default_company_id'] = server.company_id.id
ctx['default_fetchmail_server_id'] = server_id
diff --git a/file_email/fetchmail_view.xml b/file_email/fetchmail_view.xml
index 9c7b5fdb..5dfd091a 100644
--- a/file_email/fetchmail_view.xml
+++ b/file_email/fetchmail_view.xml
@@ -13,7 +13,7 @@
-
+
diff --git a/file_email/file_document_view.xml b/file_email/file_document_view.xml
deleted file mode 100644
index 7addf407..00000000
--- a/file_email/file_document_view.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
- file.document.search
- file.document
- search
-
-
-
-
-
-
-
-
-
-
- view_file_document_condition_tree
- file.document.condition
-
-
-
-
-
-
-
-
-
-
-
-
- view_file_document_condition_form
- file.document.condition
-
-
-
-
-
-
- Configuration
- file.document.condition
- form
- tree,form
-
-
-
-
-
-
-