From e717eee18e8bc80f6fd4eb5ee3a6d67188ae4b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Mon, 11 May 2020 14:41:08 +0200 Subject: [PATCH] [REF] Rename to attachement_queue --- .../__init__.py | 0 .../__manifest__.py | 12 ++-- .../data/cron.xml | 10 +-- attachment_queue/data/ir_config_parameter.xml | 7 +++ .../data/mail_template.xml | 2 +- .../demo/attachment_queue_demo.xml | 10 +++ attachment_queue/models/__init__.py | 1 + .../models/attachment_queue.py | 18 +++--- .../readme/CONTRIBUTORS.rst | 0 attachment_queue/readme/DESCRIPTION.rst | 5 ++ .../readme/USAGE.rst | 4 +- attachment_queue/security/ir.model.access.csv | 3 + .../static/description/icon.png | Bin .../tests/__init__.py | 2 +- .../tests/test_attachment_queue.py | 10 ++- .../views/attachment_queue_view.xml | 59 +++++++++--------- .../data/ir_config_parameter.xml | 7 --- .../demo/attachment_metadata_demo.xml | 10 --- base_attachment_queue/models/__init__.py | 1 - base_attachment_queue/readme/DESCRIPTION.rst | 6 -- .../security/ir.model.access.csv | 3 - 21 files changed, 83 insertions(+), 87 deletions(-) rename {base_attachment_queue => attachment_queue}/__init__.py (100%) rename {base_attachment_queue => attachment_queue}/__manifest__.py (63%) rename {base_attachment_queue => attachment_queue}/data/cron.xml (55%) create mode 100644 attachment_queue/data/ir_config_parameter.xml rename {base_attachment_queue => attachment_queue}/data/mail_template.xml (92%) create mode 100644 attachment_queue/demo/attachment_queue_demo.xml create mode 100644 attachment_queue/models/__init__.py rename base_attachment_queue/models/attachment.py => attachment_queue/models/attachment_queue.py (86%) rename {base_attachment_queue => attachment_queue}/readme/CONTRIBUTORS.rst (100%) create mode 100644 attachment_queue/readme/DESCRIPTION.rst rename {base_attachment_queue => attachment_queue}/readme/USAGE.rst (50%) create mode 100644 attachment_queue/security/ir.model.access.csv rename {base_attachment_queue => attachment_queue}/static/description/icon.png (100%) rename {base_attachment_queue => attachment_queue}/tests/__init__.py (61%) rename base_attachment_queue/tests/test_attachment_base_queue.py => attachment_queue/tests/test_attachment_queue.py (77%) rename base_attachment_queue/views/attachment_view.xml => attachment_queue/views/attachment_queue_view.xml (67%) delete mode 100644 base_attachment_queue/data/ir_config_parameter.xml delete mode 100644 base_attachment_queue/demo/attachment_metadata_demo.xml delete mode 100644 base_attachment_queue/models/__init__.py delete mode 100644 base_attachment_queue/readme/DESCRIPTION.rst delete mode 100644 base_attachment_queue/security/ir.model.access.csv diff --git a/base_attachment_queue/__init__.py b/attachment_queue/__init__.py similarity index 100% rename from base_attachment_queue/__init__.py rename to attachment_queue/__init__.py diff --git a/base_attachment_queue/__manifest__.py b/attachment_queue/__manifest__.py similarity index 63% rename from base_attachment_queue/__manifest__.py rename to attachment_queue/__manifest__.py index 9038f9a06..ece97f5a2 100644 --- a/base_attachment_queue/__manifest__.py +++ b/attachment_queue/__manifest__.py @@ -2,12 +2,12 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - 'name': 'Base Attachment Queue', + 'name': 'Attachment Queue', 'version': '12.0.1.0.0', 'author': 'Akretion,Odoo Community Association (OCA)', - 'summary': 'This module enhances ir.attachment for better ' - 'control of import and export of files', - 'website': 'https://www.akretion.com', + 'summary': "Base module that add the concept of queue for processing file", + 'website': 'https://github.com/OCA/server-tools', + 'maintainers': ['florian-dacosta', 'sebastienbeau'], 'license': 'AGPL-3', 'category': 'Generic Modules', 'depends': [ @@ -15,14 +15,14 @@ 'mail', ], 'data': [ - 'views/attachment_view.xml', + 'views/attachment_queue_view.xml', 'security/ir.model.access.csv', 'data/cron.xml', 'data/ir_config_parameter.xml', 'data/mail_template.xml', ], 'demo': [ - 'demo/attachment_metadata_demo.xml' + 'demo/attachment_queue_demo.xml' ], 'installable': True, } diff --git a/base_attachment_queue/data/cron.xml b/attachment_queue/data/cron.xml similarity index 55% rename from base_attachment_queue/data/cron.xml rename to attachment_queue/data/cron.xml index 677fcc446..ad4e6540a 100644 --- a/base_attachment_queue/data/cron.xml +++ b/attachment_queue/data/cron.xml @@ -1,16 +1,16 @@ - - - Run Attachments Metadata + + + Run Attachments Queue 30 minutes -1 False - + code - model.run_attachment_metadata_scheduler() + model.run_attachment_queue_scheduler() diff --git a/attachment_queue/data/ir_config_parameter.xml b/attachment_queue/data/ir_config_parameter.xml new file mode 100644 index 000000000..5b723255a --- /dev/null +++ b/attachment_queue/data/ir_config_parameter.xml @@ -0,0 +1,7 @@ + + + + attachment_queue_cron_batch_limit + 200 + + diff --git a/base_attachment_queue/data/mail_template.xml b/attachment_queue/data/mail_template.xml similarity index 92% rename from base_attachment_queue/data/mail_template.xml rename to attachment_queue/data/mail_template.xml index a09a66b4b..4eec88492 100644 --- a/base_attachment_queue/data/mail_template.xml +++ b/attachment_queue/data/mail_template.xml @@ -5,7 +5,7 @@ ${object.failure_emails} Attachment Failure notification The attachment ${object.name} has failed - + Hello,

The attachment ${object.name} has failed with the following error message :
${object.state_message}

diff --git a/attachment_queue/demo/attachment_queue_demo.xml b/attachment_queue/demo/attachment_queue_demo.xml new file mode 100644 index 000000000..ef69be60a --- /dev/null +++ b/attachment_queue/demo/attachment_queue_demo.xml @@ -0,0 +1,10 @@ + + + + + bWlncmF0aW9uIHRlc3Q= + attachment_queue_demo.doc + attachment_queue_demo.doc + + + diff --git a/attachment_queue/models/__init__.py b/attachment_queue/models/__init__.py new file mode 100644 index 000000000..89333838a --- /dev/null +++ b/attachment_queue/models/__init__.py @@ -0,0 +1 @@ +from . import attachment_queue diff --git a/base_attachment_queue/models/attachment.py b/attachment_queue/models/attachment_queue.py similarity index 86% rename from base_attachment_queue/models/attachment.py rename to attachment_queue/models/attachment_queue.py index 18f34d47b..72e057ced 100644 --- a/base_attachment_queue/models/attachment.py +++ b/attachment_queue/models/attachment_queue.py @@ -7,8 +7,8 @@ from odoo import api, fields, models, registry _logger = logging.getLogger(__name__) -class IrAttachmentMetadata(models.Model): - _name = 'ir.attachment.metadata' +class AttachmentQueue(models.Model): + _name = 'attachment.queue' _inherits = {'ir.attachment': 'attachment_id'} _inherit = ['mail.thread'] @@ -19,7 +19,7 @@ class IrAttachmentMetadata(models.Model): selection=[], help="The file type determines an import method to be used " "to parse and transform data before their import in ERP or an export") - sync_date = fields.Datetime() + date_done = fields.Datetime() state = fields.Selection([ ('pending', 'Pending'), ('failed', 'Failed'), @@ -42,11 +42,11 @@ class IrAttachmentMetadata(models.Model): return "" @api.model - def run_attachment_metadata_scheduler(self, domain=None): + def run_attachment_queue_scheduler(self, domain=None): if domain is None: domain = [('state', '=', 'pending')] batch_limit = self.env.ref( - 'base_attachment_queue.attachment_sync_cron_batch_limit') \ + 'attachment_queue.attachment_queue_cron_batch_limit') \ .value if batch_limit and batch_limit.isdigit(): limit = int(batch_limit) @@ -59,10 +59,10 @@ class IrAttachmentMetadata(models.Model): def run(self): """ - Run the process for each attachment metadata + Run the process for each attachment queue """ failure_tmpl = self.env.ref( - 'base_attachment_queue.attachment_failure_notification') + 'attachment_queue.attachment_failure_notification') for attachment in self: with api.Environment.manage(): with registry(self.env.cr.dbname).cursor() as new_cr: @@ -86,7 +86,7 @@ class IrAttachmentMetadata(models.Model): else: vals = { 'state': 'done', - 'sync_date': fields.Datetime.now(), + 'date_done': fields.Datetime.now(), } attach.write(vals) attach.env.cr.commit() @@ -95,7 +95,7 @@ class IrAttachmentMetadata(models.Model): @api.multi def _run(self): self.ensure_one() - _logger.info('Start to process attachment metadata id %d', self.id) + _logger.info('Start to process attachment queue id %d', self.id) @api.multi def set_done(self): diff --git a/base_attachment_queue/readme/CONTRIBUTORS.rst b/attachment_queue/readme/CONTRIBUTORS.rst similarity index 100% rename from base_attachment_queue/readme/CONTRIBUTORS.rst rename to attachment_queue/readme/CONTRIBUTORS.rst diff --git a/attachment_queue/readme/DESCRIPTION.rst b/attachment_queue/readme/DESCRIPTION.rst new file mode 100644 index 000000000..a5e20daee --- /dev/null +++ b/attachment_queue/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module implement a queue for processing file. +File are stored in Odoo standard ir.attachment. +The attachments will be processed depending on their type. + +An example of the use of this module, can be found in the module `attachment_synchronize`. diff --git a/base_attachment_queue/readme/USAGE.rst b/attachment_queue/readme/USAGE.rst similarity index 50% rename from base_attachment_queue/readme/USAGE.rst rename to attachment_queue/readme/USAGE.rst index c64e0d71b..ec276d247 100644 --- a/base_attachment_queue/readme/USAGE.rst +++ b/attachment_queue/readme/USAGE.rst @@ -1,8 +1,8 @@ -Go the menu Settings > Technical > Database Structure > Meta Data Attachments +Go the menu Settings > Technical > Database Structure > Attachments Queue You can create / see standard attachments with additional fields Configure the batch limit for attachments that can be sync by the cron task at a go: -Settings > Technical > System parameters > attachment_sync_cron_batch_limit +Settings > Technical > System parameters > attachment_queue_cron_batch_limit diff --git a/attachment_queue/security/ir.model.access.csv b/attachment_queue/security/ir.model.access.csv new file mode 100644 index 000000000..e1e0880a3 --- /dev/null +++ b/attachment_queue/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_attachment_queue_user,attachment.queue.user,model_attachment_queue,,1,0,0,0 +access_attachment_queue_manager,attachment.queue.manager,model_attachment_queue,base.group_no_one,1,1,1,1 diff --git a/base_attachment_queue/static/description/icon.png b/attachment_queue/static/description/icon.png similarity index 100% rename from base_attachment_queue/static/description/icon.png rename to attachment_queue/static/description/icon.png diff --git a/base_attachment_queue/tests/__init__.py b/attachment_queue/tests/__init__.py similarity index 61% rename from base_attachment_queue/tests/__init__.py rename to attachment_queue/tests/__init__.py index 0d389aca2..7f25150f6 100644 --- a/base_attachment_queue/tests/__init__.py +++ b/attachment_queue/tests/__init__.py @@ -1,3 +1,3 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from . import test_attachment_base_queue +from . import test_attachment_queue diff --git a/base_attachment_queue/tests/test_attachment_base_queue.py b/attachment_queue/tests/test_attachment_queue.py similarity index 77% rename from base_attachment_queue/tests/test_attachment_base_queue.py rename to attachment_queue/tests/test_attachment_queue.py index 4ba9c3adc..fc29f902f 100644 --- a/base_attachment_queue/tests/test_attachment_base_queue.py +++ b/attachment_queue/tests/test_attachment_queue.py @@ -12,22 +12,20 @@ class TestAttachmentBaseQueue(TransactionCase): self.registry.enter_test_mode(self.env.cr) self.env = api.Environment(self.registry.test_cr, self.env.uid, self.env.context) - self.attachment = self.env.ref( - 'base_attachment_queue.attachment_metadata') - self.ir_attachment_metadata = self.env['ir.attachment.metadata'] + self.attachment = self.env.ref('attachment_queue.attachment_queue_demo') def tearDown(self): self.registry.leave_test_mode() super().tearDown() - def test_attachment_metadata(self): - """Test run_attachment_metadata_scheduler to ensure set state to done + def test_attachment_queue(self): + """Test run_attachment_queue_scheduler to ensure set state to done """ self.assertEqual( self.attachment.state, 'pending' ) - self.ir_attachment_metadata.run_attachment_metadata_scheduler() + self.env['attachment.queue'].run_attachment_queue_scheduler() self.env.cache.invalidate() with odoo.registry(self.env.cr.dbname).cursor() as new_cr: new_env = api.Environment( diff --git a/base_attachment_queue/views/attachment_view.xml b/attachment_queue/views/attachment_queue_view.xml similarity index 67% rename from base_attachment_queue/views/attachment_view.xml rename to attachment_queue/views/attachment_queue_view.xml index 2d3e0b60e..f8bc7c9d3 100644 --- a/base_attachment_queue/views/attachment_view.xml +++ b/attachment_queue/views/attachment_queue_view.xml @@ -1,9 +1,9 @@ - - ir.attachment.metadata - + + attachment.queue +
@@ -14,7 +14,7 @@
- + @@ -26,8 +26,8 @@
- - ir.attachment.metadata + + attachment.queue @@ -40,8 +40,8 @@ - - ir.attachment.metadata + + attachment.queue @@ -53,7 +53,7 @@ string="Binary" domain="[('type','=','binary')]"/> - @@ -74,34 +74,33 @@ - - Meta data Attachments - ir.actions.act_window - ir.attachment.metadata - form - tree,form - - + + Attachments Queue + ir.actions.act_window + attachment.queue + form + tree,form + + - - - tree - - + + + tree + + - - - form - - + + + form + + - - + action="action_attachment_queue"/>
diff --git a/base_attachment_queue/data/ir_config_parameter.xml b/base_attachment_queue/data/ir_config_parameter.xml deleted file mode 100644 index fa726d03d..000000000 --- a/base_attachment_queue/data/ir_config_parameter.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - attachment_sync_cron_batch_limit - 200 - - diff --git a/base_attachment_queue/demo/attachment_metadata_demo.xml b/base_attachment_queue/demo/attachment_metadata_demo.xml deleted file mode 100644 index 0dd70b59a..000000000 --- a/base_attachment_queue/demo/attachment_metadata_demo.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - bWlncmF0aW9uIHRlc3Q= - attachment_metadata.doc - attachment_metadata.doc - - - diff --git a/base_attachment_queue/models/__init__.py b/base_attachment_queue/models/__init__.py deleted file mode 100644 index c14c86359..000000000 --- a/base_attachment_queue/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import attachment diff --git a/base_attachment_queue/readme/DESCRIPTION.rst b/base_attachment_queue/readme/DESCRIPTION.rst deleted file mode 100644 index e151984ed..000000000 --- a/base_attachment_queue/readme/DESCRIPTION.rst +++ /dev/null @@ -1,6 +0,0 @@ -This module extends ir.attachment model with some new fields for a better control for import and export of files. - -The main feature is the possibility to create a queue of attachment and have a cron process it. -The attachments will be processed depending on their type. - -An example of the use of this module, can be found in the module `attachment_synchronize`. diff --git a/base_attachment_queue/security/ir.model.access.csv b/base_attachment_queue/security/ir.model.access.csv deleted file mode 100644 index a886558da..000000000 --- a/base_attachment_queue/security/ir.model.access.csv +++ /dev/null @@ -1,3 +0,0 @@ -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,,1,0,0,0 -access_attachment_metadata_manager,ir.attachment.metadata.manager,model_ir_attachment_metadata,base.group_no_one,1,1,1,1