Skip to content

Commit cbe4422

Browse files
matiasgibbonsclaude
andcommitted
[FIX] stock_ux: location context crash + field .reference inexistente
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>
1 parent e2f3b32 commit cbe4422

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

stock_ux/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
##############################################################################
2020
{
2121
"name": "Stock UX",
22-
"version": "19.0.1.3.0",
22+
"version": "19.0.1.3.1",
2323
"category": "Warehouse Management",
2424
"sequence": 14,
2525
"summary": "",

stock_ux/models/stock_move_line.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,18 @@ def _compute_product_uom_qty_location(self):
3636
if not location:
3737
self.update({"product_uom_qty_location": 0.0})
3838
return False
39-
# because now we use location_id to select location, we have compelte
40-
# location name. If y need we can use some code of
41-
# _get_domain_locations on stock/product.py
42-
location_name = location[0]
43-
if isinstance(location[0], int):
44-
location_name = self.env["stock.location"].browse(location[0]).reference
39+
# `location` puede venir como int (ID único), list/tuple de ints, o string.
40+
# En v19 algunas vistas lo pasan como int directo → location[0] explota.
41+
if isinstance(location, int):
42+
location_name = self.env["stock.location"].browse(location).complete_name
43+
elif isinstance(location, (list, tuple)):
44+
first = location[0]
45+
location_name = (
46+
self.env["stock.location"].browse(first).complete_name
47+
if isinstance(first, int) else first
48+
)
49+
else:
50+
location_name = location # string
4551
locations = self.env["stock.location"].search([("complete_name", "ilike", location_name)])
4652
for rec in self:
4753
product_uom_qty_location = rec.quantity

0 commit comments

Comments
 (0)