-
-
Notifications
You must be signed in to change notification settings - Fork 241
[17.0][ADD] sale_financial_risk_exclude_order_type #561
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
Open
atgalvez08
wants to merge
1
commit into
OCA:17.0
Choose a base branch
from
BinhexTeam:17.0-add-sale_financial_risk_exclude_order_type
base: 17.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| ====================================== | ||
| Sale Financial Risk Exclude Order Type | ||
| ====================================== | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:f47c700d76bb1d6eda697be06e36a973c16d1b9409211b4a17653209e388ee74 | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png | ||
| :target: https://odoo-community.org/page/development-status | ||
| :alt: Alpha | ||
| .. |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%2Fcredit--control-lightgray.png?logo=github | ||
| :target: https://github.com/OCA/credit-control/tree/17.0/sale_financial_risk_exclude_order_type | ||
| :alt: OCA/credit-control | ||
| .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
| :target: https://translation.odoo-community.org/projects/credit-control-17-0/credit-control-17-0-sale_financial_risk_exclude_order_type | ||
| :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/credit-control&target_branch=17.0 | ||
| :alt: Try me on Runboat | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| This module extends ``sale.order.type`` to integrate with | ||
| ``sale_financial_risk``. | ||
|
|
||
| It adds two independent behaviors to sale order types: | ||
|
|
||
| - Exclude orders from financial risk computation | ||
| - Allow confirmation bypass for financial risk blocking | ||
|
|
||
| This allows implementing flexible commercial workflows while keeping the | ||
| standard financial risk framework intact. | ||
|
|
||
| Features | ||
| ======== | ||
|
|
||
| - Extend ``sale.order.type`` with financial risk options | ||
| - Exclude selected order types from risk exposure computation | ||
| - Allow selected order types to bypass financial risk blocking | ||
| - Keep computation and blocking behaviors independent | ||
| - Compatible with ``sale_financial_risk`` | ||
| - Compatible with multi-company environments | ||
|
|
||
| Design Notes | ||
| ============ | ||
|
|
||
| This module intentionally keeps the financial risk behavior directly | ||
| attached to ``sale.order.type``. | ||
|
|
||
| The implementation avoids introducing additional rule or configuration | ||
| models in order to: | ||
|
|
||
| - keep the behavior simple | ||
| - reduce maintenance complexity | ||
| - align with the functional nature of sale order types | ||
| - avoid unnecessary configuration layers | ||
|
|
||
| The module still preserves separation between: | ||
|
|
||
| - financial exposure computation | ||
| - confirmation blocking behavior | ||
|
|
||
| .. IMPORTANT:: | ||
| This is an alpha version, the data model and design can change at any time without warning. | ||
| Only for development or testing purpose, do not use in production. | ||
| `More details on development status <https://odoo-community.org/page/development-status>`_ | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Usage | ||
| ===== | ||
|
|
||
| Usage | ||
| ===== | ||
|
|
||
| - Exclude from Risk Computation | ||
|
|
||
| Sale orders using this type will not contribute to the partner financial | ||
| exposure calculation. | ||
|
|
||
| - Allow Risk Blocking Bypass | ||
|
|
||
| Sale orders using this type can be confirmed even when financial risk | ||
| blocking would normally prevent confirmation. | ||
|
|
||
| Both options are independent and can be combined freely. | ||
|
|
||
| Known issues / Roadmap | ||
| ====================== | ||
|
|
||
| Known issues / Roadmap | ||
| ====================== | ||
|
|
||
| - Add optional risk warning indicators on sale orders | ||
| - Improve reporting of excluded order types | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues <https://github.com/OCA/credit-control/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/credit-control/issues/new?body=module:%20sale_financial_risk_exclude_order_type%0Aversion:%2017.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 | ||
| ------- | ||
|
|
||
| * Binhex Systems Solutions S.L | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| - `Binhex Systems Solutions S.L. <https://www.binhex.cloud>`__: | ||
|
|
||
| - Ariel Torres | ||
|
|
||
| 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/credit-control <https://github.com/OCA/credit-control/tree/17.0/sale_financial_risk_exclude_order_type>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "name": "Sale Financial Risk Exclude Order Type", | ||
| "summary": "Exclude sale order types from financial risk computation", | ||
| "version": "17.0.1.0.0", | ||
| "category": "Credit Control", | ||
| "author": "Binhex Systems Solutions S.L, Odoo Community Association (OCA)", | ||
| "website": "https://github.com/OCA/credit-control", | ||
| "license": "AGPL-3", | ||
| "depends": [ | ||
| "sale_financial_risk", | ||
| "sale_order_type", | ||
| ], | ||
| "data": [ | ||
| "views/sale_order_type_views.xml", | ||
| ], | ||
| "images": ["static/description/icon.png"], | ||
| "installable": True, | ||
| "application": False, | ||
| "development_status": "Alpha", | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * sale_financial_risk_exclude_order_type | ||
| # | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 17.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2026-04-23 07:27+0000\n" | ||
| "PO-Revision-Date: 2026-04-23 07:27+0000\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: sale_financial_risk_exclude_order_type | ||
| #: model:ir.model.fields,field_description:sale_financial_risk_exclude_order_type.field_sale_order_type__allow_blocking_bypass | ||
| msgid "Allow Risk Blocking Bypass" | ||
| msgstr "Permitir omitir bloqueo de riesgo" | ||
|
|
||
| #. module: sale_financial_risk_exclude_order_type | ||
| #: model:ir.model,name:sale_financial_risk_exclude_order_type.model_res_partner | ||
| msgid "Contact" | ||
| msgstr "Contacto" | ||
|
|
||
| #. module: sale_financial_risk_exclude_order_type | ||
| #: model:ir.model.fields,field_description:sale_financial_risk_exclude_order_type.field_sale_order_type__exclude_from_risk | ||
| msgid "Exclude from Risk Computation" | ||
| msgstr "Excluir del cálculo de riesgo" | ||
|
|
||
| #. module: sale_financial_risk_exclude_order_type | ||
| #: model_terms:ir.ui.view,arch_db:sale_financial_risk_exclude_order_type.sale_order_type_view_form_inherit_sale_financial_risk_exclude_order_type | ||
| msgid "Financial Risk" | ||
| msgstr "Riesgo financiero" | ||
|
|
||
| #. module: sale_financial_risk_exclude_order_type | ||
| #: model:ir.model.fields,help:sale_financial_risk_exclude_order_type.field_sale_order_type__exclude_from_risk | ||
| msgid "" | ||
| "If enabled, sale orders of this type are excluded from sale financial risk " | ||
| "computation." | ||
| msgstr "" | ||
| "Si está habilitado, los pedidos de venta de este tipo se excluyen del cálculo " | ||
| "del riesgo financiero de venta." | ||
|
|
||
| #. module: sale_financial_risk_exclude_order_type | ||
| #: model:ir.model.fields,help:sale_financial_risk_exclude_order_type.field_sale_order_type__allow_blocking_bypass | ||
| msgid "" | ||
| "If enabled, sale orders of this type can be confirmed without financial risk" | ||
| " blocking." | ||
| msgstr "" | ||
| "Si está habilitado, los pedidos de venta de este tipo se pueden confirmar " | ||
| "sin bloqueo por riesgo financiero. " | ||
|
|
||
| #. module: sale_financial_risk_exclude_order_type | ||
| #: model:ir.model,name:sale_financial_risk_exclude_order_type.model_sale_order | ||
| msgid "Sales Order" | ||
| msgstr "Pedido de venta" | ||
|
|
||
| #. module: sale_financial_risk_exclude_order_type | ||
| #: model:ir.model,name:sale_financial_risk_exclude_order_type.model_sale_order_type | ||
| msgid "Type of sale order" | ||
| msgstr "Tipo de pedido de venta" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from . import sale_order_type | ||
| from . import res_partner | ||
| from . import sale_order |
28 changes: 28 additions & 0 deletions
28
sale_financial_risk_exclude_order_type/models/res_partner.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| from odoo import models | ||
|
|
||
|
|
||
| class ResPartner(models.Model): | ||
| _inherit = "res.partner" | ||
|
|
||
| def _get_risk_sale_order_domain(self): | ||
| """ | ||
| Extend the domain used by sale_financial_risk to compute | ||
| sale order exposure. | ||
| Since the base computation runs on sale.order.line, the related | ||
| field path used here is: | ||
| order_id.type_id | ||
| """ | ||
| domain = super()._get_risk_sale_order_domain() | ||
| excluded_types = self.env["sale.order.type"].search( | ||
| [ | ||
| ("exclude_from_risk", "=", True), | ||
| "|", | ||
| ("company_id", "=", False), | ||
| ("company_id", "=", self.env.company.id), | ||
| ] | ||
| ) | ||
|
|
||
| if excluded_types: | ||
| domain += [("order_id.type_id", "not in", excluded_types.ids)] | ||
|
|
||
| return domain |
27 changes: 27 additions & 0 deletions
27
sale_financial_risk_exclude_order_type/models/sale_order.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| from odoo import models | ||
|
|
||
|
|
||
| class SaleOrder(models.Model): | ||
| _inherit = "sale.order" | ||
|
|
||
| def _allow_financial_risk_blocking_bypass(self): | ||
| """ | ||
| Return whether this order type is configured to bypass | ||
| financial risk blocking. | ||
| """ | ||
| self.ensure_one() | ||
| return bool(self.type_id and self.type_id.allow_blocking_bypass) | ||
|
|
||
| def evaluate_risk_message(self, partner): | ||
| """ | ||
| Override the blocking decision from sale_financial_risk. | ||
| If the order type is configured with 'Allow Risk Blocking Bypass', | ||
| no blocking message is returned. | ||
| Otherwise, preserve the standard behavior. | ||
| """ | ||
| self.ensure_one() | ||
|
|
||
| if self._allow_financial_risk_blocking_bypass(): | ||
| return False | ||
|
|
||
| return super().evaluate_risk_message(partner) |
20 changes: 20 additions & 0 deletions
20
sale_financial_risk_exclude_order_type/models/sale_order_type.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class SaleOrderType(models.Model): | ||
| _inherit = "sale.order.type" | ||
|
|
||
| exclude_from_risk = fields.Boolean( | ||
| string="Exclude from Risk Computation", | ||
| help=( | ||
| "If enabled, sale orders of this type are excluded from " | ||
| "sale financial risk computation." | ||
| ), | ||
| ) | ||
| allow_blocking_bypass = fields.Boolean( | ||
| string="Allow Risk Blocking Bypass", | ||
| help=( | ||
| "If enabled, sale orders of this type can be confirmed " | ||
| "without financial risk blocking." | ||
| ), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [build-system] | ||
| requires = ["whool"] | ||
| build-backend = "whool.buildapi" |
11 changes: 11 additions & 0 deletions
11
sale_financial_risk_exclude_order_type/readme/CONFIGURATION.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| To configure the module: | ||
|
|
||
| Go to: | ||
|
|
||
| *Sales > Configuration > Sale Order Types* | ||
|
|
||
| For each order type you can configure: | ||
|
|
||
| - *Exclude from Risk Computation* | ||
|
|
||
| - *Allow Risk Blocking Bypass* |
2 changes: 2 additions & 0 deletions
2
sale_financial_risk_exclude_order_type/readme/CONTRIBUTORS.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - [Binhex Systems Solutions S.L.](https://www.binhex.cloud): | ||
| - Ariel Torres |
39 changes: 39 additions & 0 deletions
39
sale_financial_risk_exclude_order_type/readme/DESCRIPTION.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| This module extends ``sale.order.type`` to integrate with | ||
| ``sale_financial_risk``. | ||
|
|
||
| It adds two independent behaviors to sale order types: | ||
|
|
||
| - Exclude orders from financial risk computation | ||
| - Allow confirmation bypass for financial risk blocking | ||
|
|
||
| This allows implementing flexible commercial workflows while | ||
| keeping the standard financial risk framework intact. | ||
|
|
||
| Features | ||
| ======== | ||
|
|
||
| - Extend ``sale.order.type`` with financial risk options | ||
| - Exclude selected order types from risk exposure computation | ||
| - Allow selected order types to bypass financial risk blocking | ||
| - Keep computation and blocking behaviors independent | ||
| - Compatible with ``sale_financial_risk`` | ||
| - Compatible with multi-company environments | ||
|
|
||
| Design Notes | ||
| ============ | ||
|
|
||
| This module intentionally keeps the financial risk behavior | ||
| directly attached to ``sale.order.type``. | ||
|
|
||
| The implementation avoids introducing additional rule or | ||
| configuration models in order to: | ||
|
|
||
| - keep the behavior simple | ||
| - reduce maintenance complexity | ||
| - align with the functional nature of sale order types | ||
| - avoid unnecessary configuration layers | ||
|
|
||
| The module still preserves separation between: | ||
|
|
||
| - financial exposure computation | ||
| - confirmation blocking behavior |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Known issues / Roadmap | ||
| ====================== | ||
|
|
||
| - Add optional risk warning indicators on sale orders | ||
| - Improve reporting of excluded order types |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| Testing | ||
| ======= | ||
|
|
||
| Includes automated tests covering: | ||
|
|
||
| - risk computation exclusion | ||
| - blocking bypass behavior | ||
| - separation of concerns | ||
| - multi-company behavior | ||
| - neutral order types | ||
| - domain integrity |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 two flag fields? There seems to be some common ground between the two behaviors. Could you explain this more clearly?
Based on the naming alone, "excluded" appears to result in no sale financial risk behavior, while "allow blocking" seems to do the same. Perhaps the issue is just a lack of clear documentation.
If both paths are legitimate and distinct, I would suggest implementing a single selection field with a range of choices. That said, it's possible that I simply lack enough functional knowledge of the addon.