diff --git a/account_payment_tier_validation/README.rst b/account_payment_tier_validation/README.rst new file mode 100644 index 00000000000..c6d2109a6cf --- /dev/null +++ b/account_payment_tier_validation/README.rst @@ -0,0 +1,113 @@ +======================= +Payment Tier Validation +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:b20484a2cc48487ef795ff2d3555ff9cb5c70f73ad407b9f33f10982b5ccc247 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Faccount--payment-lightgray.png?logo=github + :target: https://github.com/OCA/account-payment/tree/16.0/account_payment_tier_validation + :alt: OCA/account-payment +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-payment-16-0/account-payment-16-0-account_payment_tier_validation + :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/account-payment&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of Payments to support a tier +validation process. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +This module depends on ``base_tier_validation``. You can find it at +`OCA/server-ux `__ + +Configuration +============= + +To configure this module, you need to: + +1. Go to *Settings > Technical > Tier Validations > Tier Definition*. +2. Create as many tiers as you want for Payment model. + +Usage +===== + +To use this module, you need to: + +1. Create a Payment triggering at least one "Tier Definition". +2. Click on *Request Validation* button. +3. Under the tab *Reviews* have a look to pending reviews and their + statuses. +4. Once all reviews are validated click on *Confirm*. + +Additional features: + +- You can filter the Payments requesting your review through the filter + *Needs my Review*. +- User with rights to confirm the payment (validate all tiers that would + be generated) can directly do the operation, this is, there is no need + for her/him to request a validation. + +Known issues / Roadmap +====================== + +When a payment is generated through the payment wizard in invoices, in +some cases, validation prevents its creation. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Contributors +------------ + +- `Spearhead `__: + + Ricardo Jara + +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/account-payment `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_payment_tier_validation/__init__.py b/account_payment_tier_validation/__init__.py new file mode 100644 index 00000000000..4b76c7b2d5c --- /dev/null +++ b/account_payment_tier_validation/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/account_payment_tier_validation/__manifest__.py b/account_payment_tier_validation/__manifest__.py new file mode 100644 index 00000000000..68c744c2b44 --- /dev/null +++ b/account_payment_tier_validation/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2025 Spearhead - Ricardo Jara +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Payment Tier Validation", + "summary": "Extends the functionality of Payment to " + "support a tier validation process.", + "version": "16.0.1.0.0", + "category": "Generic Modules/Payment", + "website": "https://github.com/OCA/account-payment", + "author": "Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["account", "base_tier_validation"], + "data": ["views/account_payment_view.xml"], +} diff --git a/account_payment_tier_validation/i18n/account_payment_tier_validation.pot b/account_payment_tier_validation/i18n/account_payment_tier_validation.pot new file mode 100644 index 00000000000..b238ec6a7b4 --- /dev/null +++ b/account_payment_tier_validation/i18n/account_payment_tier_validation.pot @@ -0,0 +1,115 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_tier_validation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__can_review +msgid "Can Review" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__has_comment +msgid "Has Comment" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__hide_reviews +msgid "Hide Reviews" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,help:account_payment_tier_validation.field_account_payment__has_comment +msgid "If set, Allow the reviewer to leave a comment on the review." +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model,name:account_payment_tier_validation.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: account_payment_tier_validation +#: model_terms:ir.ui.view,arch_db:account_payment_tier_validation.view_account_payment_search +msgid "My Payments to review" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__need_validation +msgid "Need Validation" +msgstr "" + +#. module: account_payment_tier_validation +#: model_terms:ir.ui.view,arch_db:account_payment_tier_validation.view_account_payment_search +msgid "Needs my Review" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__next_review +msgid "Next Review" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model,name:account_payment_tier_validation.model_account_payment +msgid "Payments" +msgstr "" + +#. module: account_payment_tier_validation +#: model_terms:ir.ui.view,arch_db:account_payment_tier_validation.view_account_payment_search +msgid "Payments validated and ready to be confirmed" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__rejected +msgid "Rejected" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__rejected_message +msgid "Rejected Message" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__reviewer_ids +msgid "Reviewers" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model,name:account_payment_tier_validation.model_tier_definition +msgid "Tier Definition" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__to_validate_message +msgid "To Validate Message" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__validated +#: model_terms:ir.ui.view,arch_db:account_payment_tier_validation.view_account_payment_search +msgid "Validated" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__validated_message +msgid "Validated Message" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__validation_status +msgid "Validation Status" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__review_ids +msgid "Validations" +msgstr "" diff --git a/account_payment_tier_validation/i18n/it.po b/account_payment_tier_validation/i18n/it.po new file mode 100644 index 00000000000..e259e6adf89 --- /dev/null +++ b/account_payment_tier_validation/i18n/it.po @@ -0,0 +1,119 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_tier_validation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-03-18 15:06+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.10.2\n" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__can_review +msgid "Can Review" +msgstr "Può revisionare" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__has_comment +msgid "Has Comment" +msgstr "Ha commenti" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__hide_reviews +msgid "Hide Reviews" +msgstr "Nascondi revisioni" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,help:account_payment_tier_validation.field_account_payment__has_comment +msgid "If set, Allow the reviewer to leave a comment on the review." +msgstr "" +"Se attivata, consente al revisore di lasciare un commento nella revisione." + +#. module: account_payment_tier_validation +#: model:ir.model,name:account_payment_tier_validation.model_account_move +msgid "Journal Entry" +msgstr "Registrazione contabile" + +#. module: account_payment_tier_validation +#: model_terms:ir.ui.view,arch_db:account_payment_tier_validation.view_account_payment_search +msgid "My Payments to review" +msgstr "I miei pagamenti da revisionare" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__need_validation +msgid "Need Validation" +msgstr "Richiede conferma" + +#. module: account_payment_tier_validation +#: model_terms:ir.ui.view,arch_db:account_payment_tier_validation.view_account_payment_search +msgid "Needs my Review" +msgstr "Richiede la mia revisione" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__next_review +msgid "Next Review" +msgstr "Prossima revisione" + +#. module: account_payment_tier_validation +#: model:ir.model,name:account_payment_tier_validation.model_account_payment +msgid "Payments" +msgstr "Pagamenti" + +#. module: account_payment_tier_validation +#: model_terms:ir.ui.view,arch_db:account_payment_tier_validation.view_account_payment_search +msgid "Payments validated and ready to be confirmed" +msgstr "Pagamenti validati e pronti per la conferma" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__rejected +msgid "Rejected" +msgstr "Respinto" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__rejected_message +msgid "Rejected Message" +msgstr "Messaggio di rifiuto" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__reviewer_ids +msgid "Reviewers" +msgstr "Revisori" + +#. module: account_payment_tier_validation +#: model:ir.model,name:account_payment_tier_validation.model_tier_definition +msgid "Tier Definition" +msgstr "Definizione livello" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__to_validate_message +msgid "To Validate Message" +msgstr "Messaggio per 'Da validare'" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__validated +#: model_terms:ir.ui.view,arch_db:account_payment_tier_validation.view_account_payment_search +msgid "Validated" +msgstr "Validato" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__validated_message +msgid "Validated Message" +msgstr "Messaggio per 'Validato'" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__validation_status +msgid "Validation Status" +msgstr "Stato validazione" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__review_ids +msgid "Validations" +msgstr "Validazioni" diff --git a/account_payment_tier_validation/i18n/pt_BR.po b/account_payment_tier_validation/i18n/pt_BR.po new file mode 100644 index 00000000000..fb800f0313c --- /dev/null +++ b/account_payment_tier_validation/i18n/pt_BR.po @@ -0,0 +1,116 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_tier_validation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__can_review +msgid "Can Review" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__has_comment +msgid "Has Comment" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__hide_reviews +msgid "Hide Reviews" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,help:account_payment_tier_validation.field_account_payment__has_comment +msgid "If set, Allow the reviewer to leave a comment on the review." +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model,name:account_payment_tier_validation.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: account_payment_tier_validation +#: model_terms:ir.ui.view,arch_db:account_payment_tier_validation.view_account_payment_search +msgid "My Payments to review" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__need_validation +msgid "Need Validation" +msgstr "" + +#. module: account_payment_tier_validation +#: model_terms:ir.ui.view,arch_db:account_payment_tier_validation.view_account_payment_search +msgid "Needs my Review" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__next_review +msgid "Next Review" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model,name:account_payment_tier_validation.model_account_payment +msgid "Payments" +msgstr "" + +#. module: account_payment_tier_validation +#: model_terms:ir.ui.view,arch_db:account_payment_tier_validation.view_account_payment_search +msgid "Payments validated and ready to be confirmed" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__rejected +msgid "Rejected" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__rejected_message +msgid "Rejected Message" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__reviewer_ids +msgid "Reviewers" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model,name:account_payment_tier_validation.model_tier_definition +msgid "Tier Definition" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__to_validate_message +msgid "To Validate Message" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__validated +#: model_terms:ir.ui.view,arch_db:account_payment_tier_validation.view_account_payment_search +msgid "Validated" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__validated_message +msgid "Validated Message" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__validation_status +msgid "Validation Status" +msgstr "" + +#. module: account_payment_tier_validation +#: model:ir.model.fields,field_description:account_payment_tier_validation.field_account_payment__review_ids +msgid "Validations" +msgstr "" diff --git a/account_payment_tier_validation/models/__init__.py b/account_payment_tier_validation/models/__init__.py new file mode 100644 index 00000000000..37f4e58dbb3 --- /dev/null +++ b/account_payment_tier_validation/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import account_payment +from . import tier_definition diff --git a/account_payment_tier_validation/models/account_payment.py b/account_payment_tier_validation/models/account_payment.py new file mode 100644 index 00000000000..36435be5470 --- /dev/null +++ b/account_payment_tier_validation/models/account_payment.py @@ -0,0 +1,89 @@ +# Copyright 2025 Spearhead - Ricardo Jara +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, models +from odoo.exceptions import ValidationError + + +class AccountPayment(models.Model): + _name = "account.payment" + _inherit = ["account.payment", "tier.validation"] + _state_to = ["posted"] + + _tier_validation_manual_config = False + + def _get_under_validation_exceptions(self): + res = super(AccountPayment, self)._get_under_validation_exceptions() + return res + ["name"] + + def action_post(self): + return super( + AccountPayment, self.with_context(validate_in_progress=True) + ).action_post() + + def write(self, vals): + """ + Overwritten to call some custom methods for the tier validation process + since field state is a related field not stored, and base code in + tier_validation does not work as expected, when the state is 'posted' + """ + for rec in self: + if rec._check_state_conditions_custom(): + if rec._get_need_validation(): + # try to validate operation + reviews = rec.request_validation() + rec._validate_tier(reviews) + if rec.validation_status != "validated": + raise ValidationError( + _( + "This action needs to be validated for at" + " least one record. \nPlease request a" + " validation." + ) + ) + if rec.review_ids and rec.validation_status != "validated": + raise ValidationError( + _( + "A validation process is still open for at least " + "one record." + ) + ) + return super(AccountPayment, self).write(vals) + + def _check_state_conditions_custom(self): + """ + Needed because state is a related field not stored, + _check_state_conditions in model tier_validation, does not work + when the state is 'done' + """ + self.ensure_one() + if self._context.get("validate_in_progress"): + return True + return False + + def _get_need_validation(self): + """ + Needed because state is a related field not stored, + _compute_need_validation (field need_validation) in model + tier_validation, does not properly work when executing button + "Validate" + """ + self.ensure_one() + if isinstance(self.id, models.NewId): + return False + tiers = ( + self.env["tier.definition"] + .with_context(active_test=True) + .search( + [ + ("model", "=", self._name), + ("company_id", "in", [False] + self._get_company().ids), + ] + ) + ) + valid_tiers = tiers.filtered(lambda x: self.evaluate_tier(x)) + requested_tiers = self.review_ids.filtered( + lambda x: x.status != "pending" + ).mapped("definition_id") + new_tiers = valid_tiers - requested_tiers + return new_tiers and self._context.get("validate_in_progress") diff --git a/account_payment_tier_validation/models/tier_definition.py b/account_payment_tier_validation/models/tier_definition.py new file mode 100644 index 00000000000..2ae970c30bd --- /dev/null +++ b/account_payment_tier_validation/models/tier_definition.py @@ -0,0 +1,14 @@ +# Copyright 2019 Open Source Integrators +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class TierDefinition(models.Model): + _inherit = "tier.definition" + + @api.model + def _get_tier_validation_model_names(self): + res = super()._get_tier_validation_model_names() + res.append("account.payment") + return res diff --git a/account_payment_tier_validation/pyproject.toml b/account_payment_tier_validation/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/account_payment_tier_validation/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_payment_tier_validation/readme/CONFIGURE.md b/account_payment_tier_validation/readme/CONFIGURE.md new file mode 100644 index 00000000000..6f57c89e2aa --- /dev/null +++ b/account_payment_tier_validation/readme/CONFIGURE.md @@ -0,0 +1,5 @@ +To configure this module, you need to: + +1. Go to *Settings \> Technical \> Tier Validations \> Tier + Definition*. +2. Create as many tiers as you want for Payment model. diff --git a/account_payment_tier_validation/readme/CONTRIBUTORS.md b/account_payment_tier_validation/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..ce778ae2aca --- /dev/null +++ b/account_payment_tier_validation/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Spearhead](https://spearhead.global/): + + > Ricardo Jara \<\> diff --git a/account_payment_tier_validation/readme/DESCRIPTION.md b/account_payment_tier_validation/readme/DESCRIPTION.md new file mode 100644 index 00000000000..55501cbae98 --- /dev/null +++ b/account_payment_tier_validation/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module extends the functionality of Payments to support a +tier validation process. diff --git a/account_payment_tier_validation/readme/INSTALL.md b/account_payment_tier_validation/readme/INSTALL.md new file mode 100644 index 00000000000..c45725c465b --- /dev/null +++ b/account_payment_tier_validation/readme/INSTALL.md @@ -0,0 +1,2 @@ +This module depends on `base_tier_validation`. You can find it at +[OCA/server-ux](https://github.com/OCA/server-ux) diff --git a/account_payment_tier_validation/readme/ROADMAP.md b/account_payment_tier_validation/readme/ROADMAP.md new file mode 100644 index 00000000000..f177aba0969 --- /dev/null +++ b/account_payment_tier_validation/readme/ROADMAP.md @@ -0,0 +1 @@ +When a payment is generated through the payment wizard in invoices, in some cases, validation prevents its creation. diff --git a/account_payment_tier_validation/readme/USAGE.md b/account_payment_tier_validation/readme/USAGE.md new file mode 100644 index 00000000000..9e90b593677 --- /dev/null +++ b/account_payment_tier_validation/readme/USAGE.md @@ -0,0 +1,15 @@ +To use this module, you need to: + +1. Create a Payment triggering at least one "Tier Definition". +2. Click on *Request Validation* button. +3. Under the tab *Reviews* have a look to pending reviews and their + statuses. +4. Once all reviews are validated click on *Confirm*. + +Additional features: + +- You can filter the Payments requesting your review through the filter + *Needs my Review*. +- User with rights to confirm the payment (validate all tiers that would be + generated) can directly do the operation, this is, there is no need + for her/him to request a validation. diff --git a/account_payment_tier_validation/static/description/icon.png b/account_payment_tier_validation/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/account_payment_tier_validation/static/description/icon.png differ diff --git a/account_payment_tier_validation/static/description/index.html b/account_payment_tier_validation/static/description/index.html new file mode 100644 index 00000000000..67c8d3a18b0 --- /dev/null +++ b/account_payment_tier_validation/static/description/index.html @@ -0,0 +1,462 @@ + + + + + +Payment Tier Validation + + + +
+

Payment Tier Validation

+ + +

Beta License: AGPL-3 OCA/account-payment Translate me on Weblate Try me on Runboat

+

This module extends the functionality of Payments to support a tier +validation process.

+

Table of contents

+ +
+

Installation

+

This module depends on base_tier_validation. You can find it at +OCA/server-ux

+
+
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Go to Settings > Technical > Tier Validations > Tier Definition.
  2. +
  3. Create as many tiers as you want for Payment model.
  4. +
+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Create a Payment triggering at least one “Tier Definition”.
  2. +
  3. Click on Request Validation button.
  4. +
  5. Under the tab Reviews have a look to pending reviews and their +statuses.
  6. +
  7. Once all reviews are validated click on Confirm.
  8. +
+

Additional features:

+
    +
  • You can filter the Payments requesting your review through the filter +Needs my Review.
  • +
  • User with rights to confirm the payment (validate all tiers that would +be generated) can directly do the operation, this is, there is no need +for her/him to request a validation.
  • +
+
+
+

Known issues / Roadmap

+

When a payment is generated through the payment wizard in invoices, in +some cases, validation prevents its creation.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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/account-payment project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_payment_tier_validation/tests/__init__.py b/account_payment_tier_validation/tests/__init__.py new file mode 100644 index 00000000000..f39596410e7 --- /dev/null +++ b/account_payment_tier_validation/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_tier_validation diff --git a/account_payment_tier_validation/tests/test_tier_validation.py b/account_payment_tier_validation/tests/test_tier_validation.py new file mode 100644 index 00000000000..932b6a5bbb3 --- /dev/null +++ b/account_payment_tier_validation/tests/test_tier_validation.py @@ -0,0 +1,84 @@ +# Copyright 2025 Spearhead - Ricardo Jara +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from odoo.exceptions import ValidationError +from odoo.tests import tagged + +from odoo.addons.base.tests.common import BaseCommon + + +@tagged("post_install", "-at_install") +class TestAccountPayment(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + # Payment model + cls.payment_model = cls.env.ref("account.model_account_payment") + + # Create users + group_ids = ( + cls.env.ref("base.group_system") + + cls.env.ref("account.group_account_manager") + ).ids + cls.test_user_1 = cls.env["res.users"].create( + { + "name": "John", + "login": "test1", + "groups_id": [(6, 0, group_ids)], + "email": "test@examlple.com", + } + ) + + # Create tier definitions: + cls.tier_def_obj = cls.env["tier.definition"] + cls.tier_def_obj.create( + { + "model_id": cls.payment_model.id, + "review_type": "individual", + "reviewer_id": cls.test_user_1.id, + "definition_domain": "[('amount', '>', 100)]", + } + ) + cls.customer = cls.env["res.partner"].create({"name": "Partner for test"}) + + def test_01_tier_definition_models(self): + res = self.tier_def_obj._get_tier_validation_model_names() + self.assertIn("account.payment", res) + + def test_02_validation_account_payment(self): + payment = self.env["account.payment"].create( + { + "amount": 200.0, + "payment_type": "inbound", + "partner_type": "customer", + "partner_id": self.customer.id, + } + ) + + with self.assertRaises(ValidationError): + payment.action_post() + payment.amount = 100 + payment.action_post() + self.assertEqual(payment.state, "posted") + + def test_03_validation_account_payment(self): + payment = self.env["account.payment"].create( + { + "amount": 200.0, + "payment_type": "inbound", + "partner_type": "customer", + "partner_id": self.customer.id, + } + ) + payment.invalidate_model() + self.assertEqual(payment.validation_status, "no") + reviews = payment.with_user(self.env.user.id).request_validation() + payment.invalidate_model() + self.assertEqual(payment.validation_status, "pending") + self.assertTrue(reviews) + record = payment.with_user(self.test_user_1.id) + record.invalidate_model() + record.validate_tier() + payment.action_post() + self.assertEqual(payment.state, "posted") + self.assertEqual(payment.validation_status, "validated") diff --git a/account_payment_tier_validation/views/account_payment_view.xml b/account_payment_tier_validation/views/account_payment_view.xml new file mode 100644 index 00000000000..e41335633b2 --- /dev/null +++ b/account_payment_tier_validation/views/account_payment_view.xml @@ -0,0 +1,43 @@ + + + + account.payment.search + account.payment + + + + + + + + + + + + account.payment.tree + account.payment + + + + + + + + diff --git a/setup/account_payment_tier_validation/odoo/addons/account_payment_tier_validation b/setup/account_payment_tier_validation/odoo/addons/account_payment_tier_validation new file mode 120000 index 00000000000..e47cee3d8c3 --- /dev/null +++ b/setup/account_payment_tier_validation/odoo/addons/account_payment_tier_validation @@ -0,0 +1 @@ +../../../../account_payment_tier_validation \ No newline at end of file diff --git a/setup/account_payment_tier_validation/setup.py b/setup/account_payment_tier_validation/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/account_payment_tier_validation/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)