Skip to content

[FIX] public_budget: ajustar amount neto en alta masiva de OP con retenciones#611

Open
iga-adhoc wants to merge 1 commit into
ingadhoc:18.0from
adhoc-dev:18.0-t-68735-iga-2
Open

[FIX] public_budget: ajustar amount neto en alta masiva de OP con retenciones#611
iga-adhoc wants to merge 1 commit into
ingadhoc:18.0from
adhoc-dev:18.0-t-68735-iga-2

Conversation

@iga-adhoc

Copy link
Copy Markdown
Contributor

Problema

En mass_payment_group_create, el campo amount se setea al bruto de la factura (-sum(amount_residual)). El módulo l10n_ar_tax aplica las retenciones sumándolas a payment_total (sign=+1 para proveedor outbound), lo que deja payment_total > to_pay_amount.

Consecuencias:

  • La validación de to_signature_process falla ("Importe a pagar distinto a Importe de los Pagos").
  • Para destrabarla, se elimina la retención manualmente, pero luego no puede volver a cargarse.

En el flujo manual el onchange _onchange_withholdings descuenta las retenciones de amount, dejando amount = neto. En la creación programática ese onchange nunca dispara.

Solución

Después de crear el payment, se aplica el mismo ajuste que haría _onchange_withholdings:

if payment.payment_difference:
    new_amount = payment.amount + payment.payment_difference
    payment.with_context(skip_account_move_synchronization=True).amount = new_amount if new_amount > 0 else 0

payment_difference = to_pay_amount - payment_total = -withholdings_amount, por lo que amount queda en neto y payment_total == to_pay_amount.

Test plan

  • Crear una transacción con facturas de proveedor que apliquen retenciones (posición fiscal con retenciones AR activa).
  • Ejecutar "Alta masiva de OP".
  • Verificar que en las órdenes generadas payment_total == to_pay_amount (sin diferencia).
  • Verificar que se puede pasar a "Proceso de Firma" sin ValidationError.
  • Verificar que el monto que muestra la OP es el neto (bruto menos retenciones).
  • Verificar que sin retenciones el comportamiento es idéntico al anterior (sin cambios visibles).

…enciones

En la creación masiva de órdenes de pago (mass_payment_group_create),
amount se setea al bruto de la factura. l10n_ar_tax suma las retenciones
a payment_total (sign=+1 para proveedor outbound), por lo que
payment_total > to_pay_amount y la validación de to_signature_process falla.
En el flujo manual, _onchange_withholdings ajusta amount al neto, pero
ese onchange no dispara en creación programática.

Se aplica el mismo ajuste post-create: amount = amount + payment_difference,
dejando amount en neto y payment_total == to_pay_amount.

closes ingadhoc/odoo-public-administration#???
Copilot AI review requested due to automatic review settings June 5, 2026 17: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

Note

Copilot was unable to run its full agentic suite in this review.

Adjusts supplier outbound payment creation in mass_payment_group_create to account for Argentine withholding behavior where programmatic creation doesn’t trigger the same onchange logic as the manual flow.

Changes:

  • Captures the created account.payment record to post-process it.
  • Applies a netting adjustment to payment.amount based on payment.payment_difference to match the manual withholding onchange behavior.
  • Uses a context flag to bypass move synchronization when updating the amount.

Comment on lines +441 to +445
if payment.payment_difference:
new_amount = payment.amount + payment.payment_difference
payment.with_context(
skip_account_move_synchronization=True
).amount = new_amount if new_amount > 0 else 0
Comment on lines +441 to +445
if payment.payment_difference:
new_amount = payment.amount + payment.payment_difference
payment.with_context(
skip_account_move_synchronization=True
).amount = new_amount if new_amount > 0 else 0
Comment on lines +443 to +445
payment.with_context(
skip_account_move_synchronization=True
).amount = new_amount if new_amount > 0 else 0
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