Skip to content

[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
matiasgibbons:19.0
Open

[FIX] stock_declared_value + stock_ux: bugs v19 (product_uom_id rename + location context)#904
matiasgibbons wants to merge 2 commits intoingadhoc:19.0from
matiasgibbons:19.0

Conversation

@matiasgibbons
Copy link
Copy Markdown

@matiasgibbons matiasgibbons commented Apr 17, 2026

Dos fixes de compat v19 en este PR.

1. stock_declared_value: move_line.product_uomproduct_uom_id

En v19 el campo stock.move.line.product_uom se renombró a product_uom_id. Cuatro accesos en stock_declared_value/models/stock_picking.py seguían usando el nombre viejo sobre un recordset stock.move.line (move_line), tirando AttributeError cuando corre _compute_declared_value post-migración.

Cambios en _compute_declared_value:

  • move_line.product_uom != order_line.product_uom_idmove_line.product_uom_id != order_line.product_uom_id
  • move_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_qty es un Float distinto que mantiene el mismo nombre en v19 y no se toca. Solo el Many2one product_uom / product_uom_id necesitaba el rename.

2. stock_ux: crash de _compute_product_uom_qty_location con location context

Dos bugs en stock_ux/models/stock_move_line.py::_compute_product_uom_qty_location que rompen cualquier vista de stock.move.line filtrada por location:

  • location[0] asume list/tuple/str. En Odoo 19 algunas vistas lo pasan como int (ID único) → TypeError: 'int' object is not subscriptable. Ahora normaliza los 3 casos (int / list-tuple / str).
  • browse(id).reference falla porque stock.location no tiene ese campo (en v18 tampoco existía, probablemente residuo de un rename viejo). Fijo a .complete_name, consistente con el search([('complete_name', 'ilike', ...)]) de la línea siguiente.

Validado con ORM shell en DB v19 real (4 casos: int / list[int] / str / "").

Test plan

  • Migrada DB de producción real (v18 → v19 via upgrade.odoo.com) con stock_declared_value y stock_ux instalados.
  • Pickings con declared value y move_lines con UoMs distintas calculan la cantidad correcta post-fix.
  • Vistas stock.move.line filtradas 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

…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.
@roboadhoc
Copy link
Copy Markdown
Collaborator

Pull request status dashboard

Copilot AI review requested due to automatic review settings April 17, 2026 04:03
Copy link
Copy Markdown

Copilot AI left a comment

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 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_uom por move_line.product_uom_id en 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 referenciar move_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>
@matiasgibbons matiasgibbons changed the title [FIX] stock_declared_value: move_line.product_uom → product_uom_id (v19 compat) [FIX] stock_declared_value + stock_ux: bugs v19 (product_uom_id rename + location context) Apr 21, 2026
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