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).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Atachment Category',
|
"name": "Atachment Category",
|
||||||
'summary': """
|
"summary": """
|
||||||
Adds a document category to help classification""",
|
Adds a document category to help classification""",
|
||||||
'version': '12.0.1.0.0',
|
"version": "12.0.1.0.0",
|
||||||
'license': 'AGPL-3',
|
"license": "AGPL-3",
|
||||||
'author': 'ACSONE SA/NV,Odoo Community Association (OCA)',
|
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
|
||||||
'depends': [
|
"depends": ["base",],
|
||||||
"base",
|
"data": [
|
||||||
],
|
"views/ir_attachment.xml",
|
||||||
'data': [
|
"security/ir_attachment_category.xml",
|
||||||
'views/ir_attachment.xml',
|
"views/ir_attachment_category.xml",
|
||||||
'security/ir_attachment_category.xml',
|
|
||||||
'views/ir_attachment_category.xml',
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ from odoo import fields, models
|
|||||||
|
|
||||||
class IrAttachment(models.Model):
|
class IrAttachment(models.Model):
|
||||||
|
|
||||||
_inherit = 'ir.attachment'
|
_inherit = "ir.attachment"
|
||||||
|
|
||||||
category_ids = fields.Many2many(
|
category_ids = fields.Many2many(
|
||||||
comodel_name="ir.attachment.category",
|
comodel_name="ir.attachment.category",
|
||||||
|
@ -6,28 +6,20 @@ from odoo import api, fields, models
|
|||||||
|
|
||||||
class IrAttachmentCategory(models.Model):
|
class IrAttachmentCategory(models.Model):
|
||||||
|
|
||||||
_name = 'ir.attachment.category'
|
_name = "ir.attachment.category"
|
||||||
_description = 'Attachment Category'
|
_description = "Attachment Category"
|
||||||
_parent_store = True
|
_parent_store = True
|
||||||
|
|
||||||
name = fields.Char()
|
name = fields.Char()
|
||||||
display_name = fields.Char(
|
display_name = fields.Char(compute="_compute_display_name", store=True,)
|
||||||
compute="_compute_display_name",
|
parent_id = fields.Many2one("ir.attachment.category",)
|
||||||
store=True,
|
|
||||||
)
|
|
||||||
parent_id = fields.Many2one(
|
|
||||||
"ir.attachment.category",
|
|
||||||
)
|
|
||||||
parent_path = fields.Char(index=True)
|
parent_path = fields.Char(index=True)
|
||||||
attachment_ids = fields.Many2many(
|
attachment_ids = fields.Many2many(
|
||||||
compute="_compute_attachment_count",
|
compute="_compute_attachment_count", comodel_name="ir.attachment"
|
||||||
comodel_name="ir.attachment"
|
|
||||||
)
|
|
||||||
attachment_count = fields.Integer(
|
|
||||||
compute="_compute_attachment_count",
|
|
||||||
)
|
)
|
||||||
|
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):
|
def _compute_display_name(self):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -35,8 +27,10 @@ class IrAttachmentCategory(models.Model):
|
|||||||
"""
|
"""
|
||||||
for category in self:
|
for category in self:
|
||||||
if category.parent_id.display_name:
|
if category.parent_id.display_name:
|
||||||
category.display_name = '%s/%s' % (
|
category.display_name = "{}/{}".format(
|
||||||
category.parent_id.display_name, category.name)
|
category.parent_id.display_name,
|
||||||
|
category.name,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
category.display_name = category.name
|
category.display_name = category.name
|
||||||
|
|
||||||
@ -45,16 +39,16 @@ class IrAttachmentCategory(models.Model):
|
|||||||
category_obj = self.env["ir.attachment.category"]
|
category_obj = self.env["ir.attachment.category"]
|
||||||
attachment_obj = self.env["ir.attachment"]
|
attachment_obj = self.env["ir.attachment"]
|
||||||
for category in self:
|
for category in self:
|
||||||
child_categories = category_obj.search([
|
child_categories = category_obj.search([("id", "child_of", category.id)])
|
||||||
("id", "child_of", category.id)])
|
attachment_ids = attachment_obj.search(
|
||||||
attachment_ids = attachment_obj.search([
|
[("category_ids", "in", child_categories.ids)]
|
||||||
("category_ids", "in", child_categories.ids)])
|
)
|
||||||
category.attachment_ids = attachment_ids
|
category.attachment_ids = attachment_ids
|
||||||
category.attachment_count = len(attachment_ids)
|
category.attachment_count = len(attachment_ids)
|
||||||
|
|
||||||
def action_attachment_view(self):
|
def action_attachment_view(self):
|
||||||
self.ensure_one()
|
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)]
|
action["domain"] = [("category_ids", "child_of", self.id)]
|
||||||
context = self.env.context.copy()
|
context = self.env.context.copy()
|
||||||
context.update({"default_category_ids": [self.id]})
|
context.update({"default_category_ids": [self.id]})
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<!-- Copyright 2020 ACSONE SA/NV
|
<!-- Copyright 2020 ACSONE SA/NV
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record model="ir.model.access" id="ir_attachment_category_user">
|
<record model="ir.model.access" id="ir_attachment_category_user">
|
||||||
<field name="name">Attachment Category User</field>
|
<field name="name">Attachment Category User</field>
|
||||||
<field name="model_id" ref="model_ir_attachment_category"/>
|
<field name="model_id" ref="model_ir_attachment_category" />
|
||||||
<field name="group_id" ref="base.group_user"/>
|
<field name="group_id" ref="base.group_user" />
|
||||||
<field name="perm_read" eval="1"/>
|
<field name="perm_read" eval="1" />
|
||||||
<field name="perm_create" eval="1"/>
|
<field name="perm_create" eval="1" />
|
||||||
<field name="perm_write" eval="1"/>
|
<field name="perm_write" eval="1" />
|
||||||
<field name="perm_unlink" eval="1"/>
|
<field name="perm_unlink" eval="1" />
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
@ -1,40 +1,35 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<!-- Copyright 2020 ACSONE SA/NV
|
<!-- Copyright 2020 ACSONE SA/NV
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="ir_attachment_form_view">
|
<record model="ir.ui.view" id="ir_attachment_form_view">
|
||||||
<field name="name">ir.attachment.form (in attachment_category)</field>
|
<field name="name">ir.attachment.form (in attachment_category)</field>
|
||||||
<field name="model">ir.attachment</field>
|
<field name="model">ir.attachment</field>
|
||||||
<field name="inherit_id" ref="base.view_attachment_form"/>
|
<field name="inherit_id" ref="base.view_attachment_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="type" position="after">
|
<field name="type" position="after">
|
||||||
<field name="category_ids" widget="many2many_tags"/>
|
<field name="category_ids" widget="many2many_tags" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="ir_attachment_search_view">
|
<record model="ir.ui.view" id="ir_attachment_search_view">
|
||||||
<field name="name">ir.attachment.search (in attachment_category)</field>
|
<field name="name">ir.attachment.search (in attachment_category)</field>
|
||||||
<field name="model">ir.attachment</field>
|
<field name="model">ir.attachment</field>
|
||||||
<field name="inherit_id" ref="base.view_attachment_search"/>
|
<field name="inherit_id" ref="base.view_attachment_search" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="type" position="after">
|
<field name="type" position="after">
|
||||||
<field name="category_ids"/>
|
<field name="category_ids" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="ir_attachment_tree_view">
|
<record model="ir.ui.view" id="ir_attachment_tree_view">
|
||||||
<field name="name">ir.attachment.tree (in attachment_category)</field>
|
<field name="name">ir.attachment.tree (in attachment_category)</field>
|
||||||
<field name="model">ir.attachment</field>
|
<field name="model">ir.attachment</field>
|
||||||
<field name="inherit_id" ref="base.view_attachment_tree"/>
|
<field name="inherit_id" ref="base.view_attachment_tree" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="type" position="after">
|
<field name="type" position="after">
|
||||||
<field name="category_ids"/>
|
<field name="category_ids" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<!-- Copyright 2020 ACSONE SA/NV
|
<!-- Copyright 2020 ACSONE SA/NV
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="ir_attachment_category_form_view">
|
<record model="ir.ui.view" id="ir_attachment_category_form_view">
|
||||||
<field name="name">ir.attachment.category.form (in document_category)</field>
|
<field name="name">ir.attachment.category.form (in document_category)</field>
|
||||||
<field name="model">ir.attachment.category</field>
|
<field name="model">ir.attachment.category</field>
|
||||||
@ -13,59 +11,59 @@
|
|||||||
<!-- TODO -->
|
<!-- TODO -->
|
||||||
</header>
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
<div class="oe_button_box" name="button_box">
|
<div class="oe_button_box" name="button_box">
|
||||||
<button name="action_attachment_view" type="object" class="oe_stat_button" icon="fa-align-justify">
|
<button
|
||||||
<field name="attachment_count"/>
|
name="action_attachment_view"
|
||||||
|
type="object"
|
||||||
|
class="oe_stat_button"
|
||||||
|
icon="fa-align-justify"
|
||||||
|
>
|
||||||
|
<field name="attachment_count" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<field name="name"/>
|
<field name="name" />
|
||||||
<field name="parent_id"/>
|
<field name="parent_id" />
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="ir_attachment_category_search_view">
|
<record model="ir.ui.view" id="ir_attachment_category_search_view">
|
||||||
<field name="name">ir.attachment.category.search (in document_category)</field>
|
<field name="name">ir.attachment.category.search (in document_category)</field>
|
||||||
<field name="model">ir.attachment.category</field>
|
<field name="model">ir.attachment.category</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search>
|
<search>
|
||||||
<field name="display_name"/>
|
<field name="display_name" />
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="ir_attachment_category_tree_view">
|
<record model="ir.ui.view" id="ir_attachment_category_tree_view">
|
||||||
<field name="name">ir.attachment.category.tree (in document_category)</field>
|
<field name="name">ir.attachment.category.tree (in document_category)</field>
|
||||||
<field name="model">ir.attachment.category</field>
|
<field name="model">ir.attachment.category</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree>
|
<tree>
|
||||||
<field name="display_name"/>
|
<field name="display_name" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.actions.act_window" id="ir_attachment_category_act_window">
|
<record model="ir.actions.act_window" id="ir_attachment_category_act_window">
|
||||||
<field name="name">Attachment Categories</field>
|
<field name="name">Attachment Categories</field>
|
||||||
<field name="res_model">ir.attachment.category</field>
|
<field name="res_model">ir.attachment.category</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
<p class="o_view_nocontent_smiling_face">
|
<p class="o_view_nocontent_smiling_face">
|
||||||
Create a new document
|
Create a new document
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Also you will find here all the related document categories.
|
Also you will find here all the related document categories.
|
||||||
</p>
|
</p>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.menu" id="ir_attachment_category_menu">
|
<record model="ir.ui.menu" id="ir_attachment_category_menu">
|
||||||
<field name="name">Attachment Categories</field>
|
<field name="name">Attachment Categories</field>
|
||||||
<field name="parent_id" ref="base.next_id_9"/>
|
<field name="parent_id" ref="base.next_id_9" />
|
||||||
<field name="action" ref="ir_attachment_category_act_window"/>
|
<field name="action" ref="ir_attachment_category_act_window" />
|
||||||
<field name="sequence" eval="16"/>
|
<field name="sequence" eval="16" />
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
Loading…
Reference in New Issue
Block a user