forked from OCA/credit-control
-
Notifications
You must be signed in to change notification settings - Fork 0
Syncing from upstream OCA/credit-control (19.0) #667
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
Merged
Merged
Conversation
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
* [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/
…ption. Improve views and translations.
…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.
…ecks to be not need to compute risk exception
Co-authored-by: sbiosca-s73 <[email protected]>
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
…ount_financial_risk_user
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
bt_gitbot