[FIX] account_payment_pro: filter empty currency_id in _onchange_amount_update_exact - #1113
Open
feg-adhoc wants to merge 1 commit into
Open
[FIX] account_payment_pro: filter empty currency_id in _onchange_amount_update_exact#1113feg-adhoc wants to merge 1 commit into
feg-adhoc wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Este PR busca evitar un error en el wizard de pagos cuando currency_id llega vacío en el contexto de onchange (p. ej. con usuarios restringidos), lo que provocaba un ensure_one() al llamar currency_id.is_zero().
Changes:
- Ajusta
_onchange_amount_update_exactpara no ejecutar.is_zero()cuandocurrency_idestá vacío.
Comment on lines
+398
to
400
| for rec in self.filtered("currency_id"): | ||
| if not rec.currency_id.is_zero(rec.amount - rec.amount_exact): | ||
| rec.amount_exact = rec.amount |
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
When a user without full permissions opens the payment wizard from an invoice, the
currency_idfield arrives as an empty recordset in the onchange context. Calling.is_zero()on it triggersensure_one()→ValueError: Expected singleton: res.currency().Fix: use
self.filtered("currency_id")to skip records with no currency before entering the loop, consistent with how_compute_amountalready handles this case.Changes
account_payment_pro/models/account_payment.py:_onchange_amount_update_exact— iterate overself.filtered("currency_id")instead ofself.Test plan
amount_exactfield updates correctly.