Skip to content

Commit

Permalink
[IMP] add tags
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Mar 17, 2024
1 parent 1fce83e commit de432b4
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 1 deletion.
1 change: 1 addition & 0 deletions automation_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions automation_oca/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from . import mail_thread
from . import link_tracker
from . import automation_filter
from . import automation_tag
1 change: 1 addition & 0 deletions automation_oca/models/automation_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 20 additions & 0 deletions automation_oca/models/automation_tag.py
Original file line number Diff line number Diff line change
@@ -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)

Check warning on line 16 in automation_oca/models/automation_tag.py

View check run for this annotation

Codecov / codecov/patch

automation_oca/models/automation_tag.py#L16

Added line #L16 was not covered by tests

name = fields.Char(required=True)
color = fields.Integer(default=lambda r: r._get_default_color())
active = fields.Boolean(default=True)
2 changes: 2 additions & 0 deletions automation_oca/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions automation_oca/views/automation_configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
</div>
<group>
<field name="active" invisible="1" />
<field
name="tag_ids"
widget="many2many_tags"
options="{'color_field': 'color'}"
/>
<field
name="model_id"
options="{'no_create_edit': True, 'no_open': True}"
Expand Down Expand Up @@ -427,6 +432,7 @@
<field name="arch" type="xml">
<search>
<field name="name" />
<field name="tag_ids" />
<separator />
<filter name="draft" string="Draft" domain="[('state','=', 'draft')]" />
<filter name="run" string="Run" domain="[('state','=', 'run')]" />
Expand All @@ -451,6 +457,11 @@
<div class="oe_kanban_card oe_kanban_global_click">
<div class="row">
<field name="name" class="o_text_overflow" />
<field
name="tag_ids"
widget="many2many_tags"
options="{'color_field': 'color'}"
/>
</div>
<div class="row mt8">
<div class="col-4 text-center text-black-50">
Expand Down
2 changes: 1 addition & 1 deletion automation_oca/views/automation_filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<field name="name">Filters</field>
<field name="parent_id" ref="automation_config_root_menu" />
<field name="action" ref="automation_filter_act_window" />
<field name="sequence" eval="16" />
<field name="sequence" eval="20" />
</record>

</odoo>
40 changes: 40 additions & 0 deletions automation_oca/views/automation_tag.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 Dixmit
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.ui.view" id="automation_tag_search_view">
<field name="model">automation.tag</field>
<field name="arch" type="xml">
<search>
<field name="name" />
</search>
</field>
</record>

<record model="ir.ui.view" id="automation_tag_tree_view">
<field name="model">automation.tag</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="name" />
<field name="color" />
</tree>
</field>
</record>

<record model="ir.actions.act_window" id="automation_tag_act_window">
<field name="name">Tags</field> <!-- TODO -->
<field name="res_model">automation.tag</field>
<field name="view_mode">tree,form</field>
<field name="domain">[]</field>
<field name="context">{}</field>
</record>

<record model="ir.ui.menu" id="automation_tag_menu">
<field name="name">Tags</field>
<field name="parent_id" ref="automation_config_root_menu" />
<field name="action" ref="automation_tag_act_window" />
<field name="sequence" eval="40" />
</record>

</odoo>

0 comments on commit de432b4

Please sign in to comment.