odoo-addon-base-tier-validation 16.0.1.3.0__py3-none-any.whl → 16.0.1.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/base_tier_validation/README.rst +3 -1
- odoo/addons/base_tier_validation/__manifest__.py +1 -1
- odoo/addons/base_tier_validation/i18n/base_tier_validation.pot +46 -0
- odoo/addons/base_tier_validation/i18n/es.po +67 -1
- odoo/addons/base_tier_validation/i18n/es_MX.po +64 -0
- odoo/addons/base_tier_validation/i18n/fr.po +64 -0
- odoo/addons/base_tier_validation/i18n/it.po +118 -41
- odoo/addons/base_tier_validation/i18n/nl_NL.po +122 -37
- odoo/addons/base_tier_validation/i18n/sv.po +99 -32
- odoo/addons/base_tier_validation/i18n/tr.po +64 -0
- odoo/addons/base_tier_validation/i18n/zh_CN.po +64 -0
- odoo/addons/base_tier_validation/models/tier_definition.py +15 -0
- odoo/addons/base_tier_validation/models/tier_review.py +15 -3
- odoo/addons/base_tier_validation/models/tier_validation.py +86 -40
- odoo/addons/base_tier_validation/readme/CONTRIBUTORS.rst +2 -0
- odoo/addons/base_tier_validation/static/description/index.html +3 -2
- odoo/addons/base_tier_validation/static/src/xml/tier_review_template.xml +1 -1
- odoo/addons/base_tier_validation/templates/tier_validation_templates.xml +2 -1
- odoo/addons/base_tier_validation/tests/common.py +11 -4
- odoo/addons/base_tier_validation/tests/test_tier_validation.py +370 -0
- odoo/addons/base_tier_validation/tests/tier_validation_tester.py +1 -1
- odoo/addons/base_tier_validation/views/tier_definition_view.xml +4 -1
- {odoo_addon_base_tier_validation-16.0.1.3.0.dist-info → odoo_addon_base_tier_validation-16.0.1.5.1.dist-info}/METADATA +4 -2
- {odoo_addon_base_tier_validation-16.0.1.3.0.dist-info → odoo_addon_base_tier_validation-16.0.1.5.1.dist-info}/RECORD +26 -26
- {odoo_addon_base_tier_validation-16.0.1.3.0.dist-info → odoo_addon_base_tier_validation-16.0.1.5.1.dist-info}/WHEEL +1 -1
- {odoo_addon_base_tier_validation-16.0.1.3.0.dist-info → odoo_addon_base_tier_validation-16.0.1.5.1.dist-info}/top_level.txt +0 -0
@@ -325,9 +325,20 @@ class TierValidation(models.AbstractModel):
|
|
325
325
|
"reviewed_date": fields.Datetime.now(),
|
326
326
|
}
|
327
327
|
)
|
328
|
-
|
329
|
-
|
330
|
-
|
328
|
+
reviews_to_notify = user_reviews.filtered(
|
329
|
+
lambda r: r.definition_id.notify_on_accepted
|
330
|
+
)
|
331
|
+
if reviews_to_notify:
|
332
|
+
subscribe = "message_subscribe"
|
333
|
+
if hasattr(self, subscribe):
|
334
|
+
getattr(self, subscribe)(
|
335
|
+
partner_ids=reviews_to_notify.mapped("reviewer_ids")
|
336
|
+
.mapped("partner_id")
|
337
|
+
.ids
|
338
|
+
)
|
339
|
+
for review in reviews_to_notify:
|
340
|
+
rec = self.env[review.model].browse(review.res_id)
|
341
|
+
rec._notify_accepted_reviews()
|
331
342
|
|
332
343
|
def _get_requested_notification_subtype(self):
|
333
344
|
return "base_tier_validation.mt_tier_validation_requested"
|
@@ -384,7 +395,10 @@ class TierValidation(models.AbstractModel):
|
|
384
395
|
lambda l: l.sequence in sequences or l.approve_sequence_bypass
|
385
396
|
)
|
386
397
|
if self.has_comment:
|
387
|
-
|
398
|
+
user_reviews = reviews.filtered(
|
399
|
+
lambda r: r.status == "pending" and (self.env.user in r.reviewer_ids)
|
400
|
+
)
|
401
|
+
return self._add_comment("validate", user_reviews)
|
388
402
|
self._validate_tier(reviews)
|
389
403
|
self._update_counter({"review_deleted": True})
|
390
404
|
|
@@ -431,9 +445,21 @@ class TierValidation(models.AbstractModel):
|
|
431
445
|
"reviewed_date": fields.Datetime.now(),
|
432
446
|
}
|
433
447
|
)
|
434
|
-
|
435
|
-
|
436
|
-
|
448
|
+
|
449
|
+
reviews_to_notify = user_reviews.filtered(
|
450
|
+
lambda r: r.definition_id.notify_on_rejected
|
451
|
+
)
|
452
|
+
if reviews_to_notify:
|
453
|
+
subscribe = "message_subscribe"
|
454
|
+
if hasattr(self, subscribe):
|
455
|
+
getattr(self, subscribe)(
|
456
|
+
partner_ids=reviews_to_notify.mapped("reviewer_ids")
|
457
|
+
.mapped("partner_id")
|
458
|
+
.ids
|
459
|
+
)
|
460
|
+
for review in reviews_to_notify:
|
461
|
+
rec = self.env[review.model].browse(review.res_id)
|
462
|
+
rec._notify_rejected_review()
|
437
463
|
|
438
464
|
def _notify_requested_review_body(self):
|
439
465
|
return _("A review has been requested by %s.") % (self.env.user.name)
|
@@ -442,46 +468,49 @@ class TierValidation(models.AbstractModel):
|
|
442
468
|
subscribe = "message_subscribe"
|
443
469
|
post = "message_post"
|
444
470
|
if hasattr(self, post) and hasattr(self, subscribe):
|
445
|
-
for rec in self:
|
471
|
+
for rec in self.sudo():
|
446
472
|
users_to_notify = tier_reviews.filtered(
|
447
473
|
lambda r: r.definition_id.notify_on_create and r.res_id == rec.id
|
448
474
|
).mapped("reviewer_ids")
|
449
475
|
# Subscribe reviewers and notify
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
476
|
+
if len(users_to_notify) > 0:
|
477
|
+
getattr(rec, subscribe)(
|
478
|
+
partner_ids=users_to_notify.mapped("partner_id").ids
|
479
|
+
)
|
480
|
+
getattr(rec, post)(
|
481
|
+
subtype_xmlid=self._get_requested_notification_subtype(),
|
482
|
+
body=rec._notify_requested_review_body(),
|
483
|
+
)
|
484
|
+
|
485
|
+
def _prepare_tier_review_vals(self, definition, sequence):
|
486
|
+
return {
|
487
|
+
"model": self._name,
|
488
|
+
"res_id": self.id,
|
489
|
+
"definition_id": definition.id,
|
490
|
+
"requested_by": self.env.uid,
|
491
|
+
"sequence": sequence,
|
492
|
+
}
|
457
493
|
|
458
494
|
def request_validation(self):
|
459
495
|
td_obj = self.env["tier.definition"]
|
460
|
-
tr_obj =
|
496
|
+
tr_obj = self.env["tier.review"]
|
497
|
+
vals_list = []
|
461
498
|
for rec in self:
|
462
|
-
if rec._check_state_from_condition():
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
"model": self._name,
|
478
|
-
"res_id": rec.id,
|
479
|
-
"definition_id": td.id,
|
480
|
-
"sequence": sequence,
|
481
|
-
"requested_by": self.env.uid,
|
482
|
-
}
|
483
|
-
)
|
484
|
-
self._update_counter({"review_created": True})
|
499
|
+
if rec._check_state_from_condition() and rec.need_validation:
|
500
|
+
tier_definitions = td_obj.search(
|
501
|
+
[
|
502
|
+
("model", "=", self._name),
|
503
|
+
("company_id", "in", [False] + self.env.company.ids),
|
504
|
+
],
|
505
|
+
order="sequence desc",
|
506
|
+
)
|
507
|
+
sequence = 0
|
508
|
+
for td in tier_definitions:
|
509
|
+
if rec.evaluate_tier(td):
|
510
|
+
sequence += 1
|
511
|
+
vals_list.append(rec._prepare_tier_review_vals(td, sequence))
|
512
|
+
self._update_counter({"review_created": True})
|
513
|
+
created_trs = tr_obj.create(vals_list)
|
485
514
|
self._notify_review_requested(created_trs)
|
486
515
|
return created_trs
|
487
516
|
|
@@ -498,16 +527,33 @@ class TierValidation(models.AbstractModel):
|
|
498
527
|
|
499
528
|
def restart_validation(self):
|
500
529
|
for rec in self:
|
530
|
+
partners_to_notify_ids = False
|
501
531
|
if getattr(rec, self._state_field) in self._state_from:
|
502
532
|
to_update_counter = (
|
503
533
|
rec.mapped("review_ids").filtered(lambda a: a.status == "pending")
|
504
534
|
and True
|
505
535
|
or False
|
506
536
|
)
|
537
|
+
reviews_to_notify = rec.review_ids.filtered(
|
538
|
+
lambda r: r.definition_id.notify_on_restarted
|
539
|
+
)
|
540
|
+
if reviews_to_notify:
|
541
|
+
partners_to_notify_ids = (
|
542
|
+
reviews_to_notify.mapped("reviewer_ids")
|
543
|
+
.mapped("partner_id")
|
544
|
+
.ids
|
545
|
+
)
|
507
546
|
rec.mapped("review_ids").unlink()
|
508
547
|
if to_update_counter:
|
509
548
|
self._update_counter({"review_deleted": True})
|
510
|
-
|
549
|
+
if partners_to_notify_ids:
|
550
|
+
subscribe = "message_subscribe"
|
551
|
+
reviews_to_notify = rec.review_ids.filtered(
|
552
|
+
lambda r: r.definition_id.notify_on_restarted
|
553
|
+
)
|
554
|
+
if hasattr(self, subscribe):
|
555
|
+
getattr(self, subscribe)(partner_ids=partners_to_notify_ids)
|
556
|
+
rec._notify_restarted_review()
|
511
557
|
|
512
558
|
@api.model
|
513
559
|
def _update_counter(self, review_counter):
|
@@ -1,4 +1,3 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
1
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
2
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
3
|
<head>
|
@@ -367,7 +366,7 @@ ul.auto-toc {
|
|
367
366
|
!! This file is generated by oca-gen-addon-readme !!
|
368
367
|
!! changes will be overwritten. !!
|
369
368
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
370
|
-
!! source digest: sha256:
|
369
|
+
!! source digest: sha256:1b69f3df9b2f479b32acf8c146bb4837086a025d8914c2f773db9f6c4c9eab7a
|
371
370
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
372
371
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-ux/tree/16.0/base_tier_validation"><img alt="OCA/server-ux" src="https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-ux-16-0/server-ux-16-0-base_tier_validation"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-ux&target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
373
372
|
<p>Validating some operations is a common need across different areas in a company
|
@@ -563,6 +562,8 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|
563
562
|
<li>Pedro Gonzalez <<a class="reference external" href="mailto:pedro.gonzalez@pesol.es">pedro.gonzalez@pesol.es</a>></li>
|
564
563
|
<li>Kitti U. <<a class="reference external" href="mailto:kittiu@ecosoft.co.th">kittiu@ecosoft.co.th</a>></li>
|
565
564
|
<li>Saran Lim. <<a class="reference external" href="mailto:saranl@ecosoft.co.th">saranl@ecosoft.co.th</a>></li>
|
565
|
+
<li>Evan Soh <<a class="reference external" href="mailto:evan.soh@omnisoftsolution.com">evan.soh@omnisoftsolution.com</a>></li>
|
566
|
+
<li>Manuel Regidor <<a class="reference external" href="mailto:manuel.regidor@sygel.es">manuel.regidor@sygel.es</a>></li>
|
566
567
|
</ul>
|
567
568
|
</div>
|
568
569
|
<div class="section" id="maintainers">
|
@@ -50,7 +50,7 @@
|
|
50
50
|
class="btn-icon btn-danger"
|
51
51
|
icon="fa-thumbs-down"
|
52
52
|
/>
|
53
|
-
<br /><field name="next_review" />
|
53
|
+
<br /><field name="next_review" readonly="1" />
|
54
54
|
</p>
|
55
55
|
</div>
|
56
56
|
<div
|
@@ -94,6 +94,7 @@
|
|
94
94
|
<field name="sequence" />
|
95
95
|
<field name="requested_by" />
|
96
96
|
<field name="status" />
|
97
|
+
<field name="display_status" />
|
97
98
|
<field name="todo_by" />
|
98
99
|
<field name="done_by" />
|
99
100
|
<field name="reviewed_date" />
|
@@ -5,12 +5,14 @@ from odoo_test_helper import FakeModelLoader
|
|
5
5
|
|
6
6
|
from odoo.tests import common
|
7
7
|
|
8
|
+
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
|
9
|
+
|
8
10
|
|
9
11
|
class CommonTierValidation(common.TransactionCase):
|
10
12
|
@classmethod
|
11
13
|
def setUpClass(cls):
|
12
|
-
super(
|
13
|
-
|
14
|
+
super().setUpClass()
|
15
|
+
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
|
14
16
|
cls.loader = FakeModelLoader(cls.env, cls.__module__)
|
15
17
|
cls.loader.backup_registry()
|
16
18
|
from .tier_validation_tester import (
|
@@ -58,10 +60,15 @@ class CommonTierValidation(common.TransactionCase):
|
|
58
60
|
# Create users:
|
59
61
|
group_ids = cls.env.ref("base.group_system").ids
|
60
62
|
cls.test_user_1 = cls.env["res.users"].create(
|
61
|
-
{
|
63
|
+
{
|
64
|
+
"name": "John",
|
65
|
+
"login": "test1",
|
66
|
+
"email": "john@yourcompany.example.com",
|
67
|
+
"groups_id": [(6, 0, group_ids)],
|
68
|
+
}
|
62
69
|
)
|
63
70
|
cls.test_user_2 = cls.env["res.users"].create(
|
64
|
-
{"name": "Mike", "login": "test2"}
|
71
|
+
{"name": "Mike", "login": "test2", "email": "mike@yourcompany.example.com"}
|
65
72
|
)
|
66
73
|
|
67
74
|
# Create tier definitions:
|
@@ -481,6 +481,376 @@ class TierTierValidation(CommonTierValidation):
|
|
481
481
|
self.assertTrue(review)
|
482
482
|
self.assertEqual(review.reviewer_ids, self.test_user_2)
|
483
483
|
|
484
|
+
def test_19_notify_on_create(self):
|
485
|
+
# notify on create
|
486
|
+
tier_definition = self.env["tier.definition"].search([])
|
487
|
+
tier_definition.write(
|
488
|
+
{
|
489
|
+
"notify_on_create": True,
|
490
|
+
"notify_on_accepted": False,
|
491
|
+
"notify_on_rejected": False,
|
492
|
+
"notify_on_restarted": False,
|
493
|
+
"review_type": "group",
|
494
|
+
"reviewer_group_id": self.env.ref("base.group_system").id,
|
495
|
+
}
|
496
|
+
)
|
497
|
+
test_record_1 = self.test_model.create({"test_field": 2.5})
|
498
|
+
notifications_no_1 = len(
|
499
|
+
self.env["mail.notification"].search(
|
500
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
501
|
+
)
|
502
|
+
)
|
503
|
+
test_record_1.request_validation()
|
504
|
+
notifications_no_2 = len(
|
505
|
+
self.env["mail.notification"].search(
|
506
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
507
|
+
)
|
508
|
+
)
|
509
|
+
self.assertEqual(notifications_no_2, notifications_no_1 + 1)
|
510
|
+
|
511
|
+
# do not notify on create
|
512
|
+
tier_definition.write({"notify_on_create": False})
|
513
|
+
test_record_2 = self.test_model.create({"test_field": 2.5})
|
514
|
+
notifications_no_1 = len(
|
515
|
+
self.env["mail.notification"].search(
|
516
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
517
|
+
)
|
518
|
+
)
|
519
|
+
test_record_2.request_validation()
|
520
|
+
notifications_no_2 = len(
|
521
|
+
self.env["mail.notification"].search(
|
522
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
523
|
+
)
|
524
|
+
)
|
525
|
+
self.assertEqual(notifications_no_2, notifications_no_1)
|
526
|
+
|
527
|
+
def test_20_notify_on_accepted(self):
|
528
|
+
self.test_user_2.write(
|
529
|
+
{
|
530
|
+
"groups_id": [(6, 0, self.env.ref("base.group_system").ids)],
|
531
|
+
}
|
532
|
+
)
|
533
|
+
|
534
|
+
# notify on accepted
|
535
|
+
tier_definition = self.env["tier.definition"].search([])
|
536
|
+
tier_definition.write(
|
537
|
+
{
|
538
|
+
"notify_on_create": False,
|
539
|
+
"notify_on_accepted": True,
|
540
|
+
"notify_on_rejected": False,
|
541
|
+
"notify_on_restarted": False,
|
542
|
+
"review_type": "group",
|
543
|
+
"reviewer_group_id": self.env.ref("base.group_system").id,
|
544
|
+
}
|
545
|
+
)
|
546
|
+
test_record_1 = self.test_model.create({"test_field": 2.5})
|
547
|
+
test_record_1.request_validation()
|
548
|
+
test_record_1.invalidate_model()
|
549
|
+
record = test_record_1.with_user(self.test_user_2.id)
|
550
|
+
notifications_no_1 = len(
|
551
|
+
self.env["mail.notification"].search(
|
552
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
553
|
+
)
|
554
|
+
)
|
555
|
+
record.validate_tier()
|
556
|
+
notifications_no_2 = len(
|
557
|
+
self.env["mail.notification"].search(
|
558
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
559
|
+
)
|
560
|
+
)
|
561
|
+
self.assertEqual(notifications_no_2, notifications_no_1 + 1)
|
562
|
+
|
563
|
+
# do not notify on accepted
|
564
|
+
tier_definition.write({"notify_on_accepted": False})
|
565
|
+
test_record_2 = self.test_model.create({"test_field": 2.5})
|
566
|
+
test_record_2.request_validation()
|
567
|
+
test_record_2.invalidate_model()
|
568
|
+
test_record_2.with_user(self.test_user_2.id)
|
569
|
+
notifications_no_1 = len(
|
570
|
+
self.env["mail.notification"].search(
|
571
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
572
|
+
)
|
573
|
+
)
|
574
|
+
test_record_2.validate_tier()
|
575
|
+
notifications_no_2 = len(
|
576
|
+
self.env["mail.notification"].search(
|
577
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
578
|
+
)
|
579
|
+
)
|
580
|
+
self.assertEqual(notifications_no_2, notifications_no_1)
|
581
|
+
|
582
|
+
def test_21_notify_on_rejected(self):
|
583
|
+
self.test_user_2.write(
|
584
|
+
{
|
585
|
+
"groups_id": [(6, 0, self.env.ref("base.group_system").ids)],
|
586
|
+
}
|
587
|
+
)
|
588
|
+
|
589
|
+
# notify on rejected
|
590
|
+
tier_definition = self.env["tier.definition"].search([])
|
591
|
+
tier_definition.write(
|
592
|
+
{
|
593
|
+
"notify_on_create": False,
|
594
|
+
"notify_on_accepted": False,
|
595
|
+
"notify_on_rejected": True,
|
596
|
+
"notify_on_restarted": False,
|
597
|
+
"review_type": "group",
|
598
|
+
"reviewer_group_id": self.env.ref("base.group_system").id,
|
599
|
+
}
|
600
|
+
)
|
601
|
+
test_record_1 = self.test_model.create({"test_field": 2.5})
|
602
|
+
test_record_1.request_validation()
|
603
|
+
test_record_1.invalidate_model()
|
604
|
+
record = test_record_1.with_user(self.test_user_2.id)
|
605
|
+
notifications_no_1 = len(
|
606
|
+
self.env["mail.notification"].search(
|
607
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
608
|
+
)
|
609
|
+
)
|
610
|
+
record.reject_tier()
|
611
|
+
notifications_no_2 = len(
|
612
|
+
self.env["mail.notification"].search(
|
613
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
614
|
+
)
|
615
|
+
)
|
616
|
+
self.assertEqual(notifications_no_2, notifications_no_1 + 1)
|
617
|
+
|
618
|
+
# do not notify on rejected
|
619
|
+
tier_definition.write({"notify_on_rejected": False})
|
620
|
+
test_record_2 = self.test_model.create({"test_field": 2.5})
|
621
|
+
test_record_2.request_validation()
|
622
|
+
test_record_2.invalidate_model()
|
623
|
+
test_record_2.with_user(self.test_user_2.id)
|
624
|
+
|
625
|
+
notifications_no_1 = len(
|
626
|
+
self.env["mail.notification"].search(
|
627
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
628
|
+
)
|
629
|
+
)
|
630
|
+
test_record_2.reject_tier()
|
631
|
+
notifications_no_2 = len(
|
632
|
+
self.env["mail.notification"].search(
|
633
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
634
|
+
)
|
635
|
+
)
|
636
|
+
self.assertEqual(notifications_no_2, notifications_no_1)
|
637
|
+
|
638
|
+
def test_22_notify_on_restarted(self):
|
639
|
+
self.test_user_2.write(
|
640
|
+
{
|
641
|
+
"groups_id": [(6, 0, self.env.ref("base.group_system").ids)],
|
642
|
+
}
|
643
|
+
)
|
644
|
+
|
645
|
+
# notify on restarted
|
646
|
+
tier_definition = self.env["tier.definition"].search([])
|
647
|
+
tier_definition.write(
|
648
|
+
{
|
649
|
+
"notify_on_create": False,
|
650
|
+
"notify_on_accepted": False,
|
651
|
+
"notify_on_rejected": False,
|
652
|
+
"notify_on_restarted": True,
|
653
|
+
"review_type": "group",
|
654
|
+
"reviewer_group_id": self.env.ref("base.group_system").id,
|
655
|
+
}
|
656
|
+
)
|
657
|
+
test_record_1 = self.test_model.create({"test_field": 2.5})
|
658
|
+
test_record_1.request_validation()
|
659
|
+
test_record_1.invalidate_model()
|
660
|
+
record = test_record_1.with_user(self.test_user_2.id)
|
661
|
+
notifications_no_1 = len(
|
662
|
+
self.env["mail.notification"].search(
|
663
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
664
|
+
)
|
665
|
+
)
|
666
|
+
record.restart_validation()
|
667
|
+
notifications_no_2 = len(
|
668
|
+
self.env["mail.notification"].search(
|
669
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
670
|
+
)
|
671
|
+
)
|
672
|
+
self.assertEqual(notifications_no_2, notifications_no_1 + 1)
|
673
|
+
|
674
|
+
# do not notify on restarted
|
675
|
+
tier_definition.write({"notify_on_restarted": False})
|
676
|
+
test_record_2 = self.test_model.create({"test_field": 2.5})
|
677
|
+
test_record_2.request_validation()
|
678
|
+
test_record_2.with_user(self.test_user_2.id)
|
679
|
+
notifications_no_1 = len(
|
680
|
+
self.env["mail.notification"].search(
|
681
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
682
|
+
)
|
683
|
+
)
|
684
|
+
test_record_2.restart_validation()
|
685
|
+
notifications_no_2 = len(
|
686
|
+
self.env["mail.notification"].search(
|
687
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
688
|
+
)
|
689
|
+
)
|
690
|
+
self.assertEqual(notifications_no_2, notifications_no_1)
|
691
|
+
|
692
|
+
def test_23_all_notification(self):
|
693
|
+
self.test_user_2.write(
|
694
|
+
{
|
695
|
+
"groups_id": [(6, 0, self.env.ref("base.group_system").ids)],
|
696
|
+
}
|
697
|
+
)
|
698
|
+
|
699
|
+
# notify on restarted
|
700
|
+
tier_definition = self.env["tier.definition"].search([])
|
701
|
+
tier_definition.write(
|
702
|
+
{
|
703
|
+
"notify_on_create": True,
|
704
|
+
"notify_on_accepted": True,
|
705
|
+
"notify_on_rejected": True,
|
706
|
+
"notify_on_restarted": True,
|
707
|
+
"review_type": "group",
|
708
|
+
"reviewer_group_id": self.env.ref("base.group_system").id,
|
709
|
+
}
|
710
|
+
)
|
711
|
+
|
712
|
+
test_record = self.test_model.create({"test_field": 2.5})
|
713
|
+
|
714
|
+
# request validation
|
715
|
+
notifications_no_1 = len(
|
716
|
+
self.env["mail.notification"].search(
|
717
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
718
|
+
)
|
719
|
+
)
|
720
|
+
test_record.request_validation()
|
721
|
+
test_record.invalidate_model()
|
722
|
+
notifications_no_2 = len(
|
723
|
+
self.env["mail.notification"].search(
|
724
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
725
|
+
)
|
726
|
+
)
|
727
|
+
self.assertEqual(notifications_no_2, notifications_no_1 + 1)
|
728
|
+
|
729
|
+
# accept validation
|
730
|
+
record = test_record.with_user(self.test_user_2.id)
|
731
|
+
notifications_no_1 = len(
|
732
|
+
self.env["mail.notification"].search(
|
733
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
734
|
+
)
|
735
|
+
)
|
736
|
+
record.validate_tier()
|
737
|
+
notifications_no_2 = len(
|
738
|
+
self.env["mail.notification"].search(
|
739
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
740
|
+
)
|
741
|
+
)
|
742
|
+
self.assertEqual(notifications_no_2, notifications_no_1 + 1)
|
743
|
+
|
744
|
+
# restart validation
|
745
|
+
notifications_no_1 = len(
|
746
|
+
self.env["mail.notification"].search(
|
747
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
748
|
+
)
|
749
|
+
)
|
750
|
+
record.restart_validation()
|
751
|
+
notifications_no_2 = len(
|
752
|
+
self.env["mail.notification"].search(
|
753
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
754
|
+
)
|
755
|
+
)
|
756
|
+
self.assertEqual(notifications_no_2, notifications_no_1 + 1)
|
757
|
+
|
758
|
+
# reject validation
|
759
|
+
record.request_validation()
|
760
|
+
notifications_no_1 = len(
|
761
|
+
self.env["mail.notification"].search(
|
762
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
763
|
+
)
|
764
|
+
)
|
765
|
+
record.reject_tier()
|
766
|
+
notifications_no_2 = len(
|
767
|
+
self.env["mail.notification"].search(
|
768
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
769
|
+
)
|
770
|
+
)
|
771
|
+
self.assertEqual(notifications_no_2, notifications_no_1 + 1)
|
772
|
+
|
773
|
+
def test_24_no_notification(self):
|
774
|
+
self.test_user_2.write(
|
775
|
+
{
|
776
|
+
"groups_id": [(6, 0, self.env.ref("base.group_system").ids)],
|
777
|
+
}
|
778
|
+
)
|
779
|
+
|
780
|
+
# notify on restarted
|
781
|
+
tier_definition = self.env["tier.definition"].search([])
|
782
|
+
tier_definition.write(
|
783
|
+
{
|
784
|
+
"notify_on_create": False,
|
785
|
+
"notify_on_accepted": False,
|
786
|
+
"notify_on_rejected": False,
|
787
|
+
"notify_on_restarted": False,
|
788
|
+
"review_type": "group",
|
789
|
+
"reviewer_group_id": self.env.ref("base.group_system").id,
|
790
|
+
}
|
791
|
+
)
|
792
|
+
|
793
|
+
test_record = self.test_model.create({"test_field": 2.5})
|
794
|
+
|
795
|
+
# request validation
|
796
|
+
notifications_no_1 = len(
|
797
|
+
self.env["mail.notification"].search(
|
798
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
799
|
+
)
|
800
|
+
)
|
801
|
+
test_record.request_validation()
|
802
|
+
test_record.invalidate_model()
|
803
|
+
notifications_no_2 = len(
|
804
|
+
self.env["mail.notification"].search(
|
805
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
806
|
+
)
|
807
|
+
)
|
808
|
+
self.assertEqual(notifications_no_2, notifications_no_1)
|
809
|
+
|
810
|
+
# accept validation
|
811
|
+
record = test_record.with_user(self.test_user_2.id)
|
812
|
+
notifications_no_1 = len(
|
813
|
+
self.env["mail.notification"].search(
|
814
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
815
|
+
)
|
816
|
+
)
|
817
|
+
record.validate_tier()
|
818
|
+
notifications_no_2 = len(
|
819
|
+
self.env["mail.notification"].search(
|
820
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
821
|
+
)
|
822
|
+
)
|
823
|
+
self.assertEqual(notifications_no_2, notifications_no_1)
|
824
|
+
|
825
|
+
# restart validation
|
826
|
+
notifications_no_1 = len(
|
827
|
+
self.env["mail.notification"].search(
|
828
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
829
|
+
)
|
830
|
+
)
|
831
|
+
record.restart_validation()
|
832
|
+
notifications_no_2 = len(
|
833
|
+
self.env["mail.notification"].search(
|
834
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
835
|
+
)
|
836
|
+
)
|
837
|
+
self.assertEqual(notifications_no_2, notifications_no_1)
|
838
|
+
|
839
|
+
# reject validation
|
840
|
+
record.request_validation()
|
841
|
+
notifications_no_1 = len(
|
842
|
+
self.env["mail.notification"].search(
|
843
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
844
|
+
)
|
845
|
+
)
|
846
|
+
record.reject_tier()
|
847
|
+
notifications_no_2 = len(
|
848
|
+
self.env["mail.notification"].search(
|
849
|
+
[("res_partner_id", "=", self.test_user_1.partner_id.id)]
|
850
|
+
)
|
851
|
+
)
|
852
|
+
self.assertEqual(notifications_no_2, notifications_no_1)
|
853
|
+
|
484
854
|
|
485
855
|
@tagged("at_install")
|
486
856
|
class TierTierValidationView(CommonTierValidation):
|
@@ -7,7 +7,7 @@ from odoo import api, fields, models
|
|
7
7
|
class TierValidationTester(models.Model):
|
8
8
|
_name = "tier.validation.tester"
|
9
9
|
_description = "Tier Validation Tester"
|
10
|
-
_inherit = ["tier.validation"]
|
10
|
+
_inherit = ["tier.validation", "mail.thread"]
|
11
11
|
_tier_validation_manual_config = True
|
12
12
|
|
13
13
|
state = fields.Selection(
|