Commit 5d303672 authored by Edilianny Sánchez's avatar Edilianny Sánchez 💻
Browse files

[FIX] invoice_xunnel: Avoid creating new attached xml and signing it

- When attaching a customer invoice, it must not sign the xml or create
  a new one, it must associate the attachment that is uploaded and
  update the status (pac, sat) of the invoice.
parent 4088ee65
Pipeline #93942 failed with stages
in 21 minutes and 48 seconds
......@@ -34,7 +34,10 @@ class AccountInvoice(models.Model):
self.l10n_mx_edi_cfdi_name = fname
return self.env['ir.attachment'].with_context({}).create(data_attach)
res = self.env['ir.attachment'].with_context({}).create(data_attach)
if self._context.get('l10n_mx_edi_invoice_type') == 'out':
self.l10n_mx_edi_pac_status = 'signed'
return res
def create_adjustment_line(self, xml_amount):
"""If the invoice has difference with the total in the CFDI is
......@@ -54,6 +57,21 @@ class AccountInvoice(models.Model):
return True
def post(self):
if self._context.get('l10n_mx_edi_invoice_type') == 'out':
attach_invoices = self.filtered(
lambda inv: inv.state == 'draft' and inv.l10n_mx_edi_pac_status == 'signed')
attachs = [(inv, inv.l10n_mx_edi_retrieve_last_attachment()) for inv in attach_invoices]
res = super().post()
for inv, att in attachs: = inv.l10n_mx_edi_cfdi_name
return res
# Sync SAT status if not set yet (Vendor Bills)
res = super(AccountInvoice, self).post()
vendor_bills = self.filtered(lambda inv: inv.is_purchase_document() and inv.l10n_mx_edi_cfdi_name)
return res
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
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