From 6fd1cb0b53ed274e1000772e722ac5e7b7f9eb7d Mon Sep 17 00:00:00 2001 From: Elouan Le Bars Date: Mon, 18 Nov 2019 11:19:35 +0100 Subject: [PATCH] [MOV] easy_my_coop_document -> document_hosting in addons repository --- easy_my_coop_document/__init__.py | 1 - easy_my_coop_document/__manifest__.py | 35 ----- easy_my_coop_document/models/__init__.py | 1 - easy_my_coop_document/models/document.py | 80 ----------- .../security/ir.model.access.csv | 5 - .../views/easy_my_coop_document_menu.xml | 39 ------ .../views/easy_my_coop_document_views.xml | 126 ------------------ easy_my_coop_website_document/__manifest__.py | 2 +- .../controllers/main.py | 8 +- 9 files changed, 5 insertions(+), 292 deletions(-) delete mode 100644 easy_my_coop_document/__init__.py delete mode 100644 easy_my_coop_document/__manifest__.py delete mode 100644 easy_my_coop_document/models/__init__.py delete mode 100644 easy_my_coop_document/models/document.py delete mode 100644 easy_my_coop_document/security/ir.model.access.csv delete mode 100644 easy_my_coop_document/views/easy_my_coop_document_menu.xml delete mode 100644 easy_my_coop_document/views/easy_my_coop_document_views.xml diff --git a/easy_my_coop_document/__init__.py b/easy_my_coop_document/__init__.py deleted file mode 100644 index 0650744..0000000 --- a/easy_my_coop_document/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import models diff --git a/easy_my_coop_document/__manifest__.py b/easy_my_coop_document/__manifest__.py deleted file mode 100644 index cd8e440..0000000 --- a/easy_my_coop_document/__manifest__.py +++ /dev/null @@ -1,35 +0,0 @@ - -# Copyright 2018 Rémy Taymans -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -{ - # migrate in v12 and isolate from emc - # add manager group or use relevant existing group - # add ir.model.access rules for that user - 'name': 'Easy My Coop Document', - - 'summary': """ - Manage the documents of your cooperative. - """, - 'description': """ - """, - - 'author': 'Rémy Taymans', - 'license': 'AGPL-3', - 'version': '12.0.1.0.0', - 'website': "https://github.com/coopiteasy/vertical-cooperative", - - 'category': 'Cooperative Management', - - 'depends': [ - 'base', - 'web', - 'mail', - ], - - 'data': [ - 'security/ir.model.access.csv', - 'views/easy_my_coop_document_menu.xml', - 'views/easy_my_coop_document_views.xml', - ] -} diff --git a/easy_my_coop_document/models/__init__.py b/easy_my_coop_document/models/__init__.py deleted file mode 100644 index 9c01ea2..0000000 --- a/easy_my_coop_document/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import document diff --git a/easy_my_coop_document/models/document.py b/easy_my_coop_document/models/document.py deleted file mode 100644 index 10b7fe8..0000000 --- a/easy_my_coop_document/models/document.py +++ /dev/null @@ -1,80 +0,0 @@ - -# Copyright 2018 Rémy Taymans -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - - -from odoo import models, fields, api - - -class Document(models.Model): - _name = 'easy_my_coop.document' - _description = "Document" - _order = 'document_date desc, name' - _inherit = 'mail.thread' - - name = fields.Char("Name", required=True) - description = fields.Text("Description") - document = fields.Binary('Document', attachment=True, required=True) - filename = fields.Char("Document File Name") - mimetype = fields.Char("Mime-Type", compute='_mimetype') - file_size = fields.Integer("File Size", compute='_file_size') - document_date = fields.Date("Document Date", - default=fields.Date.today()) - category = fields.Many2one('easy_my_coop.document.category', - string="Category") - published = fields.Boolean("Published?") - publication_date = fields.Datetime("Publication Date", - compute='_publication_date', - store=True) - public = fields.Boolean("Public?") - - @api.depends('document') - def _mimetype(self): - for doc in self: - attachment_mgr = self.env['ir.attachment'].sudo() - attachment = attachment_mgr.search_read( - [('res_model', '=', self._name), - ('res_id', '=', doc.id), - ('res_field', '=', 'document')], - fields=['mimetype', 'file_size'], - limit=1, - )[0] - doc.mimetype = attachment['mimetype'] - - @api.depends('document') - def _file_size(self): - for doc in self: - attachment_mgr = self.env['ir.attachment'].sudo() - attachment = attachment_mgr.search_read( - [('res_model', '=', self._name), - ('res_id', '=', doc.id), - ('res_field', '=', 'document')], - fields=['mimetype', 'file_size'], - limit=1, - )[0] - doc.file_size = attachment['file_size'] - - @api.depends('published') - def _publication_date(self): - for doc in self: - if doc.published and not doc.publication_date: - doc.publication_date = fields.Datetime.now() - if not doc.published: - doc.publication_date = False - - -class Category(models.Model): - _name = 'easy_my_coop.document.category' - _description = "Category" - _order = 'name' - - name = fields.Char("Name", required=True) - description = fields.Text("Description") - parent_id = fields.Many2one('easy_my_coop.document.category', - string="Parent Category") - child_ids = fields.One2many('easy_my_coop.document.category', - 'parent_id', - string="Child Categories") - document_ids = fields.One2many('easy_my_coop.document', - 'category', - string="Documents") diff --git a/easy_my_coop_document/security/ir.model.access.csv b/easy_my_coop_document/security/ir.model.access.csv deleted file mode 100644 index 3c91422..0000000 --- a/easy_my_coop_document/security/ir.model.access.csv +++ /dev/null @@ -1,5 +0,0 @@ -id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink -access_easy_my_coop_document_user_group,access_easy_my_coop_document,model_easy_my_coop_document,base.group_user,1,0,0,0 -access_easy_my_coop_document_category_user_group,access_easy_my_coop_document_category,model_easy_my_coop_document_category,base.group_user,1,0,0,0 -access_easy_my_coop_document_manager,access_easy_my_coop_document,model_easy_my_coop_document,,1,1,1,1 -access_easy_my_coop_document_category_manager,access_easy_my_coop_document_category,model_easy_my_coop_document_category,,1,1,1,1 diff --git a/easy_my_coop_document/views/easy_my_coop_document_menu.xml b/easy_my_coop_document/views/easy_my_coop_document_menu.xml deleted file mode 100644 index 4039aca..0000000 --- a/easy_my_coop_document/views/easy_my_coop_document_menu.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/easy_my_coop_document/views/easy_my_coop_document_views.xml b/easy_my_coop_document/views/easy_my_coop_document_views.xml deleted file mode 100644 index c926af5..0000000 --- a/easy_my_coop_document/views/easy_my_coop_document_views.xml +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - Document Form - easy_my_coop.document - -
- -
-
- - - - - - - - - - - - - - - - -
- -
- - -
-
-
-
- - - - Document Tree - easy_my_coop.document - - - - - - - - - - - - - - - - - Document Search - easy_my_coop.document - - - - - - - - - - - - - - Category Form - easy_my_coop.document.category - -
- -
-
- - - - -
-
-
-
- - - - Category Tree - easy_my_coop.document.category - - - - - - - - - - - - Category Search - easy_my_coop.document.category - - - - - - - - -
-
diff --git a/easy_my_coop_website_document/__manifest__.py b/easy_my_coop_website_document/__manifest__.py index 5f3ee44..9abe409 100644 --- a/easy_my_coop_website_document/__manifest__.py +++ b/easy_my_coop_website_document/__manifest__.py @@ -7,7 +7,7 @@ "version": "12.0.1.0.0", 'depends': [ 'website', - 'easy_my_coop_document', + 'document_hosting', ], 'author': 'Coop IT Easy SCRLfs', 'license': 'AGPL-3', diff --git a/easy_my_coop_website_document/controllers/main.py b/easy_my_coop_website_document/controllers/main.py index c4622e5..ac66af8 100644 --- a/easy_my_coop_website_document/controllers/main.py +++ b/easy_my_coop_website_document/controllers/main.py @@ -18,7 +18,7 @@ class DocumentWebsite(http.Controller): @http.route('/documents/', auth='public', website=True) def get_document(self, oid=-1): """Render a http response for a document""" - document_mgr = request.env['easy_my_coop.document'] + document_mgr = request.env['document_hosting.document'] doc = document_mgr.sudo().browse(oid) ir_http_mgr = request.env['ir.http'] status, headers, content = ir_http_mgr.sudo().binary_content( @@ -75,7 +75,7 @@ class DocumentWebsite(http.Controller): domains.append(('document_date', '<', date_end)) return { 'archive_groups': self._get_archive_groups( - 'easy_my_coop.document', + 'document_hosting.document', domains, fields=['name', 'document_date'], groupby='document_date', @@ -120,8 +120,8 @@ class DocumentWebsite(http.Controller): def _data_tree(self, category=None): """Return a tree with categories and documents in it""" - category_mgr = request.env['easy_my_coop.document.category'] - document_mgr = request.env['easy_my_coop.document'] + category_mgr = request.env['document_hosting.document.category'] + document_mgr = request.env['document_hosting.document'] if category: categories = category.child_ids.sorted( key=lambda r: r.name