From bad0e501c0fefbf127595eb3c11dc81e5bc29092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Baranx=20=28bar=29?= Date: Tue, 7 Apr 2020 08:58:51 +0000 Subject: [PATCH] [FIX] stock: ambiguous product_id in init query During the upgrade of some databases to 13.0, the following traceback was reported: `psycopg2.errors.AmbiguousColumn: column reference "product_id" is ambiguous` This commit fixes this issue by prefixing product_id with the table name alias 'm'. closes odoo/odoo#49927 X-original-commit: 0e3c5d3ee1726db2641cd683a84fe59e867d4319 Signed-off-by: Simon Lejeune (sle) --- addons/stock/report/report_stock_quantity.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/stock/report/report_stock_quantity.py b/addons/stock/report/report_stock_quantity.py index 20b85686baf..de1392f93ca 100644 --- a/addons/stock/report/report_stock_quantity.py +++ b/addons/stock/report/report_stock_quantity.py @@ -28,12 +28,12 @@ class ReportStockQuantity(models.Model): CREATE or REPLACE VIEW report_stock_quantity AS ( SELECT m.id, - product_id, + m.product_id, CASE WHEN (whs.id IS NOT NULL AND whd.id IS NULL) OR ls.usage = 'transit' THEN 'out' WHEN (whs.id IS NULL AND whd.id IS NOT NULL) OR ld.usage = 'transit' THEN 'in' END AS state, - date_expected::date AS date, + m.date_expected::date AS date, CASE WHEN (whs.id IS NOT NULL AND whd.id IS NULL) OR ls.usage = 'transit' THEN -product_qty WHEN (whs.id IS NULL AND whd.id IS NOT NULL) OR ld.usage = 'transit' THEN product_qty @@ -60,10 +60,10 @@ WHERE UNION SELECT -q.id as id, - product_id, + q.product_id, 'forecast' as state, date.*::date, - quantity as product_qty, + q.quantity as product_qty, q.company_id, wh.id as warehouse_id FROM @@ -78,16 +78,16 @@ WHERE UNION SELECT m.id, - product_id, + m.product_id, 'forecast' as state, GENERATE_SERIES( CASE WHEN m.state = 'done' THEN (now() at time zone 'utc')::date - interval '3month' - ELSE date_expected::date + ELSE m.date_expected::date END, CASE WHEN m.state != 'done' THEN (now() at time zone 'utc')::date + interval '3 month' - ELSE date::date - interval '1 day' + ELSE m.date::date - interval '1 day' END, '1 day'::interval)::date date, CASE WHEN ((whs.id IS NOT NULL AND whd.id IS NULL) OR ls.usage = 'transit') AND m.state = 'done' THEN product_qty