Skip to content

[FIX] stock_voucher_ux, stock_voucher_ux_iot: do not count header-only pages - #1024

Open
mav-adhoc wants to merge 1 commit into
ingadhoc:18.0from
adhoc-dev:18.0-h-126294-mav
Open

[FIX] stock_voucher_ux, stock_voucher_ux_iot: do not count header-only pages#1024
mav-adhoc wants to merge 1 commit into
ingadhoc:18.0from
adhoc-dev:18.0-h-126294-mav

Conversation

@mav-adhoc

Copy link
Copy Markdown
Contributor

Qué pasa

El contador que decide cuántos números de remito consume un preimpreso busca el código interno o el barcode del producto en el texto de cada página renderizada y, si no encuentra ninguno, cae a "cualquier página con un número decimal".

Un reporte que repite el encabezado en una hoja final matchea ese fallback con el encabezado mismo — alcanza un "Km 1,4" en un domicilio. La hoja no tiene una sola línea y sin embargo consume un número, y el operador pierde el remito que necesitaba usar después.

Qué cambia

Cuando el traslado tiene productos con código, manda el código: una página que no trae ninguno tampoco trae líneas. El fallback numérico queda para los traslados cuyos productos no tienen ni código interno ni barcode, donde no hay otra cosa con la que reconocer una línea.

El contador estaba duplicado en el controller de descarga y en el reporte IoT, con el mismo defecto en los dos y sin test sobre la copia del controller — que es por donde pasa toda impresión desde el navegador. Pasa a stock.picking, lo comparten los dos callers y queda cubierto.

Cómo se verifica

  • test_page_without_products_does_not_consume_a_voucher falla con la lógica vieja: AssertionError: 2 != 1.
  • Suites de stock_voucher, stock_voucher_ux y stock_voucher_ux_iot: 13 tests, 0 fallos, 0 errores.
  • Se elimina el test del módulo IoT que fijaba el comportamiento viejo (daba por buena una página con "12,50 total" y sin productos).

Tickets 126294 y 124890.

@roboadhoc

Copy link
Copy Markdown
Collaborator

Pull request status dashboard

@mav-adhoc
mav-adhoc force-pushed the 18.0-h-126294-mav branch 2 times, most recently from 3f90ff8 to 307ca90 Compare September 1, 2026 18:40
…y pages

The counter that decides how many voucher numbers a pre-printed remito
consumes looks for the product's internal reference or barcode in the text
of every rendered page and, when it finds neither, falls back to "any page
with a decimal number". A report that repeats the customer header on a
trailing page hits that fallback through the header itself: a kilometre
mark in an address is enough. A page without a single line then burned a
voucher number, and the operator lost the number they needed next.

Discard a page only when every line can be recognised: all the transfer's
products carry an internal reference or a barcode, and at least one of them
shows up in the rendered text, which is how we know the template prints
them. A page carrying none of them then carries no lines either. Anything
else -- a template that prints only the product name, a transfer with a
product that has no reference -- keeps the decimal fallback and counts every
page as it does today. The asymmetry is deliberate: over-counting burns a
number, under-counting sends out a printed page with no number on it.

The counter lived duplicated in the download controller and in the IoT
report, with the same defect in both and no test on the controller copy,
which is the one every browser print goes through. It moves to
stock.picking so both callers share a single implementation, covered by a
test that fails with the old fallback.

Tickets 126294 and 124890.
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.

2 participants