diff --git a/document_page_tag/__manifest__.py b/document_page_tag/__manifest__.py index e7edb30c..10c9c1f6 100644 --- a/document_page_tag/__manifest__.py +++ b/document_page_tag/__manifest__.py @@ -9,13 +9,11 @@ "category": "Knowledge Management", "summary": "Allows you to assign tags or keywords to pages and search for " "them afterwards", - "depends": [ - 'document_page', - ], + "depends": ["document_page",], "data": [ "views/document_page_tag.xml", "views/document_page.xml", - 'security/ir.model.access.csv', + "security/ir.model.access.csv", ], "installable": True, } diff --git a/document_page_tag/models/document_page.py b/document_page_tag/models/document_page.py index 04e4bb87..90ace153 100644 --- a/document_page_tag/models/document_page.py +++ b/document_page_tag/models/document_page.py @@ -1,9 +1,9 @@ # Copyright 2015-2018 Therp BV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import models, fields +from odoo import fields, models class DocumentPage(models.Model): - _inherit = 'document.page' + _inherit = "document.page" - tag_ids = fields.Many2many('document.page.tag', string='Keywords') + tag_ids = fields.Many2many("document.page.tag", string="Keywords") diff --git a/document_page_tag/models/document_page_tag.py b/document_page_tag/models/document_page_tag.py index 3fd759d2..dc2d9698 100644 --- a/document_page_tag/models/document_page_tag.py +++ b/document_page_tag/models/document_page_tag.py @@ -1,24 +1,24 @@ # Copyright 2015-2018 Therp BV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import api, models, fields +from odoo import api, fields, models class DocumentPageTag(models.Model): - _name = 'document.page.tag' - _description = 'A keyword for document pages' + _name = "document.page.tag" + _description = "A keyword for document pages" name = fields.Char(required=True, translate=True) - color = fields.Integer(string='Color Index') + color = fields.Integer(string="Color Index") active = fields.Boolean(default=True) _sql_constraints = [ - ('unique_name', 'unique(name)', 'Tags must me unique'), + ("unique_name", "unique(name)", "Tags must me unique"), ] @api.model def create(self, vals): """Be nice when trying to create duplicates""" - existing = self.search([('name', '=ilike', vals['name'])], limit=1) + existing = self.search([("name", "=ilike", vals["name"])], limit=1) if existing: return existing return super(DocumentPageTag, self).create(vals) diff --git a/document_page_tag/tests/test_document_page_tag.py b/document_page_tag/tests/test_document_page_tag.py index 2f4e4f00..34e10a67 100644 --- a/document_page_tag/tests/test_document_page_tag.py +++ b/document_page_tag/tests/test_document_page_tag.py @@ -1,21 +1,20 @@ # Copyright 2015-2018 Therp BV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from psycopg2 import IntegrityError + from odoo.tests.common import TransactionCase from odoo.tools.misc import mute_logger class TestDocumentPageTag(TransactionCase): def test_document_page_tag(self): - testtag = self.env['document.page.tag'].name_create('test') + testtag = self.env["document.page.tag"].name_create("test") # check we're charitable on duplicates self.assertEqual( - testtag, self.env['document.page.tag'].name_create('Test'), + testtag, self.env["document.page.tag"].name_create("Test"), ) # check we can't create nonunique tags with self.assertRaises(IntegrityError): - with mute_logger('odoo.sql_db'): - testtag2 = self.env['document.page.tag'].create({ - 'name': 'test2', - }) - testtag2.write({'name': 'test'}) + with mute_logger("odoo.sql_db"): + testtag2 = self.env["document.page.tag"].create({"name": "test2",}) + testtag2.write({"name": "test"}) diff --git a/document_page_tag/views/document_page.xml b/document_page_tag/views/document_page.xml index e067fb52..e178fb06 100644 --- a/document_page_tag/views/document_page.xml +++ b/document_page_tag/views/document_page.xml @@ -1,4 +1,4 @@ - + @@ -6,7 +6,11 @@ - + @@ -24,14 +28,16 @@ document_page.tags.tree document.page - + tree child_ids - + diff --git a/document_page_tag/views/document_page_tag.xml b/document_page_tag/views/document_page_tag.xml index 2d92212c..936fdb01 100644 --- a/document_page_tag/views/document_page_tag.xml +++ b/document_page_tag/views/document_page_tag.xml @@ -5,8 +5,12 @@ document.page.tag - - + + @@ -19,14 +23,23 @@
-
@@ -55,11 +68,12 @@ form - +