Skip to content

Conversation

@bt-admin
Copy link

bt_gitbot

carlosdauden and others added 30 commits November 12, 2025 08:27
* [9.0][IMP] partner_financial_risk: Improve performance

* [9.0][IMP] partner_financial_risk: Improve tests and partner hierarchy

* [9.0][IMP] partner_stock_risk: Test
- Refunds adds partner risk instead of reduce.
- If date_maturity changes to previous today date "never" compute partner risk.
* [9.0][IMP] partner_financial_risk: Improve multicompany cron

* [9.0][IMP] partner_financial_risk: Exec with sudo

(cherry picked from commit 6590bbf)
Currently translated at 71.2% (52 of 73 strings)

Translation: credit-control-12.0/credit-control-12.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-12-0/credit-control-12-0-account_financial_risk/fr/
Currently translated at 79.5% (58 of 73 strings)

Translation: credit-control-12.0/credit-control-12.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-12-0/credit-control-12-0-account_financial_risk/it/
Currently translated at 100.0% (73 of 73 strings)

Translation: credit-control-12.0/credit-control-12.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-12-0/credit-control-12-0-account_financial_risk/es/
Currently translated at 13.7% (10 of 73 strings)

Translation: credit-control-12.0/credit-control-12.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-12-0/credit-control-12-0-account_financial_risk/es_CL/
Currently translated at 76.7% (56 of 73 strings)

Translation: credit-control-12.0/credit-control-12.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-12-0/credit-control-12-0-account_financial_risk/pt_BR/
Currently translated at 100.0% (73 of 73 strings)

Translation: credit-control-12.0/credit-control-12.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-12-0/credit-control-12-0-account_financial_risk/pt/
…le_financial_risk:

 - Optimize code and change stored computed fields to not store to improve multi-company support
 - Improve multi-currency support
 - Convert risk amount fields to clickable link that shows traceability of amount origin
 - New pivot views to risk amount traceability
 - Simplify class style applied on risk fields
 - Migration script to remove old stored computed fields
 - Improve tests to cover new functionallity
 - Update translation files

account_financial_risk:
 - Don't block refund invoice validation when partner has risk exception
 - Allow search partners by risk exception field
 - Remove obsolete cron

sale_financial_risk
 - Create related store commercial_partner_id field in sale order line to simplify computation
 - Rename amt_to_invoice field to risk_amount in sale order line
 - Hook and migration scripts to reduce new fields computing time

TT23765
This commit adds an specific group for overpassing partner credit limit exceptions
In some situations, not only account managers shoud be allowed to overpass exception, depending on the company policies. Merging this code will not affect current instances, as long as account managers will be added to the new group.
sergio-teruel and others added 27 commits November 12, 2025 08:45
…ecks to be not need to compute risk exception
Currently translated at 52.1% (49 of 94 strings)

Translation: credit-control-16.0/credit-control-16.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-16-0/credit-control-16-0-account_financial_risk/it/
Currently translated at 100.0% (92 of 92 strings)

Translation: credit-control-17.0/credit-control-17.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-17-0/credit-control-17-0-account_financial_risk/sv/
Only superadmins have access to this model, so let's do the operation
with sudo for getting the ID, which is the only intention of that code.

TT50264
Currently translated at 100.0% (92 of 92 strings)

Translation: credit-control-17.0/credit-control-17.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-17-0/credit-control-17-0-account_financial_risk/it/
…ly when the contact is a person but does not have a parent_id.

During migration to V17, the conversion from attribute to Python expression was incorrect. As a result, this page became visible when a contact is a person but has a parent_id. The correct logic should display the field only when the contact is a person and does not have a parent_id.
…ove_line_pivot

because account.action_account_moves_all have not defined view
TT54575
Currently translated at 100.0% (92 of 92 strings)

Translation: credit-control-18.0/credit-control-18.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-18-0/credit-control-18-0-account_financial_risk/it/
…void side effects

Steps to reproduce the error:
- Install the sale_financial_risk module
- Install a sales module and run tests to confirm an order (product_sold_by_delivery_week, for example)

An error similar to this will be displayed:

File "/opt/odoo/auto/addons/account_financial_risk/models/res_partner.py", line 453, in _compute_risk_exception
    if partner.credit_limit and amount > partner.credit_limit:
  File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 1266, in __get__
    recs._fetch_field(self)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4085, in _fetch_field
    self.check_field_access_rights('read', [field.name])
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3817, in check_field_access_rights
    raise AccessError(error_msg)
odoo.exceptions.AccessError: You do not have enough rights to access the fields "credit_limit" on Contact (res.partner). Please contact your system administrator.

What's the error?
The fields added by sale_financial_risk https://github.com/OCA/credit-control/blob/63730c2082b63ac2cf83f8b1add64420b712ed0f/sale_financial_risk/models/res_partner.py#L67C9-L67C25 are set to depend on _get_depends_compute_risk_exception() https://github.com/OCA/credit-control/blob/63730c2082b63ac2cf83f8b1add64420b712ed0f/account_financial_risk/models/res_partner.py#L503 , which causes the _compute_risk_exception() method to fail because the credit_limit field is not accessible. https://github.com/OCA/credit-control/blob/63730c2082b63ac2cf83f8b1add64420b712ed0f/account_financial_risk/models/res_partner.py#L441

The correct way to resolve this is use .sudo() to access credit_limit
Currently translated at 95.6% (88 of 92 strings)

Translation: credit-control-18.0/credit-control-18.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-18-0/credit-control-18-0-account_financial_risk/tr/
Currently translated at 100.0% (92 of 92 strings)

Translation: credit-control-18.0/credit-control-18.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-18-0/credit-control-18-0-account_financial_risk/it/
…sion

Changed the calculation of `risk_remaining_percentage` to round to 2
decimals instead of rounding to an integer.
This prevents the percentage from showing misleading values like 100%
when the actual value is slightly less, improving accuracy and clarity
in financial risk display.
Currently translated at 100.0% (106 of 106 strings)

Translation: credit-control-18.0/credit-control-18.0-account_financial_risk
Translate-URL: https://translation.odoo-community.org/projects/credit-control-18-0/credit-control-18-0-account_financial_risk/it/
When users without accounting access are trying to access a Sale Order, they have an access error on the partner field credit_limit (standard Odoo field that is limited to Account groups), which is used when computing the SO's risk_info.

Use sudo across in the financial risk modules when accessing partner.credit_limit.
Signed-off-by pedrobaeza
@bt-admin bt-admin added the 19.0 label Nov 19, 2025
@bt-admin bt-admin merged commit 9f43520 into brain-tec:19.0 Nov 19, 2025
4 checks passed
@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (19.0@bdd07ac). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             19.0     #667   +/-   ##
=======================================
  Coverage        ?   90.95%           
=======================================
  Files           ?       11           
  Lines           ?      420           
  Branches        ?       40           
=======================================
  Hits            ?      382           
  Misses          ?       33           
  Partials        ?        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.