Skip to content

Commit

Permalink
[MIG] mgmtsystem_nonconformity: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgarRetes committed Sep 27, 2024
1 parent 5de4c45 commit d5d6245
Show file tree
Hide file tree
Showing 25 changed files with 122 additions and 142 deletions.
6 changes: 3 additions & 3 deletions mgmtsystem_nonconformity/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Management System - Nonconformity",
"version": "16.0.1.2.0",
"version": "17.0.1.0.0",
"author": "Savoir-faire Linux, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/management-system",
"license": "AGPL-3",
Expand Down Expand Up @@ -32,8 +32,8 @@
],
"assets": {
"web.assets_backend": [
"mgmtsystem_nonconformity/static/src/**/*.xml",
"mgmtsystem_nonconformity/static/src/**/*.js",
# "mgmtsystem_nonconformity/static/src/**/*.xml",
# "mgmtsystem_nonconformity/static/src/**/*.js",
],
},
"installable": True,
Expand Down
1 change: 0 additions & 1 deletion mgmtsystem_nonconformity/data/mail_message_subtype.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<!-- Not used at the moment. To use them override the _track_subtype method -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record id="badly_defined_need" model="mgmtsystem.nonconformity.cause">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record id="nc_origin_qc" model="mgmtsystem.nonconformity.origin">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record id="nonconformity_severity_maj" model="mgmtsystem.nonconformity.severity">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="stage_draft" model="mgmtsystem.nonconformity.stage">
<field name="name">Draft</field>
Expand Down
1 change: 0 additions & 1 deletion mgmtsystem_nonconformity/data/sequence.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record id="seq_mgmtsystem_nonconformity" model="ir.sequence">
Expand Down
1 change: 0 additions & 1 deletion mgmtsystem_nonconformity/demo/mgmtsystem_nonconformity.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="demo_nonconformity" model="mgmtsystem.nonconformity">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record id="demo_cause" model="mgmtsystem.nonconformity.cause">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record id="demo_origin" model="mgmtsystem.nonconformity.origin">
Expand Down
8 changes: 5 additions & 3 deletions mgmtsystem_nonconformity/models/mgmtsystem_nonconformity.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,12 @@ def _stage_groups(self, stages, domain, order):

@api.model
def _default_reference(self):
if self.env.context.get("active_model") and self.env.context.get("active_id"):
if self.env.context.get("mgmtsystem_nonconformity") and self.env.context.get(
"id"
):
return (
self.env[self.env.context["active_model"]]
.browse(self.env.context.get("active_id"))
self.env[self.env.context["mgmtsystem_nonconformity"]]
.browse(self.env.context.get("id"))
.exists()
.display_name
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2010 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo import api, fields, models


class MgmtsystemNonconformityCause(models.Model):
Expand All @@ -24,13 +24,12 @@ class MgmtsystemNonconformityCause(models.Model):
"mgmtsystem.nonconformity.cause", "parent_id", "Child Causes"
)
ref_code = fields.Char("Reference Code")
display_name = fields.Char(compute="_compute_display_name", recursive=True)

def name_get(self):
res = []
@api.depends("name", "parent_id.display_name")
def _compute_display_name(self):
for obj in self:
if obj.parent_id:
name = obj.parent_id.name_get()[0][1] + " / " + obj.name
obj.display_name = f"{obj.parent_id.display_name} / {obj.name}"
else:
name = obj.name
res.append((obj.id, name))
return res
obj.display_name = obj.name
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2010 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo import api, fields, models


class MgmtsystemNonconformityOrigin(models.Model):
Expand All @@ -24,11 +24,10 @@ class MgmtsystemNonconformityOrigin(models.Model):

active = fields.Boolean(default=True)

def name_get(self):
res = []
@api.depends("name", "parent_id.name")
def _compute_display_name(self):
for obj in self:
name = obj.name
if obj.parent_id:
name = obj.parent_id.name_get()[0][1] + " / " + name
res.append((obj.id, name))
return res
name = f"{obj.parent_id.display_name} / {name}"
obj.display_name = name
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<!-- Management System Non Conformity Report Pivot View -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<!-- Rule -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ registerPatch({
"mgmtsystem_nonconformity.open_mgmtsystem_nonconformity_thread_list",
{
additionalContext: {
active_id: this.thread.id,
active_model: this.thread.model,
id: this.thread.id,
mgmtsystem_nonconformity: this.thread.model,
},
}
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t
t-name="mgmtsystem_nonconformity.ChatterTopbar"
t-inherit="mail.ChatterTopbar"
t-inherit-mode="extension"
owl="1"
>
<xpath
expr="//button[hasclass('o_ChatterTopbar_buttonToggleAttachments')]"
Expand Down
27 changes: 15 additions & 12 deletions mgmtsystem_nonconformity/tests/test_cause.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ def test_create_cause(self):
self.assertNotEqual(self.record.id, 0)
self.assertNotEqual(self.record.id, None)

def test_name_get(self):
name_assoc = self.record.name_get()
self.assertEqual(name_assoc[0][1], "TestCause")
self.assertEqual(name_assoc[0][0], self.record.id)

name_assoc = self.record2.name_get()
self.assertEqual(name_assoc[0][1], "TestCause / test2")
self.assertEqual(name_assoc[0][0], self.record2.id)

name_assoc = self.record3.name_get()
self.assertEqual(name_assoc[0][1], "TestCause / test2 / test3")
self.assertEqual(name_assoc[0][0], self.record3.id)
def test_display_name(self):
name_assoc = self.record
name_assoc._compute_display_name()
self.assertEqual(name_assoc.display_name, "TestCause")
self.assertEqual(name_assoc.id, self.record.id)

name_assoc = self.record2
name_assoc._compute_display_name()
self.assertEqual(name_assoc.display_name, "TestCause / test2")
self.assertEqual(name_assoc.id, self.record2.id)

name_assoc = self.record3
name_assoc._compute_display_name()
self.assertEqual(name_assoc.display_name, "TestCause / test2 / test3")
self.assertEqual(name_assoc.id, self.record3.id)

def test_recursion(self):
parent = self.env["mgmtsystem.nonconformity.cause"].create(
Expand Down
23 changes: 13 additions & 10 deletions mgmtsystem_nonconformity/tests/test_origin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ def test_create_origin(self):
self.assertNotEqual(self.record.id, 0)
self.assertNotEqual(self.record.id, None)

def test_name_get(self):
name_assoc = self.record.name_get()
self.assertEqual(name_assoc[0][1], "TestOrigin")
self.assertEqual(name_assoc[0][0], self.record.id)
def test_display_name(self):
name_assoc = self.record
name_assoc._compute_display_name()
self.assertEqual(name_assoc.display_name, "TestOrigin")
self.assertEqual(name_assoc.id, self.record.id)

name_assoc = self.record2.name_get()
self.assertEqual(name_assoc[0][1], "TestOrigin / test2")
self.assertEqual(name_assoc[0][0], self.record2.id)
name_assoc = self.record2
name_assoc._compute_display_name()
self.assertEqual(name_assoc.display_name, "TestOrigin / test2")
self.assertEqual(name_assoc.id, self.record2.id)

name_assoc = self.record3.name_get()
self.assertEqual(name_assoc[0][1], "TestOrigin / test2 / test3")
self.assertEqual(name_assoc[0][0], self.record3.id)
name_assoc = self.record3
name_assoc._compute_display_name()
self.assertEqual(name_assoc.display_name, "TestOrigin / test2 / test3")
self.assertEqual(name_assoc.id, self.record3.id)
4 changes: 2 additions & 2 deletions mgmtsystem_nonconformity/views/mgmtsystem_action.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<!-- Actions: add link to NCs -->
Expand All @@ -14,7 +13,8 @@
name="nonconformity_ids"
colspan="4"
nolabel="1"
attrs="{'invisible':[('nonconformity_ids','=',False)]}"
invisible="nonconformity_ids == False"
readonly="1"
/>
</field>

Expand Down
1 change: 0 additions & 1 deletion mgmtsystem_nonconformity/views/mgmtsystem_cause.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Cause -->

Expand Down
Loading

0 comments on commit d5d6245

Please sign in to comment.