Skip to content

Commit

Permalink
[MIG] mgmtsystem_action: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimkhoi3010 committed Nov 20, 2024
1 parent 6764153 commit 0f27280
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 53 deletions.
2 changes: 1 addition & 1 deletion mgmtsystem_action/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Management System - Action",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"author": "Savoir-faire Linux, Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/management-system",
"license": "AGPL-3",
Expand Down
2 changes: 0 additions & 2 deletions mgmtsystem_action/data/automated_reminder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="model_id" ref="model_mgmtsystem_action" />
<field name="doall" eval="False" />
<field name="state">code</field>
<field name="code">model.process_reminder_queue()</field>
</record>
Expand Down
4 changes: 1 addition & 3 deletions mgmtsystem_action/demo/mgmtsystem_action.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
</record>

<record id="demo_improvement" model="mgmtsystem.action">
<field
name="name"
>Manage your quality management system with OpenERP :o)</field>
<field name="name">Manage your quality management system with Odoo :o)</field>
<field name="type_action">improvement</field>
</record>
</odoo>
6 changes: 3 additions & 3 deletions mgmtsystem_action/models/mgmtsystem_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from datetime import datetime, timedelta

from odoo import _, api, exceptions, fields, models
from odoo import api, exceptions, fields, models


class MgmtsystemAction(models.Model):
Expand Down Expand Up @@ -100,7 +100,7 @@ def _stage_groups(self, stages=None, domain=None, order=None):
@api.model_create_multi
def create(self, vals_list):
for one_vals in vals_list:
if one_vals.get("reference", _("New")) == _("New"):
if one_vals.get("reference", self.env._("New")) == self.env._("New"):
Sequence = self.env["ir.sequence"]
one_vals["reference"] = Sequence.next_by_code("mgmtsystem.action")
actions = super().create(vals_list)
Expand All @@ -113,7 +113,7 @@ def _check_stage_id(self):
# Do not allow to bring back actions to draft
if rec.date_open and rec.stage_id.is_starting:
raise exceptions.ValidationError(
_("We cannot bring back the action to draft stage")
self.env._("We cannot bring back the action to draft stage")
)
# If stage is changed, the action is opened
if not rec.date_open and not rec.stage_id.is_starting:
Expand Down
26 changes: 9 additions & 17 deletions mgmtsystem_action/reports/mgmtsystem_action_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ class MgmtsystemtActionReport(models.Model):
def _query(
self, with_clause="", fields="", where_clause="", groupby="", from_clause=""
):
with_ = ("WITH %s" % with_clause) if with_clause else ""
with_ = f"WITH {with_clause}" if with_clause else ""

select_ = (
"""
select_ = f"""
m.id,
m.date_closed as date_closed,
m.date_deadline as date_deadline,
Expand All @@ -56,27 +55,20 @@ def _query(
)/(3600*24) as age,
avg(extract('epoch' from (m.date_closed - m.date_deadline))
)/(3600*24) as number_of_exceedings_days,
count(*) AS number_of_actions %s
"""
% fields
)
count(*) AS number_of_actions {fields}"""

from_ = (
"""
from_ = f"""
mgmtsystem_action m
%s
"""
% from_clause
)
{from_clause}"""

where_ = ("WHERE %s" % where_clause) if where_clause else ""
where_ = f"WHERE {where_clause}" if where_clause else ""

groupby_ = """
groupby_ = f"""
m.user_id,m.system_id, m.stage_id, m.date_open,
m.create_date,m.type_action,m.date_deadline,
m.date_closed, m.id, m.number_of_days_to_open,
m.number_of_days_to_close %s
""" % (groupby)
m.number_of_days_to_close {groupby}
"""

return f"{with_} (SELECT {select_} FROM {from_} {where_} GROUP BY {groupby_})"

Expand Down
4 changes: 2 additions & 2 deletions mgmtsystem_action/tests/test_create_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime, timedelta
from unittest import mock

from odoo import _, exceptions
from odoo import exceptions
from odoo.tests import common


Expand Down Expand Up @@ -46,7 +46,7 @@ def test_create_action(self):
"type_action": "immediate",
}
)
self.assertEqual(new_record.reference, _("SampleReference"))
self.assertEqual(new_record.reference, self.env._("SampleReference"))

def test_case_close(self):
"""Test object close state."""
Expand Down
36 changes: 15 additions & 21 deletions mgmtsystem_action/views/mgmtsystem_action.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_mgmtsystem_action_tree" model="ir.ui.view">
<field name="name">mgmtsystem.action.tree</field>
<field name="name">mgmtsystem.action.list</field>
<field name="model">mgmtsystem.action</field>
<field name="type">tree</field>
<field name="type">list</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="reference" />
<field name="name" />
<field name="type_action" />
<field name="user_id" />
<field name="date_deadline" />
<field name="stage_id" />
<field name="company_id" groups="base.group_multi_company" />
</tree>
</list>
</field>
</record>

Expand Down Expand Up @@ -124,12 +124,14 @@
<sheet string="Action">
<div class="oe_title" modifiers="{}">
<h1 class="o_row" modifiers="{}">
<field name="priority" widget="priority" />
<field
name="name"
placeholder="Action title..."
required="1"
/>
<div class="d-flex">
<field name="priority" widget="priority" />
<field
name="name"
placeholder="Action title..."
required="1"
/>
</div>
</h1>
</div>
<group name="main">
Expand Down Expand Up @@ -176,15 +178,7 @@
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field
name="message_follower_ids"
widget="mail_followers"
groups="base.group_user"
/>
<field name="activity_ids" widget="mail_activity" />
<field name="message_ids" widget="mail_thread" />
</div>
<chatter />
</form>
</field>
</record>
Expand All @@ -208,7 +202,7 @@
<field name="message_needaction_counter" />
<templates>
<field name="date_deadline" />
<t t-name="kanban-box">
<t t-name="card">
<t t-set="type_action_color">#ffffff</t>
<t
t-if="record.type_action.raw_value and record.type_action.raw_value == 'immediate'"
Expand Down Expand Up @@ -337,7 +331,7 @@
<record id="open_mgmtsystem_action_list" model="ir.actions.act_window">
<field name="name">Actions</field>
<field name="res_model">mgmtsystem.action</field>
<field name="view_mode">kanban,tree,form</field>
<field name="view_mode">kanban,list,form</field>
<field name="context">{"search_default_my_actions": 1}</field>
</record>
</odoo>
6 changes: 3 additions & 3 deletions mgmtsystem_action/views/mgmtsystem_action_stage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@
<field name="name">Management System action Stage Tree</field>
<field name="model">mgmtsystem.action.stage</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="sequence" widget="handle" />
<field name="name" />
<field name="is_starting" />
<field name="is_ending" />
<field name="fold" />
</tree>
</list>
</field>
</record>

<record model="ir.actions.act_window" id="mgmtsystem_action_stage_action">
<field name="name">Stages</field>
<field name="res_model">mgmtsystem.action.stage</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="context">{}</field>
</record>
</odoo>
2 changes: 1 addition & 1 deletion mgmtsystem_action/views/mgmtsystem_action_tag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<record model="ir.actions.act_window" id="mgmtsystem_action_tag_action">
<field name="name">Tags</field>
<field name="res_model">mgmtsystem.action.tag</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="context">{}</field>
</record>
</odoo>

0 comments on commit 0f27280

Please sign in to comment.