Skip to content

Commit e10fab2

Browse files
committed
Merge PR #1136 into 17.0
Signed-off-by pedrobaeza
2 parents ba7cf79 + 93794f8 commit e10fab2

File tree

11 files changed

+294
-264
lines changed

11 files changed

+294
-264
lines changed

base_tier_validation/README.rst

Lines changed: 68 additions & 70 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
@@ -70,16 +66,16 @@ To configure this module, you need to:
7066

7167
**Note:**
7268

73-
- If check *Notify Reviewers on Creation*, all possible reviewers will
74-
be notified by email when this definition is triggered.
75-
- If check *Notify reviewers on reaching pending* if you want to send a
76-
notification when pending status is reached. This is usefull in a
77-
approve by sequence scenario to only notify reviewers when it is their
78-
turn in the sequence.
79-
- If check *Comment*, reviewers can comment after click Validate or
80-
Reject.
81-
- If check *Approve by sequence*, reviewers is forced to review by
82-
specified sequence.
69+
- If check *Notify Reviewers on Creation*, all possible reviewers will
70+
be notified by email when this definition is triggered.
71+
- If check *Notify reviewers on reaching pending* if you want to send a
72+
notification when pending status is reached. This is usefull in a
73+
approve by sequence scenario to only notify reviewers when it is
74+
their turn in the sequence.
75+
- If check *Comment*, reviewers can comment after click Validate or
76+
Reject.
77+
- If check *Approve by sequence*, reviewers is forced to review by
78+
specified sequence.
8379

8480
To configure Tier Validation Exceptions, you need to:
8581

@@ -94,40 +90,42 @@ To configure Tier Validation Exceptions, you need to:
9490

9591
**Note:**
9692

97-
- If you don't create any exception, the Validated record will be
98-
readonly and cannot be modified.
99-
- If check *Write under Validation*, records will be able to be modified
100-
only in the defined fields when the Validation process is ongoing.
101-
- If check *Write after Validation*, records will be able to be modified
102-
only in the defined fields when the Validation process is finished.
103-
- If check *Write after Validation* and *Write under Validation*,
104-
records will be able to be modified defined fields always.
93+
- If you don't create any exception, the Validated record will be
94+
readonly and cannot be modified.
95+
- If check *Write under Validation*, records will be able to be
96+
modified only in the defined fields when the Validation process is
97+
ongoing.
98+
- If check *Write after Validation*, records will be able to be
99+
modified only in the defined fields when the Validation process is
100+
finished.
101+
- If check *Write after Validation* and *Write under Validation*,
102+
records will be able to be modified defined fields always.
105103

106104
Known issues / Roadmap
107105
======================
108106

109107
This is the list of known issues for this module. Any proposal for
110108
improvement will be very valuable.
111109

112-
- **Issue:**
110+
- **Issue:**
113111

114-
When using approve_sequence option in any tier.definition there can be
115-
inconsistencies in the systray notifications.
112+
When using approve_sequence option in any tier.definition there can
113+
be inconsistencies in the systray notifications.
116114

117-
**Description:**
115+
**Description:**
118116

119-
Field can_review in tier.review is used to filter out, in the systray
120-
notifications, the reviews a user can approve. This can_review field
121-
is updated **in the database** in method review_user_count, this can
122-
make it very inconsistent for databases with a lot of users and
123-
recurring updates that can change the expected behavior.
117+
Field can_review in tier.review is used to filter out, in the systray
118+
notifications, the reviews a user can approve. This can_review field
119+
is updated **in the database** in method review_user_count, this can
120+
make it very inconsistent for databases with a lot of users and
121+
recurring updates that can change the expected behavior.
124122

125-
- **Migration to 15.0:**
123+
- **Migration to 15.0:**
126124

127-
The parameter \_tier_validation_manual_config will become False, on
128-
14.0, the default value is True, as the change is applied after the
129-
migration. In order to use the new behavior we need to modify the
130-
value on our expected model.
125+
The parameter \_tier_validation_manual_config will become False, on
126+
14.0, the default value is True, as the change is applied after the
127+
migration. In order to use the new behavior we need to modify the
128+
value on our expected model.
131129

132130
Changelog
133131
=========
@@ -149,69 +147,69 @@ Migrated to Odoo 14.
149147

150148
Fixes:
151149

152-
- When using approve_sequence option in any tier.definition there can be
153-
inconsistencies in the systray notifications
154-
- When using approve_sequence, still not approve only the needed
155-
sequence, but also other sequence for the same approver
150+
- When using approve_sequence option in any tier.definition there can
151+
be inconsistencies in the systray notifications
152+
- When using approve_sequence, still not approve only the needed
153+
sequence, but also other sequence for the same approver
156154

157155
12.0.3.3.1 (2019-12-02)
158156
-----------------------
159157

160158
Fixes:
161159

162-
- Show comment on Reviews Table.
163-
- Edit notification with approve_sequence.
160+
- Show comment on Reviews Table.
161+
- Edit notification with approve_sequence.
164162

165163
12.0.3.3.0 (2019-11-27)
166164
-----------------------
167165

168166
New features:
169167

170-
- Add comment on Reviews Table.
171-
- Approve by sequence.
168+
- Add comment on Reviews Table.
169+
- Approve by sequence.
172170

173171
12.0.3.2.1 (2019-11-26)
174172
-----------------------
175173

176174
Fixes:
177175

178-
- Remove message_subscribe_users
176+
- Remove message_subscribe_users
179177

180178
12.0.3.2.0 (2019-11-25)
181179
-----------------------
182180

183181
New features:
184182

185-
- Notify reviewers
183+
- Notify reviewers
186184

187185
12.0.3.1.0 (2019-07-08)
188186
-----------------------
189187

190188
Fixes:
191189

192-
- Singleton error
190+
- Singleton error
193191

194192
12.0.3.0.0 (2019-12-02)
195193
-----------------------
196194

197195
Fixes:
198196

199-
- Edit Reviews Table
197+
- Edit Reviews Table
200198

201199
12.0.2.1.0 (2019-05-29)
202200
-----------------------
203201

204202
Fixes:
205203

206-
- Edit drop-down style width and position
204+
- Edit drop-down style width and position
207205

208206
12.0.2.0.0 (2019-05-28)
209207
-----------------------
210208

211209
New features:
212210

213-
- Pass parameters as functions.
214-
- Add Systray.
211+
- Pass parameters as functions.
212+
- Add Systray.
215213

216214
12.0.1.0.0 (2019-02-18)
217215
-----------------------
@@ -254,24 +252,24 @@ Authors
254252
Contributors
255253
------------
256254

257-
- Lois Rilo <[email protected]>
258-
- Naglis Jonaitis <[email protected]>
259-
- Adrià Gil Sorribes <[email protected]>
260-
- Pimolnat Suntian <[email protected]>
261-
- Pedro Gonzalez <[email protected]>
262-
- Kitti U. <[email protected]>
263-
- Saran Lim. <[email protected]>
264-
- Carlos Lopez <[email protected]>
265-
- Javier Colmeiro <[email protected]>
266-
- bosd
267-
- Evan Soh <[email protected]>
268-
- Manuel Regidor <[email protected]>
269-
- Eduardo de Miguel <[email protected]>
270-
- `XCG Consulting <https://xcg-consulting.fr>`__:
271-
272-
- Houzéfa Abbasbhay
273-
274-
- Stefan Rijnhart <[email protected]>
255+
- Lois Rilo <[email protected]>
256+
- Naglis Jonaitis <[email protected]>
257+
- Adrià Gil Sorribes <[email protected]>
258+
- Pimolnat Suntian <[email protected]>
259+
- Pedro Gonzalez <[email protected]>
260+
- Kitti U. <[email protected]>
261+
- Saran Lim. <[email protected]>
262+
- Carlos Lopez <[email protected]>
263+
- Javier Colmeiro <[email protected]>
264+
- bosd
265+
- Evan Soh <[email protected]>
266+
- Manuel Regidor <[email protected]>
267+
- Eduardo de Miguel <[email protected]>
268+
- `XCG Consulting <https://xcg-consulting.fr>`__:
269+
270+
- Houzéfa Abbasbhay
271+
272+
- Stefan Rijnhart <[email protected]>
275273

276274
Maintainers
277275
-----------

base_tier_validation/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Base Tier Validation",
55
"summary": "Implement a validation process based on tiers.",
6-
"version": "17.0.3.0.1",
6+
"version": "17.0.3.1.0",
77
"development_status": "Mature",
88
"maintainers": ["LoisRForgeFlow"],
99
"category": "Tools",
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Copyright 2025 Tecnativa - Víctor Martínez
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from openupgradelib import openupgrade
5+
6+
7+
@openupgrade.migrate()
8+
def migrate(env, version):
9+
env.cr.execute(
10+
"""
11+
SELECT imf.model
12+
FROM ir_model_fields AS imf
13+
WHERE imf.name = 'review_ids'
14+
AND imf.ttype = 'one2many'
15+
AND imf.model != 'tier.validation'
16+
"""
17+
)
18+
for (model_name,) in env.cr.fetchall():
19+
table_name = model_name.replace(".", "_")
20+
# validation_status column
21+
if not openupgrade.column_exists(env.cr, table_name, "validation_status"):
22+
openupgrade.logged_query(
23+
env.cr,
24+
f"""
25+
ALTER TABLE {table_name}
26+
ADD COLUMN IF NOT EXISTS validation_status VARCHAR
27+
""",
28+
)
29+
openupgrade.logged_query(
30+
env.cr,
31+
f"""
32+
UPDATE {table_name} SET validation_status = 'no'
33+
""",
34+
)
35+
openupgrade.logged_query(
36+
env.cr,
37+
f"""
38+
UPDATE {table_name} SET validation_status = 'rejected'
39+
WHERE validation_status = 'no' AND id IN (
40+
SELECT DISTINCT(tr.res_id)
41+
FROM tier_review AS tr
42+
WHERE tr.model = '{model_name}' AND tr.status = 'rejected'
43+
)
44+
""",
45+
)
46+
openupgrade.logged_query(
47+
env.cr,
48+
f"""
49+
UPDATE {table_name} SET validation_status = 'pending'
50+
WHERE validation_status = 'no' AND id IN (
51+
SELECT DISTINCT(tr.res_id)
52+
FROM tier_review AS tr
53+
WHERE tr.model = '{model_name}' AND tr.status = 'pending'
54+
)
55+
""",
56+
)
57+
openupgrade.logged_query(
58+
env.cr,
59+
f"""
60+
UPDATE {table_name} SET validation_status = 'waiting'
61+
WHERE validation_status = 'no' AND id IN (
62+
SELECT DISTINCT(tr.res_id)
63+
FROM tier_review AS tr
64+
WHERE tr.model = '{model_name}' AND tr.status = 'waiting'
65+
)
66+
""",
67+
)
68+
openupgrade.logged_query(
69+
env.cr,
70+
f"""
71+
UPDATE {table_name} SET validation_status = 'validated'
72+
WHERE validation_status = 'no' AND id IN (
73+
SELECT DISTINCT(tr.res_id)
74+
FROM tier_review AS tr
75+
WHERE tr.model = '{model_name}'
76+
AND tr.status IN ('approved', 'forwarded')
77+
)
78+
""",
79+
)

base_tier_validation/models/res_users.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ def review_user_count(self):
2828
Model.with_user(self.env.user)
2929
.with_context(active_test=False)
3030
.search([("id", "in", reviews.mapped("res_id"))])
31-
.filtered(lambda x: not x.rejected and x.can_review)
31+
.filtered(
32+
lambda x: x.validation_status != "rejected" and x.can_review
33+
)
3234
)
3335
# Excludes any cancelled records depending on the structure of the model
3436
if self.env[model]._state_field in self.env[model]._fields:

0 commit comments

Comments
 (0)