mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-25 01:48:41 -06:00
[IMP] : black, isort, prettier
This commit is contained in:
parent
55f8f28e62
commit
23114febd1
@ -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",
|
||||
],
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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]})
|
||||
|
@ -1,9 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2020 ACSONE SA/NV
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record model="ir.model.access" id="ir_attachment_category_user">
|
||||
<field name="name">Attachment Category User</field>
|
||||
<field name="model_id" ref="model_ir_attachment_category" />
|
||||
@ -13,5 +11,4 @@
|
||||
<field name="perm_write" eval="1" />
|
||||
<field name="perm_unlink" eval="1" />
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
@ -1,9 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2020 ACSONE SA/NV
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record model="ir.ui.view" id="ir_attachment_form_view">
|
||||
<field name="name">ir.attachment.form (in attachment_category)</field>
|
||||
<field name="model">ir.attachment</field>
|
||||
@ -14,7 +12,6 @@
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="ir_attachment_search_view">
|
||||
<field name="name">ir.attachment.search (in attachment_category)</field>
|
||||
<field name="model">ir.attachment</field>
|
||||
@ -25,7 +22,6 @@
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="ir_attachment_tree_view">
|
||||
<field name="name">ir.attachment.tree (in attachment_category)</field>
|
||||
<field name="model">ir.attachment</field>
|
||||
@ -36,5 +32,4 @@
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
@ -1,9 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2020 ACSONE SA/NV
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record model="ir.ui.view" id="ir_attachment_category_form_view">
|
||||
<field name="name">ir.attachment.category.form (in document_category)</field>
|
||||
<field name="model">ir.attachment.category</field>
|
||||
@ -14,7 +12,12 @@
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button name="action_attachment_view" type="object" class="oe_stat_button" icon="fa-align-justify">
|
||||
<button
|
||||
name="action_attachment_view"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
icon="fa-align-justify"
|
||||
>
|
||||
<field name="attachment_count" />
|
||||
</button>
|
||||
</div>
|
||||
@ -26,7 +29,6 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="ir_attachment_category_search_view">
|
||||
<field name="name">ir.attachment.category.search (in document_category)</field>
|
||||
<field name="model">ir.attachment.category</field>
|
||||
@ -36,7 +38,6 @@
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="ir_attachment_category_tree_view">
|
||||
<field name="name">ir.attachment.category.tree (in document_category)</field>
|
||||
<field name="model">ir.attachment.category</field>
|
||||
@ -46,7 +47,6 @@
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="ir_attachment_category_act_window">
|
||||
<field name="name">Attachment Categories</field>
|
||||
<field name="res_model">ir.attachment.category</field>
|
||||
@ -60,12 +60,10 @@
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.menu" id="ir_attachment_category_menu">
|
||||
<field name="name">Attachment Categories</field>
|
||||
<field name="parent_id" ref="base.next_id_9" />
|
||||
<field name="action" ref="ir_attachment_category_act_window" />
|
||||
<field name="sequence" eval="16" />
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
Loading…
Reference in New Issue
Block a user