[17.0] repair: not-null constraint conflict
Los mantenedores suelen responder en 3 días
@SirPyTech ya está trabajando en esto.
Desde el 15/9/2026.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 22/100
Línea de trabajo
The failing step is the DELETE on stock_location (id 26) in openupgrade_scripts/scripts/repair/17.0.1.0/post-migration.py, which cascades into an UPDATE of repair_order.location_dest_id. Start by reading the earlier UPDATE repair_order statements that set location_dest_id = 26 and the stock_location foreign keys in the logged ALTER TABLE steps. Done means the repair migration completes on a database with these rows without a not-null violation.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The migration is failing due to a conflict between OpenUpgrade's data cleanup logic. The failure occurs because a temporary action by the migration script—deleting a placeholder location (ID 26 in this case)—triggers a ON DELETE SET NULL, but the field being updated (location_dest_id) is simultaneously required to be non-empty (NOT NULL).
Module
Repair
Describe the bug
OpenUpgrade runs ALTER TABLE commands to add the new Odoo 17 stock location fields.
ALTER TABLE "repair_order" ADD COLUMN "location_dest_id" int4
Later the scripts does this:
JOIN stock_location sld ON sld.id = rl.location_dest_id
And this:
UPDATE repair_order ro SET ... location_dest_id = spt.default_location_dest_id ...
The OpenUpgrade script reaches its final cleanup stage and attempts to delete the temporary location ID 26:
OpenUpgrade Action: DELETE FROM "stock_location" WHERE id IN (26). Because one or more constraints exist between stock_location and repair_order (likely set to ON DELETE SET NULL), the database automatically attempts to run the cascade query: UPDATE ONLY "public"."repair_order" SET "location_dest_id" = NULL WHERE ... location_dest_id = 26
The Conflict: null value in column "location_dest_id" violates not-null constraint
Additional context
Python 3.12
The uncommented log for the reference
2025-12-13 17:27:16,238 15469 DEBUG odoo17 OpenUpgrade: -1 rows affected after 0:00:00.001639 running ALTER TABLE "stock_warehouse" ADD COLUMN "repair_type_id" int4
2025-12-13 17:27:16,240 15469 DEBUG odoo17 OpenUpgrade: -1 rows affected after 0:00:00.000961 running ALTER TABLE "repair_order" ADD COLUMN "picking_type_id" int4
2025-12-13 17:27:16,241 15469 DEBUG odoo17 OpenUpgrade: -1 rows affected after 0:00:00.000792 running ALTER TABLE "repair_order" ADD COLUMN "location_dest_id" int4
2025-12-13 17:27:16,242 15469 DEBUG odoo17 OpenUpgrade: -1 rows affected after 0:00:00.000492 running ALTER TABLE "repair_order" ADD COLUMN "parts_location_id" int4
2025-12-13 17:27:16,244 15469 DEBUG odoo17 OpenUpgrade: -1 rows affected after 0:00:00.000506 running ALTER TABLE "repair_order" ADD COLUMN "recycle_location_id" int4
2025-12-13 17:27:18,848 15469 DEBUG odoo17 OpenUpgrade: 8317 rows affected after 0:00:02.006967 running
UPDATE repair_order
SET picking_type_id = 14,
location_dest_id = 26,
parts_location_id = 26,
recycle_location_id = 26
.......
2025-12-13 17:27:31,364 15469 DEBUG odoo17 OpenUpgrade: 71 rows affected after 0:00:00.069785 running
INSERT INTO stock_move (
old_repair_line_id,
sequence, priority,
propagate_cancel,
additional,
picked,
create_uid, create_date, write_uid, write_date,
repair_id, repair_line_type,
picking_type_id, location_id, location_dest_id,
product_id, product_uom,
product_uom_qty, product_qty, quantity,
name, description_picking,
date, company_id,
origin, reference,
procure_method,
scrapped,
state
)
SELECT rl.id,
10 AS sequence, '0' AS priority,
true AS propagate_cancel,
false AS additional,
false AS picked,
rl.create_uid, rl.create_date, rl.write_uid, rl.write_date,
rl.repair_id, rl.type AS repair_line_type,
ro.picking_type_id, rl.location_id, rl.location_dest_id,
rl.product_id, rl.product_uom,
rl.product_uom_qty,
ROUND(
((rl.product_uom_qty / rl_uom.factor) * pt_uom.factor),
SCALE(pt_uom.rounding)
) AS product_qty,
0 AS quantity,
ro.name, rl.name AS description_picking,
ro.schedule_date AS date, rl.company_id,
ro.name AS origin, ro.name AS reference,
'make_to_stock' AS procure_method,
sld.scrap_location AS scrapped,
CASE WHEN ro.state IN ('draft', 'cancel')
THEN ro.state ELSE 'confirmed'
END AS state
FROM repair_line rl
JOIN repair_order ro ON rl.repair_id = ro.id
JOIN stock_location sld ON sld.id = rl.location_dest_id
JOIN product_product pp ON pp.id = rl.product_id
JOIN product_template pt ON pt.id = pp.product_tmpl_id
JOIN uom_uom rl_uom ON rl_uom.id = rl.product_uom
JOIN uom_uom pt_uom ON pt_uom.id = pt.uom_id
WHERE rl.move_id IS NULL AND rl.type IS NOT NULL
......
2025-12-13 17:27:32,875 15469 DEBUG odoo17 OpenUpgrade: 4991 rows affected after 0:00:01.497093 running
UPDATE repair_order ro
SET picking_type_id = sw.repair_type_id,
location_dest_id = spt.default_location_dest_id,
parts_location_id = spt.default_remove_location_dest_id,
recycle_location_id = spt.default_recycle_location_dest_id
FROM stock_location sl
JOIN stock_warehouse sw ON sw.id = sl.warehouse_id
JOIN stock_picking_type spt ON spt.id = sw.repair_type_id
WHERE ro.location_id = sl.id
....
2025-12-13 17:27:33,719 15469 ERROR odoo17 odoo.sql_db: bad query: DELETE FROM "stock_location" WHERE id IN (26)
ERROR: null value in column "location_dest_id" violates not-null constraint
DETAIL: Failing row contains (5247, 17098, 2021-06-16 06:49:54.830732, 1, null, 1, 1.00, null, null, 17098, 9, 9, 9, 1, 1.89, done, 1, t, 2025-12-13 17:27:10.292693, 17098, 121308, 10.89, RMA21386, null, after_repair, 582, t, null, 9, 25728, null, 2021-06-16 00:00:00, null, 0, null, done, 14, null, 26, 26, null, null, null, f, f).
CONTEXT: SQL statement "UPDATE ONLY "public"."repair_order" SET "location_dest_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "location_dest_id""
2025-12-13 17:27:33,719 15469 ERROR odoo17 OpenUpgrade: repair: error in migration script /opt/odoo/openupgrade17/OpenUpgrade/openupgrade_scripts/scripts/repair/17.0.1.0/post-migration.py: null value in column "location_dest_id" violates not-null constraint
DETAIL: Failing row contains (5247, 17098, 2021-06-16 06:49:54.830732, 1, null, 1, 1.00, null, null, 17098, 9, 9, 9, 1, 1.89, done, 1, t, 2025-12-13 17:27:10.292693, 17098, 121308, 10.89, RMA21386, null, after_repair, 582, t, null, 9, 25728, null, 2021-06-16 00:00:00, null, 0, null, done, 14, null, 26, 26, null, null, null, f, f).
CONTEXT: SQL statement "UPDATE ONLY "public"."repair_order" SET "location_dest_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "location_dest_id""
2025-12-13 17:27:33,720 15469 ERROR odoo17 OpenUpgrade: null value in column "location_dest_id" violates not-null constraint
DETAIL: Failing row contains (5247, 17098, 2021-06-16 06:49:54.830732, 1, null, 1, 1.00, null, null, 17098, 9, 9, 9, 1, 1.89, done, 1, t, 2025-12-13 17:27:10.292693, 17098, 121308, 10.89, RMA21386, null, after_repair, 582, t, null, 9, 25728, null, 2021-06-16 00:00:00, null, 0, null, done, 14, null, 26, 26, null, null, null, f, f).
CONTEXT: SQL statement "UPDATE ONLY "public"."repair_order" SET "location_dest_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "location_dest_id""
- Lenguaje dominante
- Python
- Estrellas
- 995
- Forks
- 837
- Merge medio
- 2 d 8 h
- PR fusionados (30 d)
- 12
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de OCA/OpenUpgrade
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
OCA/OpenUpgrade#5380 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
Migration to version 20.0Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
OCA/OpenUpgrade#6044 · 6 comentarios · 6 reacciones ·
Los mantenedores suelen responder en 3 días
-
bug
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
OCA/OpenUpgrade#6004 · 5 comentarios ·
Los mantenedores suelen responder en 3 días
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
OCA/OpenUpgrade#5594 ·
Los mantenedores suelen responder en 3 días
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 20/100
OCA/OpenUpgrade#5592 · 1 comentario ·
Los mantenedores suelen responder en 3 días
Todos los issues de OCA/OpenUpgrade
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
vllm-project/vllm#64845 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
dekobon/big-code-analysis#1729 ·
Los mantenedores suelen responder en 1 día
-
Add `openai_safety_identifier`, the replacement for the `user` field that `openai_user` sendsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
pydantic/pydantic-ai#12091 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100