From 5478608e3644b6abea656769944b835a7ec6d06c Mon Sep 17 00:00:00 2001 From: Valentin Chemiere Date: Wed, 17 Jun 2015 12:14:35 +0200 Subject: [PATCH 01/15] Add file import/export --- attachment_metadata/README.rst | 51 +++++++++++++++++++ attachment_metadata/__init__.py | 23 +++++++++ attachment_metadata/__openerp__.py | 43 ++++++++++++++++ attachment_metadata/attachment.py | 47 +++++++++++++++++ attachment_metadata/attachment_view.xml | 17 +++++++ .../security/ir.model.access.csv | 2 + 6 files changed, 183 insertions(+) create mode 100644 attachment_metadata/README.rst create mode 100644 attachment_metadata/__init__.py create mode 100644 attachment_metadata/__openerp__.py create mode 100644 attachment_metadata/attachment.py create mode 100644 attachment_metadata/attachment_view.xml create mode 100644 attachment_metadata/security/ir.model.access.csv diff --git a/attachment_metadata/README.rst b/attachment_metadata/README.rst new file mode 100644 index 000000000..f9640f29e --- /dev/null +++ b/attachment_metadata/README.rst @@ -0,0 +1,51 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License + +Attachment Metadata +====================== + +This module was written to extend the functionality of ir.attachment + +Installation +============ + +Installable without any requirements + +Usage +===== + +THe module just add some field to ir.attachment + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + +Credits +======= + +* Joel Grand-Guillaume Camptocamp +* initOS +* Valentin CHEMIERE + +Contributors +------------ + +* Sebastien BEAU + +Maintainer +---------- + +* Valentin CHEMIERE + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/attachment_metadata/__init__.py b/attachment_metadata/__init__.py new file mode 100644 index 000000000..3e53cd607 --- /dev/null +++ b/attachment_metadata/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Module for OpenERP +# Copyright (C) 2015 Akretion (http://www.akretion.com). +# @author Valentin CHEMIERE +# +# 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 . import attachment diff --git a/attachment_metadata/__openerp__.py b/attachment_metadata/__openerp__.py new file mode 100644 index 000000000..232b1f84a --- /dev/null +++ b/attachment_metadata/__openerp__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Module for OpenERP +# Copyright (C) 2015 Akretion (http://www.akretion.com). +# @author Valentin CHEMIERE +# +# 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': 'attachment_metadata', + 'version': '0.0.1', + 'author': 'Akretion', + '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': [ + 'base', + 'mail' + ], + 'data': [ + 'attachment_view.xml', + 'security/ir.model.access.csv', + ], + 'installable': True, + 'application': False, + } diff --git a/attachment_metadata/attachment.py b/attachment_metadata/attachment.py new file mode 100644 index 000000000..b75ff47a6 --- /dev/null +++ b/attachment_metadata/attachment.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Module for OpenERP +# Copyright 2011-2012 Camptocamp SA +# @author: Joel Grand-Guillaume +# Copyright (C) 2015 Akretion (http://www.akretion.com). +# @author Valentin CHEMIERE +# +# 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 import models, fields, api, _ +from openerp.exceptions import Warning +import hashlib +from base64 import b64decode + + +class IrAttachmentMetadata(models.Model): + _name = 'ir.attachment.metadata' + _inherits = {'ir.attachment': 'attachment_id'} + + internal_hash = fields.Char(store=True, compute='_compute_hash') + external_hash = fields.Char() + attachment_id = fields.Many2one('ir.attachment', required=True, + ondelete='cascade') + + @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 Warning(_('File corrupted'), + _("Something was wrong with the retreived file, " + "please relaunch the task.")) diff --git a/attachment_metadata/attachment_view.xml b/attachment_metadata/attachment_view.xml new file mode 100644 index 000000000..a95535596 --- /dev/null +++ b/attachment_metadata/attachment_view.xml @@ -0,0 +1,17 @@ + + + + + + ir.attachment.metadata + + + + + + + + + + + diff --git a/attachment_metadata/security/ir.model.access.csv b/attachment_metadata/security/ir.model.access.csv new file mode 100644 index 000000000..9b01638c4 --- /dev/null +++ b/attachment_metadata/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_attachment_metadata_user,ir.attachment.metadata.user,model_ir_attachment_metadata,base.group_user,1,0,0,0 From 12b333db8c1b8cc8b963a016bcfc6a14740a457d Mon Sep 17 00:00:00 2001 From: David Beal Date: Tue, 23 Feb 2016 21:51:34 +0100 Subject: [PATCH 02/15] [FIX] python header in akretion modules --- attachment_metadata/__init__.py | 22 ------------------- attachment_metadata/__openerp__.py | 24 +++------------------ attachment_metadata/attachment.py | 34 +++++++----------------------- 3 files changed, 11 insertions(+), 69 deletions(-) diff --git a/attachment_metadata/__init__.py b/attachment_metadata/__init__.py index 3e53cd607..c14c86359 100644 --- a/attachment_metadata/__init__.py +++ b/attachment_metadata/__init__.py @@ -1,23 +1 @@ -# -*- coding: utf-8 -*- -############################################################################### -# -# Module for OpenERP -# Copyright (C) 2015 Akretion (http://www.akretion.com). -# @author Valentin CHEMIERE -# -# 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 . import attachment diff --git a/attachment_metadata/__openerp__.py b/attachment_metadata/__openerp__.py index 232b1f84a..1fed0db4f 100644 --- a/attachment_metadata/__openerp__.py +++ b/attachment_metadata/__openerp__.py @@ -1,24 +1,6 @@ -# -*- coding: utf-8 -*- -############################################################################### -# -# Module for OpenERP -# Copyright (C) 2015 Akretion (http://www.akretion.com). -# @author Valentin CHEMIERE -# -# 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 . -# -############################################################################### +# coding: utf-8 +# @ 2015 Valentin CHEMIERE @ Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). {'name': 'attachment_metadata', 'version': '0.0.1', diff --git a/attachment_metadata/attachment.py b/attachment_metadata/attachment.py index b75ff47a6..85f3da4e9 100644 --- a/attachment_metadata/attachment.py +++ b/attachment_metadata/attachment.py @@ -1,29 +1,11 @@ -# -*- coding: utf-8 -*- -############################################################################### -# -# Module for OpenERP -# Copyright 2011-2012 Camptocamp SA -# @author: Joel Grand-Guillaume -# Copyright (C) 2015 Akretion (http://www.akretion.com). -# @author Valentin CHEMIERE -# -# 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 . -# -############################################################################### +# coding: utf-8 +# Copyright (C) 2014 initOS GmbH & Co. KG (). +# @author: Joel Grand-Guillaume @ Camptocamp SA +# @ 2015 Valentin CHEMIERE @ Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openerp import models, fields, api, _ -from openerp.exceptions import Warning +from openerp.exceptions import Warning as UserError import hashlib from base64 import b64decode @@ -42,6 +24,6 @@ class IrAttachmentMetadata(models.Model): if self.datas: self.internal_hash = hashlib.md5(b64decode(self.datas)).hexdigest() if self.external_hash and self.internal_hash != self.external_hash: - raise Warning(_('File corrupted'), - _("Something was wrong with the retreived file, " + raise UserError(_('File corrupted'), + _("Something was wrong with the retreived file, " "please relaunch the task.")) From ff8e65e982f7fdbbcefcb2e6e9dd753bcd800af7 Mon Sep 17 00:00:00 2001 From: David Beal Date: Wed, 24 Feb 2016 14:01:40 +0100 Subject: [PATCH 03/15] [FIX] check if class is in installed module, README --- attachment_metadata/README.rst | 66 +++++++++++++++++-------- attachment_metadata/attachment.py | 21 +++++--- attachment_metadata/attachment_view.xml | 24 ++++----- 3 files changed, 72 insertions(+), 39 deletions(-) diff --git a/attachment_metadata/README.rst b/attachment_metadata/README.rst index f9640f29e..926d24474 100644 --- a/attachment_metadata/README.rst +++ b/attachment_metadata/README.rst @@ -1,51 +1,77 @@ + .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +==================== Attachment Metadata -====================== - -This module was written to extend the functionality of ir.attachment +==================== -Installation -============ +This module extend ir.attachment model with some new fields for a better control +for import and export of files. The main feature is an integrity file check with a hash. -Installable without any requirements Usage ===== -THe module just add some field to ir.attachment +Go the menu Settings > Attachments + +You can create / see standard attachments with additional fields + -For further information, please visit: -* https://www.odoo.com/forum/help-1 +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/{repo_id}/8.0 + +.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt +.. branch is "8.0" for example Known issues / Roadmap ====================== +* ... + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed `feedback +`_. + Credits ======= -* Joel Grand-Guillaume Camptocamp -* initOS -* Valentin CHEMIERE +Images +------ + +* Odoo Community Association: `Icon `_. + Contributors ------------ +* Valentin CHEMIERE * Sebastien BEAU +* Joel Grand-Guillaume Camptocamp +* initOS Maintainer ---------- -* Valentin CHEMIERE - -.. image:: http://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: http://odoo-community.org +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org This module is maintained by the OCA. -OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. diff --git a/attachment_metadata/attachment.py b/attachment_metadata/attachment.py index 85f3da4e9..d27a43292 100644 --- a/attachment_metadata/attachment.py +++ b/attachment_metadata/attachment.py @@ -14,16 +14,23 @@ class IrAttachmentMetadata(models.Model): _name = 'ir.attachment.metadata' _inherits = {'ir.attachment': 'attachment_id'} - internal_hash = fields.Char(store=True, compute='_compute_hash') - external_hash = fields.Char() - attachment_id = fields.Many2one('ir.attachment', required=True, - ondelete='cascade') + internal_hash = fields.Char( + store=True, compute='_compute_hash', + help="File hash computed with file data to be compared " + "to external hash when provided.") + external_hash = fields.Char( + help="File hash comes from the external owner of the file.\n" + "If provided allow to check than downloaded file " + "is the exact copy of the original file.") + attachment_id = fields.Many2one( + 'ir.attachment', required=True, ondelete='cascade', + help="Link to ir.attachment 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 retreived file, " - "please relaunch the task.")) + raise UserError( + _("File corrupted: Something was wrong with " + "the retrieved file, please relaunch the task.")) diff --git a/attachment_metadata/attachment_view.xml b/attachment_metadata/attachment_view.xml index a95535596..11e70172b 100644 --- a/attachment_metadata/attachment_view.xml +++ b/attachment_metadata/attachment_view.xml @@ -1,17 +1,17 @@ - + - - ir.attachment.metadata - - - - - - - - + + ir.attachment.metadata + + + + + + + + - + From 32c3fb62bc2830ebcd1c28176253434525928a06 Mon Sep 17 00:00:00 2001 From: David Beal Date: Fri, 26 Feb 2016 08:56:40 +0100 Subject: [PATCH 04/15] [FIX] community remarks --- attachment_metadata/README.rst | 10 ++++------ attachment_metadata/__init__.py | 2 +- attachment_metadata/__openerp__.py | 8 +++----- attachment_metadata/models/__init__.py | 1 + attachment_metadata/{ => models}/attachment.py | 0 attachment_metadata/{ => views}/attachment_view.xml | 0 6 files changed, 9 insertions(+), 12 deletions(-) create mode 100644 attachment_metadata/models/__init__.py rename attachment_metadata/{ => models}/attachment.py (100%) rename attachment_metadata/{ => views}/attachment_view.xml (100%) diff --git a/attachment_metadata/README.rst b/attachment_metadata/README.rst index 926d24474..82f7b6411 100644 --- a/attachment_metadata/README.rst +++ b/attachment_metadata/README.rst @@ -22,25 +22,23 @@ You can create / see standard attachments with additional fields .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/{repo_id}/8.0 + :target: https://runbot.odoo-community.org/runbot/149/8.0 -.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt -.. branch is "8.0" for example Known issues / Roadmap ====================== -* ... + Bug Tracker =========== Bugs are tracked on `GitHub Issues -`_. In case of trouble, please +`_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed `feedback `_. diff --git a/attachment_metadata/__init__.py b/attachment_metadata/__init__.py index c14c86359..0650744f6 100644 --- a/attachment_metadata/__init__.py +++ b/attachment_metadata/__init__.py @@ -1 +1 @@ -from . import attachment +from . import models diff --git a/attachment_metadata/__openerp__.py b/attachment_metadata/__openerp__.py index 1fed0db4f..2b23f955a 100644 --- a/attachment_metadata/__openerp__.py +++ b/attachment_metadata/__openerp__.py @@ -3,8 +3,8 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). {'name': 'attachment_metadata', - 'version': '0.0.1', - 'author': 'Akretion', + 'version': '8.0.1.0.0', + 'author': 'Akretion,Odoo Community Association (OCA)', 'website': 'www.akretion.com', 'license': 'AGPL-3', 'category': 'Generic Modules', @@ -13,11 +13,9 @@ internal and external hash for coherence verification """, 'depends': [ - 'base', - 'mail' ], 'data': [ - 'attachment_view.xml', + 'views/attachment_view.xml', 'security/ir.model.access.csv', ], 'installable': True, diff --git a/attachment_metadata/models/__init__.py b/attachment_metadata/models/__init__.py new file mode 100644 index 000000000..c14c86359 --- /dev/null +++ b/attachment_metadata/models/__init__.py @@ -0,0 +1 @@ +from . import attachment diff --git a/attachment_metadata/attachment.py b/attachment_metadata/models/attachment.py similarity index 100% rename from attachment_metadata/attachment.py rename to attachment_metadata/models/attachment.py diff --git a/attachment_metadata/attachment_view.xml b/attachment_metadata/views/attachment_view.xml similarity index 100% rename from attachment_metadata/attachment_view.xml rename to attachment_metadata/views/attachment_view.xml From f9b75eb1eee6860df3a33404691c9bb21a057ed1 Mon Sep 17 00:00:00 2001 From: David Beal Date: Fri, 26 Feb 2016 10:01:48 +0100 Subject: [PATCH 05/15] [IMP] README file --- attachment_metadata/README.rst | 11 ++++++++++- attachment_metadata/__openerp__.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/attachment_metadata/README.rst b/attachment_metadata/README.rst index 82f7b6411..5abfa0cc4 100644 --- a/attachment_metadata/README.rst +++ b/attachment_metadata/README.rst @@ -8,7 +8,15 @@ Attachment Metadata ==================== This module extend ir.attachment model with some new fields for a better control -for import and export of files. The main feature is an integrity file check with a hash. +for import and export of files. + +The main feature is an integrity file check with a hash. + +A file hash is short representation (signature) computed from file data. +Hashes computed before send file and after received file can be compared to be +sure of the content integrity. + +An example of the use of this module, can be found in the external_file_location. Usage @@ -28,6 +36,7 @@ You can create / see standard attachments with additional fields Known issues / Roadmap ====================== +The purpose of this module is not to import the data of the file but only exchange files with external application. Bug Tracker diff --git a/attachment_metadata/__openerp__.py b/attachment_metadata/__openerp__.py index 2b23f955a..56105e5d0 100644 --- a/attachment_metadata/__openerp__.py +++ b/attachment_metadata/__openerp__.py @@ -2,7 +2,7 @@ # @ 2015 Valentin CHEMIERE @ Akretion # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -{'name': 'attachment_metadata', +{'name': 'Attachment Metadata', 'version': '8.0.1.0.0', 'author': 'Akretion,Odoo Community Association (OCA)', 'website': 'www.akretion.com', 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 06/15] [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 07/15] [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 08/15] [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 09/15] [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 10/15] [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 11/15] [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 12/15] [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 13/15] [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 From 5391d086349f1b91819d71075fa7d72c91df9e56 Mon Sep 17 00:00:00 2001 From: David Beal Date: Tue, 31 May 2016 15:12:03 +0200 Subject: [PATCH 14/15] [FIX] remove oca dependencies --- oca_dependencies.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 oca_dependencies.txt diff --git a/oca_dependencies.txt b/oca_dependencies.txt deleted file mode 100644 index d2ebf74f8..000000000 --- a/oca_dependencies.txt +++ /dev/null @@ -1 +0,0 @@ -server-tools-file https://github.com/akretion/server-tools.git 8-file-loc \ No newline at end of file From 27e077f6ed1e52129cba0da1cd42f9ff6aa30216 Mon Sep 17 00:00:00 2001 From: Mourad Elhadj Mimoune Date: Wed, 1 Jun 2016 10:56:01 +0200 Subject: [PATCH 15/15] [FIX] bug of compute internal_hash --- attachment_metadata/models/attachment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attachment_metadata/models/attachment.py b/attachment_metadata/models/attachment.py index e21e29830..6fd9d52b0 100644 --- a/attachment_metadata/models/attachment.py +++ b/attachment_metadata/models/attachment.py @@ -36,7 +36,7 @@ class IrAttachmentMetadata(models.Model): for attachment in self: if attachment.datas: attachment.internal_hash = hashlib.md5( - b64decode(self.datas)).hexdigest() + b64decode(attachment.datas)).hexdigest() if attachment.external_hash and\ attachment.internal_hash != attachment.external_hash: raise UserError(