feat(ir.attachment.facturae.mx): soporte para la tarea cron de cancelacion

se crea la funcion undo_waiting_state(), si al verificar un cfdi en estado waiting y la cancelacion
es negada por el cliente, entonces regresa del estado waiting a done o signed
parent af212fde
......@@ -542,17 +542,18 @@ class IrAttachmentFacturaeMx(models.Model):
TODO: Cancel outgoing CFDIs
"""
# Ensure this method is called only for one record
self.ensure_one()
if self.cfdi_type == "incoming" and self.state in ("signed", "done"):
if self.cfdi_type == "incoming" and self.state in ("signed", "done","waiting"):
cancel_answer = self.cancel_cfdi_sat()[0]
if cancel_answer:
self.cancel_cfdi()
else:
elif cancel_answer is None:
self.write({
"state": "waiting",
})
else:
self.undo_waiting_state()
return cancel_answer
def sign_xml(self, xml_data):
......@@ -822,6 +823,20 @@ class IrAttachmentFacturaeMx(models.Model):
# Call function which connects with PACs
return params_pacs.cancel_cfdi(uuid=self.uuid)
@api.multi
def undo_waiting_state(self):
'''when cancel is negate, undo waiting state'''
self.ensure_one()
if self.state in ("waiting"):
if self.file_pdf:
self.write({
"state": "done"
})
else:
self.write({
"state": "signed"
})
@api.model
def cancel_cfdi(self):
''' Cancel CFDI and rewrite PDF
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment