[19.0][ADD] account_financial_risk_global: new module#559
Open
gdgellatly wants to merge 1 commit into
Open
Conversation
Evaluate partner financial risk across all companies. The credit_limit field on res.partner is global, but account_financial_risk restricts risk queries to the current user's companies. This creates a gap where a partner can exceed their limit across companies without triggering an exception. This module removes the company filter and runs the risk computation with sudo so that totals always reflect the partner's full exposure across every company in the database.
29f8e72 to
57406a7
Compare
Contributor
|
I don’t think it’s necessary to create a new module for this; simply add a system parameter to the base module and propose the following change: If you like, you can add an option in the settings to improve the user experience. An even more powerful option would be to maintain a company-wide list of the companies for which risk is calculated. |
Contributor
|
ping @sergio-teruel |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
account_financial_risk_globalthat evaluates partner financial risk across all companiescredit_limitfield onres.partneris global, butaccount_financial_riskrestricts risk queries to the current user's companies, creating a gap where a partner can exceed their limit across companies without triggering an exception from any single company's view_get_risk_company_domainreturnsDomain.TRUE) and runs the risk computation withsudo()so that totals always reflect the partner's full exposureTechnical details
_get_risk_company_domain()to returnDomain.TRUE(include all companies)_compute_risk_account_amount()to run viasudo()so cross-company journal items are visiblerisk_account_amount/risk_account_amount_unpaid(notrisk_invoice_open) sinceproperty_account_receivable_idis company-specific — but they still count towardrisk_totalTest plan
test_risk_domain_is_global— domain returnsDomain.TRUEtest_risk_totals_span_companies— draft invoices in 2 companies sum correctlytest_exception_triggered_globally— credit limit exceeded with combined amountstest_no_exception_within_limit— no false positive within limittest_posted_invoices_span_companies— posted invoices across companies count in risk totaltest_single_company_user_still_sees_global_risk— user with single-company access sees full global risk