Migración a la nueva versión
INSERT INTO ir_attachment_facturae_mx (res_id, name, company_id, uuid, file_xml_sign, cfdi_type, type_attachment, state) (SELECT DISTINCT ON (payslip.id) res_id, payslip.number AS name, payslip.company_id AS company_id, payslip.cfdi_folio_fiscal AS uuid, xml.id AS file_xml_sign, pdf.id AS file_pdf_sign, 'outgoing' AS cfdi_type, 'hr.payslip' AS type_attachment, 'done' AS state FROM hr_payslip AS payslip INNER JOIN ir_attachment AS xml ON payslip.id = xml.res_id INNER JOIN ir_attachment AS pdf ON payslip.id = pdf.res_id WHERE payslip.cfdi_folio_fiscal IS NOT null AND payslip.state NOT IN ('draft', 'cancel') AND xml.res_model = 'hr.payslip' AND xml.file_type IN ('text/xml', 'application/xml', 'text/plain') AND pdf.res_model = 'hr.payslip' AND pdf.file_type IN ('application/pdf') );
UPDATE hr_payslip hp SET cfdi_id=a.id FROM (SELECT id, type_attachment, state, res_id FROM ir_attachment_facturae_mx) AS a WHERE a.type_attachment='hr.payslip' AND a.state='done' AND a.res_id = hp.id;