[IMP] stock_currency_valuation_recompute: recompute and revaluate from the list - #1010
Open
feg-adhoc wants to merge 1 commit into
Open
[IMP] stock_currency_valuation_recompute: recompute and revaluate from the list#1010feg-adhoc wants to merge 1 commit into
feg-adhoc wants to merge 1 commit into
Conversation
…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.
Collaborator
There was a problem hiding this comment.
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 |
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.

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:
draft,in_processandno_change.in_process, since revaluating a record that is alreadydonewould 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_recomputetests, 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— adonerecord 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.