diff --git a/attachment_base_synchronize/README.rst b/attachment_base_synchronize/README.rst index fe25020d2..a609c314a 100644 --- a/attachment_base_synchronize/README.rst +++ b/attachment_base_synchronize/README.rst @@ -1,4 +1,3 @@ - .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 @@ -22,7 +21,7 @@ An example of the use of this module, can be found in the external_file_location Usage ===== -Go the menu Settings > Attachments +Go the menu Settings > Technical > Database Structure > Meta Data Attachments You can create / see standard attachments with additional fields @@ -30,7 +29,7 @@ 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/149/8.0 + :target: https://runbot.odoo-community.org/runbot/149/10.0 Known issues / Roadmap @@ -43,13 +42,9 @@ 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 -`_. +help us smash it by providing detailed and welcomed feedback. Credits ======= @@ -64,9 +59,7 @@ Contributors ------------ * Valentin CHEMIERE -* Sebastien BEAU -* Joel Grand-Guillaume Camptocamp -* initOS +* Florian da Costa * Angel Moya Maintainer diff --git a/attachment_base_synchronize/__manifest__.py b/attachment_base_synchronize/__manifest__.py index 40f3f390e..47bc71929 100644 --- a/attachment_base_synchronize/__manifest__.py +++ b/attachment_base_synchronize/__manifest__.py @@ -4,7 +4,7 @@ { 'name': 'Attachment Base Synchronize', - 'version': '9.0.1.0.0', + 'version': '10.0.1.0.0', 'author': 'Akretion,Odoo Community Association (OCA)', 'website': 'www.akretion.com', 'license': 'AGPL-3', @@ -21,7 +21,7 @@ 'demo': [ 'demo/attachment_metadata_demo.xml' ], - 'installable': False, + 'installable': True, 'application': False, 'images': [], } diff --git a/attachment_base_synchronize/data/cron.xml b/attachment_base_synchronize/data/cron.xml index 031d594dc..47c82b150 100644 --- a/attachment_base_synchronize/data/cron.xml +++ b/attachment_base_synchronize/data/cron.xml @@ -1,6 +1,5 @@ - - + Run Attachments Metadata @@ -14,5 +13,4 @@ ([]) - - + diff --git a/attachment_base_synchronize/demo/attachment_metadata_demo.xml b/attachment_base_synchronize/demo/attachment_metadata_demo.xml index 1a8444557..0dd70b59a 100644 --- a/attachment_base_synchronize/demo/attachment_metadata_demo.xml +++ b/attachment_base_synchronize/demo/attachment_metadata_demo.xml @@ -1,6 +1,5 @@ - - + bWlncmF0aW9uIHRlc3Q= @@ -8,5 +7,4 @@ attachment_metadata.doc - - + diff --git a/attachment_base_synchronize/models/attachment.py b/attachment_base_synchronize/models/attachment.py index baba50fd8..81d7d5b13 100644 --- a/attachment_base_synchronize/models/attachment.py +++ b/attachment_base_synchronize/models/attachment.py @@ -2,12 +2,13 @@ # @ 2015 Florian DA COSTA @ 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 as UserError -import openerp -import hashlib from base64 import b64decode +import hashlib import logging +import odoo +from odoo import _, api, fields, models +from odoo.exceptions import UserError + _logger = logging.getLogger(__name__) @@ -56,8 +57,7 @@ class IrAttachmentMetadata(models.Model): @api.model def run_attachment_metadata_scheduler(self, domain=None): if domain is None: - domain = [] - domain.append(('state', '=', 'pending')) + domain = [('state', '=', 'pending')] attachments = self.search(domain) if attachments: return attachments.run() @@ -70,7 +70,7 @@ class IrAttachmentMetadata(models.Model): """ for attachment in self: with api.Environment.manage(): - with openerp.registry(self.env.cr.dbname).cursor() as new_cr: + with odoo.registry(self.env.cr.dbname).cursor() as new_cr: new_env = api.Environment( new_cr, self.env.uid, self.env.context) attach = attachment.with_env(new_env) @@ -86,7 +86,11 @@ class IrAttachmentMetadata(models.Model): }) attach.env.cr.commit() else: - attach.write({'state': 'done'}) + vals = { + 'state': 'done', + 'sync_date': fields.Datetime.now(), + } + attach.write(vals) attach.env.cr.commit() return True diff --git a/attachment_base_synchronize/security/ir.model.access.csv b/attachment_base_synchronize/security/ir.model.access.csv index 9b01638c4..a3628dbba 100644 --- a/attachment_base_synchronize/security/ir.model.access.csv +++ b/attachment_base_synchronize/security/ir.model.access.csv @@ -1,2 +1,3 @@ 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 +access_attachment_metadata_user,ir.attachment.metadata.user,model_ir_attachment_metadata,,1,0,0,0 +access_attachment_metadata_user,ir.attachment.metadata.user,model_ir_attachment_metadata,base.group_no_one,1,1,1,1 diff --git a/attachment_base_synchronize/tests/test_attachment_base_synchronize.py b/attachment_base_synchronize/tests/test_attachment_base_synchronize.py index 7ace25276..a4f90abdf 100644 --- a/attachment_base_synchronize/tests/test_attachment_base_synchronize.py +++ b/attachment_base_synchronize/tests/test_attachment_base_synchronize.py @@ -2,9 +2,9 @@ # Copyright 2016 Angel Moya (http://angelmoya.es) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp.tests.common import TransactionCase -import openerp -from openerp import api +from odoo.tests.common import TransactionCase +import odoo +from odoo import api class TestAttachmentBaseSynchronize(TransactionCase): @@ -31,7 +31,7 @@ class TestAttachmentBaseSynchronize(TransactionCase): ) self.ir_attachment_metadata.run_attachment_metadata_scheduler() self.env.invalidate_all() - with openerp.registry(self.env.cr.dbname).cursor() as new_cr: + with odoo.registry(self.env.cr.dbname).cursor() as new_cr: new_env = api.Environment( new_cr, self.env.uid, self.env.context) attach = self.attachment.with_env(new_env) @@ -43,6 +43,10 @@ class TestAttachmentBaseSynchronize(TransactionCase): def test_set_done(self): """Test set_done manually """ + self.assertEqual( + self.attachment.state, + 'pending' + ) self.attachment.set_done() self.assertEqual( self.attachment.state, diff --git a/attachment_base_synchronize/views/attachment_view.xml b/attachment_base_synchronize/views/attachment_view.xml index 7da173faf..28dfaf702 100644 --- a/attachment_base_synchronize/views/attachment_view.xml +++ b/attachment_base_synchronize/views/attachment_view.xml @@ -1,6 +1,5 @@ - - + ir.attachment.metadata @@ -108,5 +107,4 @@ sequence="20" action="action_attachment"/> - - +