mirror of
https://github.com/OCA/knowledge.git
synced 2026-01-05 11:46:56 -06:00
[IMP] : black, isort, prettier
This commit is contained in:
@@ -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]})
|
||||
|
||||
Reference in New Issue
Block a user