diff --git a/attachment_metadata/__openerp__.py b/attachment_metadata/__openerp__.py
index 56105e5d0..23b3d6795 100644
--- a/attachment_metadata/__openerp__.py
+++ b/attachment_metadata/__openerp__.py
@@ -2,22 +2,20 @@
# @ 2015 Valentin CHEMIERE @ Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-{'name': 'Attachment Metadata',
- 'version': '8.0.1.0.0',
- 'author': 'Akretion,Odoo Community Association (OCA)',
- 'website': 'www.akretion.com',
- 'license': 'AGPL-3',
- 'category': 'Generic Modules',
- 'description': """
- Add some useful field to ir.attachment object like:
- internal and external hash for coherence verification
- """,
- 'depends': [
- ],
- 'data': [
- 'views/attachment_view.xml',
- 'security/ir.model.access.csv',
- ],
- 'installable': True,
- 'application': False,
- }
+{
+ 'name': 'Attachment Metadata',
+ 'version': '8.0.1.0.0',
+ 'author': 'Akretion,Odoo Community Association (OCA)',
+ 'website': 'www.akretion.com',
+ 'license': 'AGPL-3',
+ 'category': 'Generic Modules',
+ 'depends': [
+ ],
+ 'data': [
+ 'views/attachment_view.xml',
+ 'security/ir.model.access.csv',
+ ],
+ 'installable': True,
+ 'application': False,
+ 'images': [],
+}
diff --git a/attachment_metadata/models/attachment.py b/attachment_metadata/models/attachment.py
index d27a43292..e21e29830 100644
--- a/attachment_metadata/models/attachment.py
+++ b/attachment_metadata/models/attachment.py
@@ -25,12 +25,27 @@ class IrAttachmentMetadata(models.Model):
attachment_id = fields.Many2one(
'ir.attachment', required=True, ondelete='cascade',
help="Link to ir.attachment model ")
+ file_type = fields.Selection(
+ selection="_get_file_type",
+ string="File type",
+ help="The file type determines an import method to be used "
+ "to parse and transform data before their import in ERP")
@api.depends('datas', 'external_hash')
def _compute_hash(self):
- if self.datas:
- self.internal_hash = hashlib.md5(b64decode(self.datas)).hexdigest()
- if self.external_hash and self.internal_hash != self.external_hash:
- raise UserError(
- _("File corrupted: Something was wrong with "
- "the retrieved file, please relaunch the task."))
+ for attachment in self:
+ if attachment.datas:
+ attachment.internal_hash = hashlib.md5(
+ b64decode(self.datas)).hexdigest()
+ if attachment.external_hash and\
+ attachment.internal_hash != attachment.external_hash:
+ raise UserError(
+ _("File corrupted: Something was wrong with "
+ "the retrieved file, please relaunch the task."))
+
+ def _get_file_type(self):
+ """This is the method to be inherited for adding file types
+ The basic import do not apply any parsing or transform of the file.
+ The file is just added as an attachement
+ """
+ return [('basic_import', 'Basic import')]
diff --git a/attachment_metadata/views/attachment_view.xml b/attachment_metadata/views/attachment_view.xml
index 11e70172b..71ed3a2cd 100644
--- a/attachment_metadata/views/attachment_view.xml
+++ b/attachment_metadata/views/attachment_view.xml
@@ -9,9 +9,82 @@
+
+
+ ir.attachment.metadata
+
+
+
+
+
+
+
+
+
+
+ ir.attachment.metadata
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Meta data Attachments
+ ir.actions.act_window
+ ir.attachment.metadata
+ form
+ tree,form
+
+
+
+
+
+
+ tree
+
+
+
+
+
+
+ form
+
+
+
+
+
+
+
diff --git a/oca_dependencies.txt b/oca_dependencies.txt
new file mode 100644
index 000000000..d2ebf74f8
--- /dev/null
+++ b/oca_dependencies.txt
@@ -0,0 +1 @@
+server-tools-file https://github.com/akretion/server-tools.git 8-file-loc
\ No newline at end of file