[FIX] stock_declared_value + stock_ux: bugs v19 (product_uom_id rename + location context)#904
Open
matiasgibbons wants to merge 2 commits intoingadhoc:19.0from
Open
[FIX] stock_declared_value + stock_ux: bugs v19 (product_uom_id rename + location context)#904matiasgibbons wants to merge 2 commits intoingadhoc:19.0from
matiasgibbons wants to merge 2 commits intoingadhoc:19.0from
Conversation
…19 compat) In v19 the field stock.move.line.product_uom was renamed to product_uom_id. Four accesses in stock_declared_value/models/stock_picking.py still used the old name on move_line recordsets (stock.move.line), causing AttributeError when the _compute_declared_value method runs. Note: move_line.product_uom_qty (a distinct Float field) was NOT renamed — it keeps the same name in v19 and is left untouched.
Collaborator
There was a problem hiding this comment.
Pull request overview
Este PR corrige una incompatibilidad con Odoo v19 en stock_declared_value, actualizando accesos al campo renombrado en stock.move.line para evitar AttributeError durante el cómputo del valor declarado post-migración.
Changes:
- Sustituye
move_line.product_uompormove_line.product_uom_iden la comparación de UoM. - Actualiza las conversiones de cantidad para usar
move_line.product_uom_id._compute_quantity(...). - Ajusta el
with_context(uom=...)del pricelist para referenciarmove_line.product_uom_id.id.
Dos bugs en `_compute_product_uom_qty_location` (stock_move_line.py) que se
disparan al abrir cualquier vista de stock.move.line filtrada por location:
1. `location[0]` asume que `location` es list/tuple/str. En Odoo 19 algunas
vistas lo pasan como `int` (ID único de stock.location) → crashea con
`TypeError: 'int' object is not subscriptable`. Ahora normaliza los 3
casos (int / list-tuple / str).
2. El lookup posterior usaba `browse(id).reference`, campo que NO existe
en stock.location (en v18 tampoco, probablemente residuo de un rename
muy viejo). Crasheaba con
`AttributeError: 'stock.location' object has no attribute 'reference'`.
Fijo a `.complete_name`, que es el campo consistente con la `search`
posterior `('complete_name', 'ilike', location_name)`.
Validado con ORM shell en 4 casos (int / list[int] / str / ""), todos
retornan resultados consistentes y sin excepción.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

Dos fixes de compat v19 en este PR.
1.
stock_declared_value:move_line.product_uom→product_uom_idEn v19 el campo
stock.move.line.product_uomse renombró aproduct_uom_id. Cuatro accesos enstock_declared_value/models/stock_picking.pyseguían usando el nombre viejo sobre un recordsetstock.move.line(move_line), tirandoAttributeErrorcuando corre_compute_declared_valuepost-migración.Cambios en
_compute_declared_value:move_line.product_uom != order_line.product_uom_id→move_line.product_uom_id != order_line.product_uom_idmove_line.product_uom._compute_quantity(...)(dos llamadas) →move_line.product_uom_id._compute_quantity(...)with_context(uom=move_line.product_uom.id)→with_context(uom=move_line.product_uom_id.id)Nota:
move_line.product_uom_qtyes un Float distinto que mantiene el mismo nombre en v19 y no se toca. Solo el Many2oneproduct_uom/product_uom_idnecesitaba el rename.2.
stock_ux: crash de_compute_product_uom_qty_locationcon location contextDos bugs en
stock_ux/models/stock_move_line.py::_compute_product_uom_qty_locationque rompen cualquier vista destock.move.linefiltrada por location:location[0]asume list/tuple/str. En Odoo 19 algunas vistas lo pasan comoint(ID único) →TypeError: 'int' object is not subscriptable. Ahora normaliza los 3 casos (int / list-tuple / str).browse(id).referencefalla porquestock.locationno tiene ese campo (en v18 tampoco existía, probablemente residuo de un rename viejo). Fijo a.complete_name, consistente con elsearch([('complete_name', 'ilike', ...)])de la línea siguiente.Validado con ORM shell en DB v19 real (4 casos: int / list[int] / str / "").
Test plan
stock_declared_valueystock_uxinstalados.stock.move.linefiltradas por location (selector → location específica) cargan sin crash.Module version bumps:
stock_declared_value: (commit previo)stock_ux:19.0.1.3.0 → 19.0.1.3.1