From de432b44d5f24e34d8f297fba08466fd73bf9286 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Sun, 17 Mar 2024 12:12:38 +0100 Subject: [PATCH] [IMP] add tags --- automation_oca/__manifest__.py | 1 + automation_oca/models/__init__.py | 1 + .../models/automation_configuration.py | 1 + automation_oca/models/automation_tag.py | 20 ++++++++++ automation_oca/security/ir.model.access.csv | 2 + .../views/automation_configuration.xml | 11 +++++ automation_oca/views/automation_filter.xml | 2 +- automation_oca/views/automation_tag.xml | 40 +++++++++++++++++++ 8 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 automation_oca/models/automation_tag.py create mode 100644 automation_oca/views/automation_tag.xml diff --git a/automation_oca/__manifest__.py b/automation_oca/__manifest__.py index eca2dbf..a96ed82 100644 --- a/automation_oca/__manifest__.py +++ b/automation_oca/__manifest__.py @@ -21,6 +21,7 @@ "views/automation_configuration.xml", "views/link_tracker_clicks.xml", "views/automation_filter.xml", + "views/automation_tag.xml", "data/cron.xml", ], "assets": { diff --git a/automation_oca/models/__init__.py b/automation_oca/models/__init__.py index e75bca6..af3cd6e 100644 --- a/automation_oca/models/__init__.py +++ b/automation_oca/models/__init__.py @@ -6,3 +6,4 @@ from . import mail_thread from . import link_tracker from . import automation_filter +from . import automation_tag diff --git a/automation_oca/models/automation_configuration.py b/automation_oca/models/automation_configuration.py index 03dc278..9875ecc 100644 --- a/automation_oca/models/automation_configuration.py +++ b/automation_oca/models/automation_configuration.py @@ -16,6 +16,7 @@ class AutomationConfiguration(models.Model): name = fields.Char(required=True) active = fields.Boolean(default=True) + tag_ids = fields.Many2many("automation.tag") company_id = fields.Many2one("res.company") domain = fields.Char( required=True, default="[]", help="Filter to apply", compute="_compute_domain" diff --git a/automation_oca/models/automation_tag.py b/automation_oca/models/automation_tag.py new file mode 100644 index 0000000..1c8c490 --- /dev/null +++ b/automation_oca/models/automation_tag.py @@ -0,0 +1,20 @@ +# Copyright 2024 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from random import randint + +from odoo import api, fields, models + + +class AutomationTag(models.Model): + + _name = "automation.tag" + _description = "Automation Tag" + + @api.model + def _get_default_color(self): + return randint(1, 11) + + name = fields.Char(required=True) + color = fields.Integer(default=lambda r: r._get_default_color()) + active = fields.Boolean(default=True) diff --git a/automation_oca/security/ir.model.access.csv b/automation_oca/security/ir.model.access.csv index cde92a4..1146850 100644 --- a/automation_oca/security/ir.model.access.csv +++ b/automation_oca/security/ir.model.access.csv @@ -7,5 +7,7 @@ access_automation_record,Access Automation Record,model_automation_record,group_ manage_automation_record,Access Automation Record,model_automation_record,group_automation_manager,1,1,1,1 access_automation_filter,Access Automation filter,model_automation_filter,group_automation_user,1,0,0,0 manage_automation_filter,Access Automation filter,model_automation_filter,group_automation_manager,1,1,1,1 +access_automation_tag,Access Automation tag,model_automation_tag,group_automation_user,1,0,0,0 +manage_automation_tag,Access Automation tag,model_automation_tag,group_automation_manager,1,1,1,1 access_automation_record_activity,Access Automation Record Activity,model_automation_record_activity,group_automation_user,1,0,0,0 manage_automation_record_activity,Access Automation Record Activity,model_automation_record_activity,group_automation_manager,1,1,1,1 diff --git a/automation_oca/views/automation_configuration.xml b/automation_oca/views/automation_configuration.xml index 21d3b26..fd78711 100644 --- a/automation_oca/views/automation_configuration.xml +++ b/automation_oca/views/automation_configuration.xml @@ -68,6 +68,11 @@ + + @@ -451,6 +457,11 @@
+
diff --git a/automation_oca/views/automation_filter.xml b/automation_oca/views/automation_filter.xml index bba3ae6..0cbe9a1 100644 --- a/automation_oca/views/automation_filter.xml +++ b/automation_oca/views/automation_filter.xml @@ -59,7 +59,7 @@ Filters - + diff --git a/automation_oca/views/automation_tag.xml b/automation_oca/views/automation_tag.xml new file mode 100644 index 0000000..acd39b2 --- /dev/null +++ b/automation_oca/views/automation_tag.xml @@ -0,0 +1,40 @@ + + + + + + automation.tag + + + + + + + + + automation.tag + + + + + + + + + + Tags + automation.tag + tree,form + [] + {} + + + + Tags + + + + + +