mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-18 10:52:03 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,5 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_cause
|
||||
from . import test_origin
|
||||
from . import test_nonconformity
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
# 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 exceptions
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestModelCause(common.TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.record = cls.env["mgmtsystem.nonconformity.cause"].create(
|
||||
{"name": "TestCause"}
|
||||
)
|
||||
cls.record2 = cls.env["mgmtsystem.nonconformity.cause"].create(
|
||||
{"name": "test2", "parent_id": cls.record.id}
|
||||
)
|
||||
cls.record3 = cls.env["mgmtsystem.nonconformity.cause"].create(
|
||||
{"name": "test3", "parent_id": cls.record2.id}
|
||||
)
|
||||
|
||||
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_recursion(self):
|
||||
parent = self.env["mgmtsystem.nonconformity.cause"].create(
|
||||
{"name": "ParentCause"}
|
||||
)
|
||||
child = self.env["mgmtsystem.nonconformity.cause"].create(
|
||||
{"name": "ChildCause", "parent_id": parent.id}
|
||||
)
|
||||
# no recursion
|
||||
with self.assertRaises(exceptions.UserError), self.cr.savepoint():
|
||||
parent.write({"parent_id": child.id})
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
# Copyright (C) 2010 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestModelNonConformity(common.TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.nc_model = cls.env["mgmtsystem.nonconformity"]
|
||||
cls.partner = cls.env["res.partner"].search([])[0]
|
||||
cls.nc_test = cls.nc_model.create(
|
||||
{
|
||||
"partner_id": cls.partner.id,
|
||||
"manager_user_id": cls.env.user.id,
|
||||
"description": "description",
|
||||
"responsible_user_id": cls.env.user.id,
|
||||
}
|
||||
)
|
||||
action_vals = {"name": "An Action", "type_action": "immediate"}
|
||||
action1 = cls.nc_model.action_ids.create(action_vals)
|
||||
cls.nc_test.immediate_action_id = action1
|
||||
|
||||
def test_stage_group(self):
|
||||
"""Group by Stage shows all stages"""
|
||||
group_stages = self.nc_test.read_group(
|
||||
domain=[], fields=["stage_id"], groupby=["stage_id"]
|
||||
)
|
||||
num_stages = len(self.nc_model.stage_id.search([]))
|
||||
self.assertEqual(len(group_stages), num_stages)
|
||||
|
||||
def test_reset_kanban_state(self):
|
||||
"""Reset Kanban State on Stage change"""
|
||||
self.nc_test.kanban_state = "done"
|
||||
self.nc_test.stage_id = self.env.ref("mgmtsystem_nonconformity.stage_analysis")
|
||||
self.assertEqual(self.nc_test.kanban_state, "normal")
|
||||
|
||||
def test_open_validation(self):
|
||||
"""Don't allow approving/In Progress action comments"""
|
||||
open_stage = self.env.ref("mgmtsystem_nonconformity.stage_open")
|
||||
with self.assertRaises(ValidationError):
|
||||
self.nc_test.stage_id = open_stage
|
||||
|
||||
def test_done_validation(self):
|
||||
"""Don't allow closing an NC without evaluation comments"""
|
||||
done_stage = self.env.ref("mgmtsystem_nonconformity.stage_done")
|
||||
self.nc_test.action_comments = "OK!"
|
||||
with self.assertRaises(ValidationError):
|
||||
self.nc_test.stage_id = done_stage
|
||||
|
||||
def test_done_actions_validation(self):
|
||||
"""Don't allow closing an NC with open actions"""
|
||||
done_stage = self.env.ref("mgmtsystem_nonconformity.stage_done")
|
||||
self.nc_test.immediate_action_id.stage_id = self.env.ref(
|
||||
"mgmtsystem_action.stage_open"
|
||||
)
|
||||
self.nc_test.evaluation_comments = "OK!"
|
||||
with self.assertRaises(ValidationError):
|
||||
self.nc_test.stage_id = done_stage
|
||||
|
||||
def test_state_transition(self):
|
||||
"""Close and reopen Nonconformity"""
|
||||
self.nc_test.action_comments = "OK!"
|
||||
self.nc_test.stage_id = self.env.ref("mgmtsystem_nonconformity.stage_open")
|
||||
self.assertEqual(
|
||||
self.nc_test.immediate_action_id.stage_id,
|
||||
self.env.ref("mgmtsystem_action.stage_open"),
|
||||
"Plan Approval starts Actions",
|
||||
)
|
||||
|
||||
self.nc_test.immediate_action_id.stage_id = self.env.ref(
|
||||
"mgmtsystem_action.stage_open"
|
||||
)
|
||||
self.nc_test.evaluation_comments = "OK!"
|
||||
self.nc_test.immediate_action_id.stage_id = self.env.ref(
|
||||
"mgmtsystem_action.stage_close"
|
||||
)
|
||||
self.nc_test.stage_id = self.env.ref("mgmtsystem_nonconformity.stage_done")
|
||||
self.assertEqual(self.nc_test.state, "done")
|
||||
self.assertTrue(self.nc_test.closing_date, "Set close date on Done")
|
||||
|
||||
self.nc_test.stage_id = self.env.ref("mgmtsystem_nonconformity.stage_open")
|
||||
self.assertEqual(self.nc_test.state, "open")
|
||||
self.assertFalse(self.nc_test.closing_date, "Reset close date on reopen")
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
# Copyright (C) 2010 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestModelOrigin(common.TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.record = cls.env["mgmtsystem.nonconformity.origin"].create(
|
||||
{"name": "TestOrigin"}
|
||||
)
|
||||
cls.record2 = cls.env["mgmtsystem.nonconformity.origin"].create(
|
||||
{"name": "test2", "parent_id": cls.record.id}
|
||||
)
|
||||
cls.record3 = cls.env["mgmtsystem.nonconformity.origin"].create(
|
||||
{"name": "test3", "parent_id": cls.record2.id}
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
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.record3.name_get()
|
||||
self.assertEqual(name_assoc[0][1], "TestOrigin / test2 / test3")
|
||||
self.assertEqual(name_assoc[0][0], self.record3.id)
|
||||
Loading…
Add table
Add a link
Reference in a new issue