-
-
Notifications
You must be signed in to change notification settings - Fork 549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[15.0][MIG] base_tier_validation_waiting #638
Changes from all commits
6a7d9d9
8c93ee8
a890d13
ebb81aa
d49fffc
1ced653
dc54332
e167045
462c898
2fbae16
a0eb267
ff8b053
4c70394
174337e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
===================================== | ||
Base Tier Validation - Waiting status | ||
===================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:4346475efe4ef480f0be92477f55cec22180d4b9cc084696826c6ae8a532cf7f | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github | ||
:target: https://github.com/OCA/server-ux/tree/15.0/base_tier_validation_waiting | ||
:alt: OCA/server-ux | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/server-ux-15-0/server-ux-15-0-base_tier_validation_waiting | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-ux&target_branch=15.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module extends base_tier_validation to add an initial **"waiting"** status to tier reviews. | ||
It also auto moves next review to pending status when needed and handles notification if set. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
Set "Notify reviewers on reaching pending" if you want to send a notification when pending status is reached | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-ux/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/server-ux/issues/new?body=module:%20base_tier_validation_waiting%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* brain-tec AG | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Javier Colmeiro <javier.colmeiro@braintec.com> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/15.0/base_tier_validation_waiting>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (c) 2022 brain-tec AG (https://braintec.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import models |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (c) 2022 brain-tec AG (https://braintec.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Base Tier Validation - Waiting status", | ||
"summary": "Base Tier Validation Extension to add waiting status", | ||
"category": "Tools", | ||
"version": "15.0.1.0.0", | ||
"author": "brain-tec AG, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/server-ux", | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": [ | ||
"base_tier_validation", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/tier_definition_views.xml", | ||
], | ||
"qweb": ["static/src/xml/tier_review_template.xml"], | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * base_tier_validation_waiting | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: base_tier_validation_waiting | ||
#: model:ir.model.fields,field_description:base_tier_validation_waiting.field_tier_definition__display_name | ||
#: model:ir.model.fields,field_description:base_tier_validation_waiting.field_tier_review__display_name | ||
#: model:ir.model.fields,field_description:base_tier_validation_waiting.field_tier_validation__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: base_tier_validation_waiting | ||
#: model:ir.model.fields,field_description:base_tier_validation_waiting.field_tier_definition__id | ||
#: model:ir.model.fields,field_description:base_tier_validation_waiting.field_tier_review__id | ||
#: model:ir.model.fields,field_description:base_tier_validation_waiting.field_tier_validation__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: base_tier_validation_waiting | ||
#: model:ir.model.fields,help:base_tier_validation_waiting.field_tier_definition__notify_on_pending | ||
msgid "" | ||
"If set, all possible reviewers will be notified by email when this " | ||
"definition is triggered." | ||
msgstr "" | ||
|
||
#. module: base_tier_validation_waiting | ||
#: model:ir.model.fields,field_description:base_tier_validation_waiting.field_tier_definition____last_update | ||
#: model:ir.model.fields,field_description:base_tier_validation_waiting.field_tier_review____last_update | ||
#: model:ir.model.fields,field_description:base_tier_validation_waiting.field_tier_validation____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: base_tier_validation_waiting | ||
#: model:ir.model.fields,field_description:base_tier_validation_waiting.field_tier_definition__notify_on_pending | ||
msgid "Notify Reviewers on reaching Pending" | ||
msgstr "" | ||
|
||
#. module: base_tier_validation_waiting | ||
#: model:ir.model.fields,field_description:base_tier_validation_waiting.field_tier_review__status | ||
msgid "Status" | ||
msgstr "" | ||
|
||
#. module: base_tier_validation_waiting | ||
#: model:ir.model,name:base_tier_validation_waiting.model_tier_definition | ||
msgid "Tier Definition" | ||
msgstr "" | ||
|
||
#. module: base_tier_validation_waiting | ||
#: model:ir.model,name:base_tier_validation_waiting.model_tier_review | ||
msgid "Tier Review" | ||
msgstr "" | ||
|
||
#. module: base_tier_validation_waiting | ||
#: model:ir.model,name:base_tier_validation_waiting.model_tier_validation | ||
msgid "Tier Validation (abstract)" | ||
msgstr "" | ||
|
||
#. module: base_tier_validation_waiting | ||
#: model:ir.model.fields.selection,name:base_tier_validation_waiting.selection__tier_review__status__waiting | ||
msgid "Waiting" | ||
msgstr "" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright (c) 2022 brain-tec AG (https://braintec.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import tier_definition | ||
from . import tier_review | ||
from . import tier_validation |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (c) 2022 brain-tec AG (https://braintec.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class TierDefinition(models.Model): | ||
_inherit = "tier.definition" | ||
|
||
notify_on_pending = fields.Boolean( | ||
string="Notify Reviewers on reaching Pending", | ||
help="If set, all possible reviewers will be notified by email when " | ||
"this definition is triggered.", | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright (c) 2022 brain-tec AG (https://braintec.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
from odoo.tools import config | ||
|
||
|
||
class TierReview(models.Model): | ||
_inherit = "tier.review" | ||
|
||
def _default_status(self): | ||
if ( | ||
not config["test_enable"] | ||
or config["test_enable"] | ||
and self.env.context.get("testing_base_tier_validation_waiting") | ||
): | ||
return "waiting" | ||
else: | ||
return "pending" | ||
|
||
status = fields.Selection( | ||
selection_add=[("waiting", "Waiting")], | ||
default=_default_status, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use lambda to not reference the method object directly |
||
ondelete={"waiting": "set default"}, | ||
) | ||
|
||
def _notify_pending_status(self, review_ids): | ||
"""Method to call and reuse abstract notification method""" | ||
resource = self.env[self.model].browse(self.res_id) | ||
bosd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
resource._notify_review_available(review_ids) | ||
|
||
@api.depends("definition_id.approve_sequence") | ||
def _compute_can_review(self): | ||
"""inherit base module to push forward waiting reviews""" | ||
reviews = self.filtered( | ||
lambda rev: rev.status in ["waiting", "pending", "rejected"] | ||
) | ||
if reviews: | ||
# get minimum sequence of all to prevent jumps | ||
next_seq = min(reviews.mapped("sequence")) | ||
for record in reviews: | ||
# if not in waiting, nothing to do | ||
if record.status != "waiting": | ||
continue | ||
# if approve by sequence, check sequence has been reached | ||
if record.approve_sequence: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I get this IF block: in any case you set "pending" -> can't you have 1 single check? |
||
if record.sequence == next_seq: | ||
record.status = "pending" | ||
# if there is no approval sequence go directly to pending state | ||
elif not record.approve_sequence: | ||
record.status = "pending" | ||
# notify if state has changed | ||
if record.status == "pending": | ||
bosd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if record.definition_id.notify_on_pending: | ||
record._notify_pending_status(record) | ||
return super(TierReview, self)._compute_can_review() | ||
bosd marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need this specific check for tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, without this commit, it would mean that we need to patch a lot of depending modules, to fix their tests.
Another solution I've evaluated is using seperate tests. That might solve the problem with the CI tests here on github.
But it would simply transfer the problem to the persons running an custom CI like odoo.sh.
The method here is not really clean. But it's the least dirty solution.
(Discussed this test issue with a couple of oca contributors at the OXP)
Maybe you have another insight to solve this problem?