def l10n_mx_edi_update_sat_status(self): """Synchronize both systems: Odoo & SAT to make sure the invoice is valid. """ url = 'https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc?wsdl' for rec in self.filtered(lambda r: r.l10n_mx_edi_is_required() and r.l10n_mx_edi_pac_status in ['signed', 'cancelled']): supplier_rfc = rec.l10n_mx_edi_cfdi_supplier_rfc customer_rfc = rec.l10n_mx_edi_cfdi_customer_rfc total = 0 uuid = rec.l10n_mx_edi_cfdi_uuid params = '"?re=%s&rr=%s&tt=%s&id=%s' % ( html_escape(html_escape(supplier_rfc or '')), html_escape(html_escape(customer_rfc or '')), total or 0.0, uuid or '') try: response = Client(url).service.Consulta(params).Estado except Exception as e: rec.l10n_mx_edi_log_error(str(e)) continue rec.l10n_mx_edi_sat_status = CFDI_SAT_QR_STATE.get(response.__repr__(), 'none')
def l10n_mx_edi_update_sat_status(self): '''Synchronize both systems: Odoo & SAT to make sure the invoice is valid. ''' url = 'https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc?wsdl' for inv in self.filtered(lambda r: r.l10n_mx_edi_is_required()): if inv.l10n_mx_edi_pac_status not in ['signed', 'cancelled']: continue supplier_rfc = inv.l10n_mx_edi_cfdi_supplier_rfc customer_rfc = inv.l10n_mx_edi_cfdi_customer_rfc total = float_repr(inv.l10n_mx_edi_cfdi_amount, precision_digits=inv.currency_id.decimal_places) uuid = inv.l10n_mx_edi_cfdi_uuid params = '"?re=%s&rr=%s&tt=%s&id=%s' % ( tools.html_escape(tools.html_escape(supplier_rfc or '')), tools.html_escape(tools.html_escape(customer_rfc or '')), total or 0.0, uuid or '') try: response = Client(url).service.Consulta(params).Estado except Exception as e: inv.l10n_mx_edi_log_error(str(e)) continue inv.l10n_mx_edi_sat_status = CFDI_SAT_QR_STATE.get(response.__repr__(), 'none')
def l10n_mx_edi_update_sat_status(self): res = super(AccountInvoice, self).l10n_mx_edi_update_sat_status() url = 'https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc?wsdl' # noqa for inv in self.filtered( lambda r: r.type == 'in_invoice' and r.l10n_mx_edi_cfdi_uuid): supplier_rfc = inv.l10n_mx_edi_cfdi_supplier_rfc customer_rfc = inv.l10n_mx_edi_cfdi_customer_rfc total = float_repr(inv.l10n_mx_edi_cfdi_amount, precision_digits=inv.currency_id.decimal_places) uuid = inv.l10n_mx_edi_cfdi_uuid params = '"?re=%s&rr=%s&tt=%s&id=%s' % ( tools.html_escape(tools.html_escape(supplier_rfc or '')), tools.html_escape(tools.html_escape( customer_rfc or '')), total or 0.0, uuid or '') try: response = Client(url).service.Consulta(params).Estado except BaseException as e: inv.l10n_mx_edi_log_error(str(e)) continue inv.l10n_mx_edi_sat_status = CFDI_SAT_QR_STATE.get( response.__repr__(), 'none') return res