From aa2027b4fc7f7705de95fb0a08ecbb38842f0f5d Mon Sep 17 00:00:00 2001 From: Mourad El Hadj Mimoune Date: Wed, 9 Mar 2016 12:16:26 +0100 Subject: [PATCH 1/8] [ADD] add file type on attachment_metadata --- attachment_metadata/models/attachment.py | 12 ++++++++++++ attachment_metadata/views/attachment_view.xml | 1 + 2 files changed, 13 insertions(+) diff --git a/attachment_metadata/models/attachment.py b/attachment_metadata/models/attachment.py index d27a43292..813255710 100644 --- a/attachment_metadata/models/attachment.py +++ b/attachment_metadata/models/attachment.py @@ -25,6 +25,11 @@ 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 detrmine an import method to be used " + "to parse and transforme data before theire import in odoo") @api.depends('datas', 'external_hash') def _compute_hash(self): @@ -34,3 +39,10 @@ class IrAttachmentMetadata(models.Model): 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..b3a8dd06f 100644 --- a/attachment_metadata/views/attachment_view.xml +++ b/attachment_metadata/views/attachment_view.xml @@ -9,6 +9,7 @@ + From 2e7a196ac17588aa126eeef0c8fb3649905acf2b Mon Sep 17 00:00:00 2001 From: Mourad El Hadj Mimoune Date: Wed, 9 Mar 2016 15:48:23 +0100 Subject: [PATCH 2/8] [ADD] add view on attachment_metadata --- attachment_metadata/views/attachment_view.xml | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/attachment_metadata/views/attachment_view.xml b/attachment_metadata/views/attachment_view.xml index b3a8dd06f..a6e1d2e4b 100644 --- a/attachment_metadata/views/attachment_view.xml +++ b/attachment_metadata/views/attachment_view.xml @@ -14,5 +14,81 @@ + + ir.attachment.metadata + + + + + + + + + + + ir.attachment.metadata + + + + + + + + + + + + + + + + + + + + + + + Attachments + ir.actions.act_window + ir.attachment.metadata + form + tree,form + + + + + + + tree + + + + + + + form + + + + + + + + From 30efb9c394d11d72d0e218e350dd45f0fabc1b2b Mon Sep 17 00:00:00 2001 From: Mourad El Hadj Mimoune Date: Thu, 10 Mar 2016 14:34:07 +0100 Subject: [PATCH 3/8] [FIX] typing mistake --- attachment_metadata/models/attachment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/attachment_metadata/models/attachment.py b/attachment_metadata/models/attachment.py index 813255710..f2c0347f8 100644 --- a/attachment_metadata/models/attachment.py +++ b/attachment_metadata/models/attachment.py @@ -28,8 +28,8 @@ class IrAttachmentMetadata(models.Model): file_type = fields.Selection( selection="_get_file_type", string="File type", - help="The file type detrmine an import method to be used " - "to parse and transforme data before theire import in odoo") + 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): From b88563b7dbde144a262ab5ba1866c264dff0eabc Mon Sep 17 00:00:00 2001 From: Mourad El Hadj Mimoune Date: Thu, 10 Mar 2016 15:37:26 +0100 Subject: [PATCH 4/8] [IMP] move meta data attachement menu near attachement --- attachment_metadata/views/attachment_view.xml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/attachment_metadata/views/attachment_view.xml b/attachment_metadata/views/attachment_view.xml index a6e1d2e4b..71ed3a2cd 100644 --- a/attachment_metadata/views/attachment_view.xml +++ b/attachment_metadata/views/attachment_view.xml @@ -57,7 +57,7 @@ - Attachments + Meta data Attachments ir.actions.act_window ir.attachment.metadata form @@ -80,13 +80,9 @@ - From f70a939dd5663f63d8974f3e3913836f348cc8b0 Mon Sep 17 00:00:00 2001 From: Mourad El Hadj Mimoune Date: Wed, 16 Mar 2016 14:49:24 +0100 Subject: [PATCH 5/8] [FIX] bug of file import related to api.multi --- attachment_metadata/models/attachment.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/attachment_metadata/models/attachment.py b/attachment_metadata/models/attachment.py index f2c0347f8..15e3e56a6 100644 --- a/attachment_metadata/models/attachment.py +++ b/attachment_metadata/models/attachment.py @@ -33,12 +33,15 @@ class IrAttachmentMetadata(models.Model): @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 From 21ccc05958611004ede28116074414341c3a3037 Mon Sep 17 00:00:00 2001 From: Mourad El Hadj Mimoune Date: Wed, 25 May 2016 13:38:08 +0000 Subject: [PATCH 6/8] [FIX] fix pylint --- attachment_metadata/__openerp__.py | 36 ++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-) 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': [], +} From 5706e7d816455b14cfd8a7e1c7a7c6fb072bd827 Mon Sep 17 00:00:00 2001 From: Mourad Elhadj Mimoune Date: Wed, 25 May 2016 15:59:57 +0200 Subject: [PATCH 7/8] [FIX] add oca_dependencies --- oca_dependencies.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 oca_dependencies.txt diff --git a/oca_dependencies.txt b/oca_dependencies.txt new file mode 100644 index 000000000..d72e90060 --- /dev/null +++ b/oca_dependencies.txt @@ -0,0 +1 @@ +server-tools-file https://github.com/akretion/server-tools.git server-tools-file 8-file-loc \ No newline at end of file From 59cb07a0904d40115a6b01552b3138557b4325e8 Mon Sep 17 00:00:00 2001 From: Mourad Elhadj Mimoune Date: Thu, 26 May 2016 11:28:41 +0200 Subject: [PATCH 8/8] [FIX] fix pylint & oca_dependencies --- attachment_metadata/models/attachment.py | 8 ++++---- oca_dependencies.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/attachment_metadata/models/attachment.py b/attachment_metadata/models/attachment.py index 15e3e56a6..e21e29830 100644 --- a/attachment_metadata/models/attachment.py +++ b/attachment_metadata/models/attachment.py @@ -26,10 +26,10 @@ class IrAttachmentMetadata(models.Model): '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") + 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): diff --git a/oca_dependencies.txt b/oca_dependencies.txt index d72e90060..d2ebf74f8 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -1 +1 @@ -server-tools-file https://github.com/akretion/server-tools.git server-tools-file 8-file-loc \ No newline at end of file +server-tools-file https://github.com/akretion/server-tools.git 8-file-loc \ No newline at end of file