Skip to content

Instantly share code, notes, and snippets.

@josemoralesp
Created February 23, 2019 01:58
Show Gist options
  • Save josemoralesp/5c9ea2e037af6f1491ff48c3292d1a8e to your computer and use it in GitHub Desktop.
Save josemoralesp/5c9ea2e037af6f1491ff48c3292d1a8e to your computer and use it in GitHub Desktop.
SELECT
i.id,
i.number,
att1.datas_fname,
att1.store_fname
FROM
account_invoice AS i
JOIN
ir_attachment AS att1 ON (i.id = att1.res_id AND att1.res_model = 'account.invoice' AND att1.l10n_mx_edi_uuid IS NOT NULL)
LEFT OUTER JOIN
ir_attachment AS att2 ON (i.id = att2.res_id AND
(att1.create_date < att2.create_date OR
att1.create_date = att2.create_date AND att1.id < att2.id))
WHERE
att2.id IS NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment