diff --git a/attachment_category/__manifest__.py b/attachment_category/__manifest__.py index 36976887..54b7f376 100644 --- a/attachment_category/__manifest__.py +++ b/attachment_category/__manifest__.py @@ -2,18 +2,16 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Atachment Category', - 'summary': """ + "name": "Atachment Category", + "summary": """ Adds a document category to help classification""", - 'version': '12.0.1.0.0', - 'license': 'AGPL-3', - 'author': 'ACSONE SA/NV,Odoo Community Association (OCA)', - 'depends': [ - "base", - ], - 'data': [ - 'views/ir_attachment.xml', - 'security/ir_attachment_category.xml', - 'views/ir_attachment_category.xml', + "version": "12.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "depends": ["base",], + "data": [ + "views/ir_attachment.xml", + "security/ir_attachment_category.xml", + "views/ir_attachment_category.xml", ], } diff --git a/attachment_category/models/ir_attachment.py b/attachment_category/models/ir_attachment.py index 0251d80c..5c6f144f 100644 --- a/attachment_category/models/ir_attachment.py +++ b/attachment_category/models/ir_attachment.py @@ -6,7 +6,7 @@ from odoo import fields, models class IrAttachment(models.Model): - _inherit = 'ir.attachment' + _inherit = "ir.attachment" category_ids = fields.Many2many( comodel_name="ir.attachment.category", diff --git a/attachment_category/models/ir_attachment_category.py b/attachment_category/models/ir_attachment_category.py index da1c392d..dea59998 100644 --- a/attachment_category/models/ir_attachment_category.py +++ b/attachment_category/models/ir_attachment_category.py @@ -6,28 +6,20 @@ from odoo import api, fields, models class IrAttachmentCategory(models.Model): - _name = 'ir.attachment.category' - _description = 'Attachment Category' + _name = "ir.attachment.category" + _description = "Attachment Category" _parent_store = True name = fields.Char() - display_name = fields.Char( - compute="_compute_display_name", - store=True, - ) - parent_id = fields.Many2one( - "ir.attachment.category", - ) + display_name = fields.Char(compute="_compute_display_name", store=True,) + parent_id = fields.Many2one("ir.attachment.category",) parent_path = fields.Char(index=True) attachment_ids = fields.Many2many( - compute="_compute_attachment_count", - comodel_name="ir.attachment" - ) - attachment_count = fields.Integer( - compute="_compute_attachment_count", + compute="_compute_attachment_count", comodel_name="ir.attachment" ) + attachment_count = fields.Integer(compute="_compute_attachment_count",) - @api.depends('name', 'parent_id.display_name') + @api.depends("name", "parent_id.display_name") def _compute_display_name(self): """ @@ -35,8 +27,10 @@ class IrAttachmentCategory(models.Model): """ for category in self: if category.parent_id.display_name: - category.display_name = '%s/%s' % ( - category.parent_id.display_name, category.name) + category.display_name = "{}/{}".format( + category.parent_id.display_name, + category.name, + ) else: category.display_name = category.name @@ -45,16 +39,16 @@ class IrAttachmentCategory(models.Model): category_obj = self.env["ir.attachment.category"] attachment_obj = self.env["ir.attachment"] for category in self: - child_categories = category_obj.search([ - ("id", "child_of", category.id)]) - attachment_ids = attachment_obj.search([ - ("category_ids", "in", child_categories.ids)]) + child_categories = category_obj.search([("id", "child_of", category.id)]) + attachment_ids = attachment_obj.search( + [("category_ids", "in", child_categories.ids)] + ) category.attachment_ids = attachment_ids category.attachment_count = len(attachment_ids) def action_attachment_view(self): self.ensure_one() - action = self.env.ref('base.action_attachment').read()[0] + action = self.env.ref("base.action_attachment").read()[0] action["domain"] = [("category_ids", "child_of", self.id)] context = self.env.context.copy() context.update({"default_category_ids": [self.id]}) diff --git a/attachment_category/security/ir_attachment_category.xml b/attachment_category/security/ir_attachment_category.xml index ba18907c..354d0f54 100644 --- a/attachment_category/security/ir_attachment_category.xml +++ b/attachment_category/security/ir_attachment_category.xml @@ -1,17 +1,14 @@ - + - - Attachment Category User - - - - - - + + + + + + - diff --git a/attachment_category/views/ir_attachment.xml b/attachment_category/views/ir_attachment.xml index 43b78b0a..c61f047a 100644 --- a/attachment_category/views/ir_attachment.xml +++ b/attachment_category/views/ir_attachment.xml @@ -1,40 +1,35 @@ - + - - ir.attachment.form (in attachment_category) ir.attachment - + - + - ir.attachment.search (in attachment_category) ir.attachment - + - + - ir.attachment.tree (in attachment_category) ir.attachment - + - + - diff --git a/attachment_category/views/ir_attachment_category.xml b/attachment_category/views/ir_attachment_category.xml index 3392a330..37135529 100644 --- a/attachment_category/views/ir_attachment_category.xml +++ b/attachment_category/views/ir_attachment_category.xml @@ -1,9 +1,7 @@ - + - - ir.attachment.category.form (in document_category) ir.attachment.category @@ -13,59 +11,59 @@ -
-
- - + +
- ir.attachment.category.search (in document_category) ir.attachment.category - + - ir.attachment.category.tree (in document_category) ir.attachment.category - + - Attachment Categories ir.attachment.category tree,form -

+

Create a new document

-

+

Also you will find here all the related document categories.

-
+
- Attachment Categories - - - + + + -
diff --git a/setup/attachment_category/odoo/addons/attachment_category b/setup/attachment_category/odoo/addons/attachment_category new file mode 120000 index 00000000..c8c075cf --- /dev/null +++ b/setup/attachment_category/odoo/addons/attachment_category @@ -0,0 +1 @@ +../../../../attachment_category \ No newline at end of file diff --git a/setup/attachment_category/setup.py b/setup/attachment_category/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/attachment_category/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)