Created
May 21, 2018 16:23
-
-
Save josemoralesp/8214e8baef18916ec3ed2b81ba40dfcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH partner_move AS ( | |
SELECT | |
p.partner_id, | |
m.id | |
FROM | |
stock_move AS m | |
INNER JOIN | |
purchase_order_line AS pl ON pl.id=m.purchase_line_id | |
INNER JOIN | |
purchase_order AS p ON p.id=pl.order_id | |
WHERE | |
m.purchase_line_id IS NOT NULL AND | |
m.partner_id IS NULL) | |
UPDATE | |
stock_move AS m | |
SET | |
partner_id=pm.partner_id | |
FROM | |
partner_move AS pm | |
WHERE | |
m.id=pm.id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment