Skip to content

[IMP] stock_currency_valuation_recompute: recompute and revaluate from the list - #1010

Open
feg-adhoc wants to merge 1 commit into
ingadhoc:18.0from
adhoc-dev:18.0-h-124586-feg-batch
Open

[IMP] stock_currency_valuation_recompute: recompute and revaluate from the list#1010
feg-adhoc wants to merge 1 commit into
ingadhoc:18.0from
adhoc-dev:18.0-h-124586-feg-batch

Conversation

@feg-adhoc

Copy link
Copy Markdown
Contributor

The repair tool works one record at a time. Repairing a database means opening every recompute and pressing the two buttons on each one, which on a real run is hundreds of records.

What changes

The list view gets the same two actions in its header, acting on the selection:

  • Compute lines — takes records in draft, in_process and no_change.
  • Revaluate — takes only in_process, since revaluating a record that is already done would write its adjustment a second time. It asks for confirmation, because it writes on the layers and their journal entries.

Both loop over the selection and delegate to the existing single record methods, which are left untouched: the replay and the writing of the layers, their journal entries and the product cost keep going through exactly the same code.

Records that the form buttons would not offer are filtered out rather than processed, and if nothing in the selection qualifies it raises, instead of reporting success after doing nothing.

The cap

The selection is capped at 30. Each record replays the whole valuation history of its product and, when revaluating, rewrites its journal entries; a larger selection runs past the request timeout and, since it is a single transaction, nothing is applied at all.

Note the same transaction boundary applies within a batch: if one record raises (for example, a correction that starts before the fiscal lock date), the whole batch is rolled back. That is the standard behaviour of a button acting on a selection, and keeping it means a partially applied batch is never left behind.

Test plan

stock_currency_valuation_recompute tests, 4 passed:

  • test_compute_lines_multi_processes_every_selected_record — two products with their own layer, one recompute each; both end up recomputed, not only the first.
  • test_batch_over_the_limit_is_refused — 31 records raise and none of them is recomputed.
  • test_revaluation_multi_skips_records_already_applied — a done record is not revaluated again.
  • test_recompute_detects_out_valued_with_stale_cost — the pre-existing one, unchanged.

Manually: filter the list by In Process, tick several records, and use both header buttons.

…m the list

The tool works one record at a time, so repairing a database means opening every
recompute and pressing the two buttons on each one. On a real repair run that is
hundreds of records.

The list view gets the same two actions in its header, acting on the selection.
Both loop over the selection and delegate to the single record methods, which are
left untouched: the replay and the writing of the layers, their journal entries
and the product cost keep going through exactly the same code.

The selection is capped at 30 records. Each one replays the whole valuation
history of its product and, when revaluating, rewrites its journal entries, so a
larger selection runs past the request timeout and nothing is applied at all.

Records the form buttons would not offer are skipped instead of processed:
compute lines takes draft, in process and no change; revaluate takes only in
process, since revaluating a record that is already done would write its
adjustment a second time. If nothing in the selection qualifies it raises, rather
than reporting success after doing nothing.

Change note: desde la lista de recomputes ahora se pueden recalcular las lineas y
revaluar varios registros juntos, seleccionandolos y usando los botones del
encabezado, en tandas de hasta 30.
Copilot AI lite review requested due to automatic review settings August 25, 2026 21:37
@roboadhoc

Copy link
Copy Markdown
Collaborator

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 mejora la usabilidad del asistente de recompute/revaluate agregando acciones masivas en la vista de lista para procesar múltiples registros seleccionados, manteniendo la lógica existente de procesamiento por registro.

Changes:

  • Agrega botones en el encabezado de la vista lista para Compute lines y Revaluate sobre la selección.
  • Implementa métodos “multi” con tope de selección (BATCH_LIMIT = 30) y filtrado por estado antes de delegar en los métodos existentes por registro.
  • Incorpora tests para el procesamiento masivo (compute) y el límite de batch, y actualiza la documentación de uso.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
stock_currency_valuation_recompute/views/stock_valuation_layer_recompute.xml Añade botones de acciones masivas en el header de la vista lista y confirmación para revaluar.
stock_currency_valuation_recompute/models/stock_valuation_layer_recompute.py Introduce BATCH_LIMIT, filtrado de selección y métodos action_*_multi que delegan en los métodos existentes.
stock_currency_valuation_recompute/tests/test_layer_recompute.py Agrega tests para compute masivo y rechazo por superar el límite; incluye un caso de error para revaluación masiva.
stock_currency_valuation_recompute/README.rst Documenta el uso de las acciones masivas desde la lista y el límite por batch.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +151 to +152
def test_revaluation_multi_skips_records_already_applied(self):
"""Revaluar en masa no vuelve a aplicar un registro ya aplicado."""
Comment on lines +474 to +477
def action_manual_slv_revaluation_multi(self):
"""Boton de la vista lista: aplica la seleccion de a un registro.

Solo los que estan en proceso: revaluar uno ya aplicado escribiria el ajuste
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