Skip to content

Instantly share code, notes, and snippets.

@ovnicraft
Created June 25, 2019 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ovnicraft/fc30f885f45687e6be6927f801562243 to your computer and use it in GitHub Desktop.
Save ovnicraft/fc30f885f45687e6be6927f801562243 to your computer and use it in GitHub Desktop.
select sum(product_qty) filter (spt.code = 'incoming') as incoming, product_id, sloc.name, sm.location_id, picking_type_id, spt.code
from stock_move sm
inner join stock_picking_type spt on sm.picking_type_id = spt.id
left join stock_location sloc on sm.location_id = sloc.id
left join stock_location slocd on sm.location_dest_id = slocd.id
where sm.state = 'done'
and inventory_id is null
group by product_id, sloc.name, sm.location_id, picking_type_id, spt.code;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment