Skip to content

Commit 4f17018

Browse files
[IMP] base_tier_validation: Added password confirmation
1 parent 6211f08 commit 4f17018

File tree

13 files changed

+218
-39
lines changed

13 files changed

+218
-39
lines changed

base_tier_validation/README.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
====================
62
Base Tier Validation
73
====================
@@ -17,7 +13,7 @@ Base Tier Validation
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Mature
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github

base_tier_validation/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"views/tier_review_view.xml",
2424
"views/tier_validation_exception_view.xml",
2525
"wizard/comment_wizard_view.xml",
26+
"wizard/password_wizard_view.xml",
2627
"templates/tier_validation_templates.xml",
2728
],
2829
"assets": {

base_tier_validation/models/tier_definition.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ def _get_tier_validation_model_names(self):
108108
help="Bypassed (auto validated), if previous tier was validated "
109109
"by same reviewer",
110110
)
111+
require_password = fields.Boolean(
112+
help="If checked, the user will be asked to enter "
113+
"the password to validate the tier.",
114+
)
111115

112116
@api.onchange("review_type")
113117
def onchange_review_type(self):

base_tier_validation/models/tier_review.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ class TierReview(models.Model):
6868
related="definition_id.approve_sequence_bypass"
6969
)
7070
last_reminder_date = fields.Datetime(readonly=True)
71+
require_password = fields.Boolean(
72+
related="definition_id.require_password", readonly=True
73+
)
74+
password_confirmed = fields.Boolean()
7175

7276
@api.depends("status")
7377
def _compute_display_status(self):

base_tier_validation/models/tier_validation.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ class TierValidation(models.AbstractModel):
7979
)
8080
next_review = fields.Char(compute="_compute_next_review")
8181
hide_reviews = fields.Boolean(compute="_compute_hide_reviews")
82+
require_password = fields.Boolean(compute="_compute_require_password")
83+
84+
def _compute_require_password(self):
85+
for rec in self:
86+
require_password = rec.review_ids.filtered(
87+
lambda r: r.status == "pending" and (self.env.user in r.reviewer_ids)
88+
).mapped("require_password")
89+
rec.require_password = True in require_password
8290

8391
def _compute_has_comment(self):
8492
for rec in self:
@@ -623,6 +631,24 @@ def _add_comment(self, validate_reject, reviews):
623631
},
624632
}
625633

634+
def _confirm_password(self, validate_reject, reviews):
635+
wizard = self.env.ref("base_tier_validation.view_password_confirm_wizard")
636+
return {
637+
"name": self.env._("Password Confirmation"),
638+
"type": "ir.actions.act_window",
639+
"view_mode": "form",
640+
"res_model": "password.wizard",
641+
"views": [(wizard.id, "form")],
642+
"view_id": wizard.id,
643+
"target": "new",
644+
"context": {
645+
"default_res_id": self.id,
646+
"default_res_model": self._name,
647+
"default_review_ids": reviews.ids,
648+
"default_validate_reject": validate_reject,
649+
},
650+
}
651+
626652
def validate_tier(self):
627653
self.ensure_one()
628654
sequences = self._get_sequences_to_approve(self.env.user)
@@ -634,6 +660,11 @@ def validate_tier(self):
634660
lambda r: r.status == "pending" and (self.env.user in r.reviewer_ids)
635661
)
636662
return self._add_comment("validate", user_reviews)
663+
elif self.require_password:
664+
user_reviews = reviews.filtered(
665+
lambda r: r.status == "pending" and (self.env.user in r.reviewer_ids)
666+
)
667+
return self._confirm_password("validate", user_reviews)
637668
self._validate_tier(reviews)
638669
self._update_counter({"review_deleted": True})
639670

@@ -643,6 +674,8 @@ def reject_tier(self):
643674
reviews = self.review_ids.filtered(lambda x: x.sequence in sequences)
644675
if self.has_comment:
645676
return self._add_comment("reject", reviews)
677+
elif self.require_password:
678+
return self._confirm_password("reject", reviews)
646679
self._rejected_tier(reviews)
647680
self._update_counter({"review_deleted": True})
648681

base_tier_validation/security/ir.model.access.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ access_tier_review,access.tier.review,model_tier_review,base.group_user,1,1,1,1
77
access_tier_definition_all,tier.definition.all,model_tier_definition,base.group_user,1,0,0,0
88
access_tier_definition_settings,tier.definition.settings,model_tier_definition,base.group_erp_manager,1,1,1,1
99
access_comment_wizard,access.comment.wizard,model_comment_wizard,base.group_user,1,1,1,1
10+
access_password_wizard,access.password.wizard,model_password_wizard,base.group_user,1,1,1,1
1011
access_tier_validation_exceptions_all,tier.validation.exceptions,model_tier_validation_exception,base.group_user,1,0,0,0
1112
access_tier_validation_exceptions_settings,tier.validation.exceptions,model_tier_validation_exception,base.group_system,1,1,1,1

base_tier_validation/static/description/index.html

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Base Tier Validation</title>
77
<style type="text/css">
88

99
/*
@@ -360,21 +360,16 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="base-tier-validation">
364+
<h1 class="title">Base Tier Validation</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="base-tier-validation">
370-
<h1>Base Tier Validation</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375370
!! source digest: sha256:6d11975caf64405a5a43026ff242109052744ce42ab068f3e50f93dd016d1208
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-ux/tree/18.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-18-0/server-ux-18-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&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<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/18.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-18-0/server-ux-18-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&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p>Validating some operations is a common need across different areas in a
379374
company and sometimes it also involves several people and stages in the
380375
process. With this module you will be able to define your custom
@@ -426,7 +421,7 @@ <h1>Base Tier Validation</h1>
426421
</ul>
427422
</div>
428423
<div class="section" id="configuration">
429-
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
424+
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
430425
<p>To configure this module, you need to:</p>
431426
<ol class="arabic simple">
432427
<li>Go to <em>Settings &gt; Technical &gt; Tier Validations &gt; Tier Definition</em>.</li>
@@ -470,7 +465,7 @@ <h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
470465
</ul>
471466
</div>
472467
<div class="section" id="known-issues-roadmap">
473-
<h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
468+
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
474469
<p>This is the list of known issues for this module. Any proposal for
475470
improvement will be very valuable.</p>
476471
<ul>
@@ -493,19 +488,19 @@ <h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
493488
</ul>
494489
</div>
495490
<div class="section" id="changelog">
496-
<h2><a class="toc-backref" href="#toc-entry-3">Changelog</a></h2>
491+
<h1><a class="toc-backref" href="#toc-entry-3">Changelog</a></h1>
497492
<div class="section" id="section-1">
498-
<h3><a class="toc-backref" href="#toc-entry-4">17.0.1.0.0 (2024-01-10)</a></h3>
493+
<h2><a class="toc-backref" href="#toc-entry-4">17.0.1.0.0 (2024-01-10)</a></h2>
499494
<p>Migrated to Odoo 17. Merged module with tier_validation_waiting. To
500495
support sending messages in a validation sequence when it is their turn
501496
to validate.</p>
502497
</div>
503498
<div class="section" id="section-2">
504-
<h3><a class="toc-backref" href="#toc-entry-5">14.0.1.0.0 (2020-11-19)</a></h3>
499+
<h2><a class="toc-backref" href="#toc-entry-5">14.0.1.0.0 (2020-11-19)</a></h2>
505500
<p>Migrated to Odoo 14.</p>
506501
</div>
507502
<div class="section" id="section-3">
508-
<h3><a class="toc-backref" href="#toc-entry-6">13.0.1.2.2 (2020-08-30)</a></h3>
503+
<h2><a class="toc-backref" href="#toc-entry-6">13.0.1.2.2 (2020-08-30)</a></h2>
509504
<p>Fixes:</p>
510505
<ul class="simple">
511506
<li>When using approve_sequence option in any tier.definition there can be
@@ -515,99 +510,99 @@ <h3><a class="toc-backref" href="#toc-entry-6">13.0.1.2.2 (2020-08-30)</a></h3>
515510
</ul>
516511
</div>
517512
<div class="section" id="section-4">
518-
<h3><a class="toc-backref" href="#toc-entry-7">12.0.3.3.1 (2019-12-02)</a></h3>
513+
<h2><a class="toc-backref" href="#toc-entry-7">12.0.3.3.1 (2019-12-02)</a></h2>
519514
<p>Fixes:</p>
520515
<ul class="simple">
521516
<li>Show comment on Reviews Table.</li>
522517
<li>Edit notification with approve_sequence.</li>
523518
</ul>
524519
</div>
525520
<div class="section" id="section-5">
526-
<h3><a class="toc-backref" href="#toc-entry-8">12.0.3.3.0 (2019-11-27)</a></h3>
521+
<h2><a class="toc-backref" href="#toc-entry-8">12.0.3.3.0 (2019-11-27)</a></h2>
527522
<p>New features:</p>
528523
<ul class="simple">
529524
<li>Add comment on Reviews Table.</li>
530525
<li>Approve by sequence.</li>
531526
</ul>
532527
</div>
533528
<div class="section" id="section-6">
534-
<h3><a class="toc-backref" href="#toc-entry-9">12.0.3.2.1 (2019-11-26)</a></h3>
529+
<h2><a class="toc-backref" href="#toc-entry-9">12.0.3.2.1 (2019-11-26)</a></h2>
535530
<p>Fixes:</p>
536531
<ul class="simple">
537532
<li>Remove message_subscribe_users</li>
538533
</ul>
539534
</div>
540535
<div class="section" id="section-7">
541-
<h3><a class="toc-backref" href="#toc-entry-10">12.0.3.2.0 (2019-11-25)</a></h3>
536+
<h2><a class="toc-backref" href="#toc-entry-10">12.0.3.2.0 (2019-11-25)</a></h2>
542537
<p>New features:</p>
543538
<ul class="simple">
544539
<li>Notify reviewers</li>
545540
</ul>
546541
</div>
547542
<div class="section" id="section-8">
548-
<h3><a class="toc-backref" href="#toc-entry-11">12.0.3.1.0 (2019-07-08)</a></h3>
543+
<h2><a class="toc-backref" href="#toc-entry-11">12.0.3.1.0 (2019-07-08)</a></h2>
549544
<p>Fixes:</p>
550545
<ul class="simple">
551546
<li>Singleton error</li>
552547
</ul>
553548
</div>
554549
<div class="section" id="section-9">
555-
<h3><a class="toc-backref" href="#toc-entry-12">12.0.3.0.0 (2019-12-02)</a></h3>
550+
<h2><a class="toc-backref" href="#toc-entry-12">12.0.3.0.0 (2019-12-02)</a></h2>
556551
<p>Fixes:</p>
557552
<ul class="simple">
558553
<li>Edit Reviews Table</li>
559554
</ul>
560555
</div>
561556
<div class="section" id="section-10">
562-
<h3><a class="toc-backref" href="#toc-entry-13">12.0.2.1.0 (2019-05-29)</a></h3>
557+
<h2><a class="toc-backref" href="#toc-entry-13">12.0.2.1.0 (2019-05-29)</a></h2>
563558
<p>Fixes:</p>
564559
<ul class="simple">
565560
<li>Edit drop-down style width and position</li>
566561
</ul>
567562
</div>
568563
<div class="section" id="section-11">
569-
<h3><a class="toc-backref" href="#toc-entry-14">12.0.2.0.0 (2019-05-28)</a></h3>
564+
<h2><a class="toc-backref" href="#toc-entry-14">12.0.2.0.0 (2019-05-28)</a></h2>
570565
<p>New features:</p>
571566
<ul class="simple">
572567
<li>Pass parameters as functions.</li>
573568
<li>Add Systray.</li>
574569
</ul>
575570
</div>
576571
<div class="section" id="section-12">
577-
<h3><a class="toc-backref" href="#toc-entry-15">12.0.1.0.0 (2019-02-18)</a></h3>
572+
<h2><a class="toc-backref" href="#toc-entry-15">12.0.1.0.0 (2019-02-18)</a></h2>
578573
<p>Migrated to Odoo 12.</p>
579574
</div>
580575
<div class="section" id="section-13">
581-
<h3><a class="toc-backref" href="#toc-entry-16">11.0.1.0.0 (2018-05-09)</a></h3>
576+
<h2><a class="toc-backref" href="#toc-entry-16">11.0.1.0.0 (2018-05-09)</a></h2>
582577
<p>Migrated to Odoo 11.</p>
583578
</div>
584579
<div class="section" id="section-14">
585-
<h3><a class="toc-backref" href="#toc-entry-17">10.0.1.0.0 (2018-03-26)</a></h3>
580+
<h2><a class="toc-backref" href="#toc-entry-17">10.0.1.0.0 (2018-03-26)</a></h2>
586581
<p>Migrated to Odoo 10.</p>
587582
</div>
588583
<div class="section" id="section-15">
589-
<h3><a class="toc-backref" href="#toc-entry-18">9.0.1.0.0 (2017-12-02)</a></h3>
584+
<h2><a class="toc-backref" href="#toc-entry-18">9.0.1.0.0 (2017-12-02)</a></h2>
590585
<p>First version.</p>
591586
</div>
592587
</div>
593588
<div class="section" id="bug-tracker">
594-
<h2><a class="toc-backref" href="#toc-entry-19">Bug Tracker</a></h2>
589+
<h1><a class="toc-backref" href="#toc-entry-19">Bug Tracker</a></h1>
595590
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-ux/issues">GitHub Issues</a>.
596591
In case of trouble, please check there if your issue has already been reported.
597592
If you spotted it first, help us to smash it by providing a detailed and welcomed
598593
<a class="reference external" href="https://github.com/OCA/server-ux/issues/new?body=module:%20base_tier_validation%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
599594
<p>Do not contact contributors directly about support or help with technical issues.</p>
600595
</div>
601596
<div class="section" id="credits">
602-
<h2><a class="toc-backref" href="#toc-entry-20">Credits</a></h2>
597+
<h1><a class="toc-backref" href="#toc-entry-20">Credits</a></h1>
603598
<div class="section" id="authors">
604-
<h3><a class="toc-backref" href="#toc-entry-21">Authors</a></h3>
599+
<h2><a class="toc-backref" href="#toc-entry-21">Authors</a></h2>
605600
<ul class="simple">
606601
<li>ForgeFlow</li>
607602
</ul>
608603
</div>
609604
<div class="section" id="contributors">
610-
<h3><a class="toc-backref" href="#toc-entry-22">Contributors</a></h3>
605+
<h2><a class="toc-backref" href="#toc-entry-22">Contributors</a></h2>
611606
<ul class="simple">
612607
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
613608
<li>Naglis Jonaitis &lt;<a class="reference external" href="mailto:naglis&#64;versada.eu">naglis&#64;versada.eu</a>&gt;</li>
@@ -632,12 +627,12 @@ <h3><a class="toc-backref" href="#toc-entry-22">Contributors</a></h3>
632627
</ul>
633628
</div>
634629
<div class="section" id="other-credits">
635-
<h3><a class="toc-backref" href="#toc-entry-23">Other credits</a></h3>
630+
<h2><a class="toc-backref" href="#toc-entry-23">Other credits</a></h2>
636631
<p>The migration of this module from 17.0 to 18.0 was financially supported
637632
by Camptocamp.</p>
638633
</div>
639634
<div class="section" id="maintainers">
640-
<h3><a class="toc-backref" href="#toc-entry-24">Maintainers</a></h3>
635+
<h2><a class="toc-backref" href="#toc-entry-24">Maintainers</a></h2>
641636
<p>This module is maintained by the OCA.</p>
642637
<a class="reference external image-reference" href="https://odoo-community.org">
643638
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -652,6 +647,5 @@ <h3><a class="toc-backref" href="#toc-entry-24">Maintainers</a></h3>
652647
</div>
653648
</div>
654649
</div>
655-
</div>
656650
</body>
657651
</html>

0 commit comments

Comments
 (0)