[FIX] stock_account: stock history performance

Using BIGINT id instead of Text
 - This doesn't change the behavior, just the variable type,
   while being much more efficient.
Using `UNION ALL` instead of simple `UNION`
 - This doesn't change the behavior either,
   as the ids of each sub select cannot collide

Closes #9197
opw-650598
This commit is contained in:
Nicolas Seinlet 2015-10-22 14:56:13 +02:00 committed by Denis Ledoux
parent 8f6caf9785
commit 29bd622521
1 changed files with 3 additions and 3 deletions

View File

@ -129,7 +129,7 @@ class stock_history(osv.osv):
source
FROM
((SELECT
stock_move.id::text || '-' || quant.id::text AS id,
stock_move.id AS id,
quant.id AS quant_id,
stock_move.id AS move_id,
dest_location.id AS location_id,
@ -156,9 +156,9 @@ class stock_history(osv.osv):
(source_location.company_id is not null and dest_location.company_id is null) or
source_location.company_id != dest_location.company_id or
source_location.usage not in ('internal', 'transit'))
) UNION
) UNION ALL
(SELECT
'-' || stock_move.id::text || '-' || quant.id::text AS id,
(-1) * stock_move.id AS id,
quant.id AS quant_id,
stock_move.id AS move_id,
source_location.id AS location_id,