Skip to content

[17.0][ADD] sale_financial_risk_exclude_order_type#561

Open
atgalvez08 wants to merge 1 commit into
OCA:17.0from
BinhexTeam:17.0-add-sale_financial_risk_exclude_order_type
Open

[17.0][ADD] sale_financial_risk_exclude_order_type#561
atgalvez08 wants to merge 1 commit into
OCA:17.0from
BinhexTeam:17.0-add-sale_financial_risk_exclude_order_type

Conversation

@atgalvez08

@atgalvez08 atgalvez08 commented May 7, 2026

Copy link
Copy Markdown

@BinhexTeam

Description

This module extends sale_financial_risk to support
financial risk behavior configuration directly on
sale.order.type.

It allows configuring sale order types to:

  • exclude orders from financial risk computation
  • bypass financial risk blocking validation

The implementation intentionally keeps the design
simple and business-oriented by integrating the
configuration directly into sale order types.

Features

  • Exclude order types from risk computation
  • Allow blocking bypass by order type
  • Independent control of computation and blocking
  • Multi-company compatible behavior
  • Seamless integration with sale_order_type

Included components

  • sale.order.type extensions
  • Risk computation domain extension
  • Financial risk blocking override
  • Automated test suite

Design considerations

The implementation intentionally avoids introducing
additional configuration models.

The module:

  • keeps configuration close to business semantics
  • reduces maintenance complexity
  • avoids duplicating framework logic
  • preserves existing sale_financial_risk behavior
  • follows a lightweight extension approach

Technical details

  • Extends sale.order.type
  • Overrides evaluate_risk_message
  • Extends _get_risk_sale_order_domain
  • Supports optional blocking bypass
  • Supports optional exclusion from risk computation

Dependencies

  • sale_financial_risk
  • sale_order_type

Testing

Includes automated tests for:

  • blocking bypass behavior
  • risk computation domain generation
  • separation of concerns
  • neutral order types
  • multi-company behavior
  • domain integrity

Checklist

  • Module follows OCA structure
  • README aligned with implementation
  • Tests included
  • No duplicated framework logic
  • License headers included

@OCA-git-bot OCA-git-bot added mod:sale_financial_risk_exclude_order_type Module sale_financial_risk_exclude_order_type series:17.0 labels May 7, 2026
@atgalvez08 atgalvez08 force-pushed the 17.0-add-sale_financial_risk_exclude_order_type branch from c38e764 to b5b2e7b Compare May 7, 2026 15:40

@rrebollo rrebollo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a technical perspective, it looks good. However, regarding the design or approach used for the implementation—why not just integrate the risk management directly into sale_order_type? I mean, the glue addon is fine, but I don't understand why you went with the company settings approach. Why not simply incorporate the feature into the sale order type itself?

Comment thread sale_financial_risk_exclude_order_type/__manifest__.py Outdated
Comment thread sale_financial_risk_exclude_order_type/views/res_config_settings_views.xml Outdated
@atgalvez08 atgalvez08 force-pushed the 17.0-add-sale_financial_risk_exclude_order_type branch from b5b2e7b to 1338dbd Compare May 11, 2026 06:43
@atgalvez08 atgalvez08 changed the title [17.0][ADD] sale_financial_risk_exclude_order_type: add risk exclusion rules by order type [17.0][ADD] sale_financial_risk_exclude_order_type May 11, 2026
@atgalvez08

Copy link
Copy Markdown
Author

From a technical perspective, it looks good. However, regarding the design or approach used for the implementation—why not just integrate the risk management directly into sale_order_type? I mean, the glue addon is fine, but I don't understand why you went with the company settings approach. Why not simply incorporate the feature into the sale order type itself?

Good point, and I agree after revisiting the design.

The initial implementation used a separate configuration model to keep the feature highly configurable and isolated from sale.order.type. The idea was to support company-specific rules without modifying the business model itself.

However, after reviewing the use case more carefully, the additional configuration layer introduced unnecessary complexity for a behavior that is naturally tied to the order type definition itself.

I have now simplified the implementation by moving the configuration directly into sale.order.type through dedicated boolean fields:

  • exclude_from_risk
  • allow_blocking_bypass

This approach is cleaner because it:

  • keeps configuration closer to the business semantics
  • removes unnecessary indirection
  • reduces maintenance overhead
  • simplifies the UX
  • avoids an extra model and settings view

The current implementation preserves the same functional behavior while significantly simplifying the architecture.

@atgalvez08 atgalvez08 marked this pull request as ready for review May 11, 2026 06:49
Comment thread sale_financial_risk_exclude_order_type/models/res_partner.py Outdated
…der type

This module extends sale_financial_risk to support
financial risk behavior configuration directly on
sale order types.

It allows configuring sale order types to:

- exclude orders from risk computation
- bypass financial risk blocking validation

The implementation intentionally integrates the
behavior directly into sale.order.type in order to:

- simplify the architecture
- avoid unnecessary configuration models
- reduce maintenance complexity
- align configuration with business semantics

Features:
- risk computation exclusion by order type
- blocking bypass support by order type
- independent control of computation and blocking
- multi-company compatible behavior
- integration with sale_order_type

Technical details:
- extends sale.order.type
- overrides evaluate_risk_message
- extends risk computation domain
- preserves standard sale_financial_risk behavior

Includes automated tests for:
- blocking bypass behavior
- risk domain generation
- separation of concerns
- neutral order types
- multi-company behavior
- domain integrity
@atgalvez08 atgalvez08 force-pushed the 17.0-add-sale_financial_risk_exclude_order_type branch from 1338dbd to 029a921 Compare May 11, 2026 10:06

Copy link
Copy Markdown

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.

@rrebollo rrebollo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review. LGTM!

After reading the documentation, I understand that the two paths address distinct scenarios within the financial risk framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:sale_financial_risk_exclude_order_type Module sale_financial_risk_exclude_order_type series:17.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants