Skip to content

[FIX] account_payment_pro: filter empty currency_id in _onchange_amount_update_exact - #1113

Open
feg-adhoc wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-h-120417-feg
Open

[FIX] account_payment_pro: filter empty currency_id in _onchange_amount_update_exact#1113
feg-adhoc wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-h-120417-feg

Conversation

@feg-adhoc

Copy link
Copy Markdown
Contributor

Summary

When a user without full permissions opens the payment wizard from an invoice, the currency_id field arrives as an empty recordset in the onchange context. Calling .is_zero() on it triggers ensure_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_amount already handles this case.

Changes

  • account_payment_pro/models/account_payment.py: _onchange_amount_update_exact — iterate over self.filtered("currency_id") instead of self.

Test plan

  • Open an invoice and click "Register Payment" with a user that has restricted permissions.
  • Verify the payment wizard opens without RPC error.
  • Change the amount and confirm the amount_exact field updates correctly.

Copilot AI review requested due to automatic review settings June 19, 2026 20:19
@roboadhoc

Copy link
Copy Markdown
Contributor

Pull request status dashboard

Copilot AI 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.

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_exact para no ejecutar .is_zero() cuando currency_id está 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants