Commit ab258794 authored by agb80's avatar agb80

feat(base.cfdi): agrega soporte para la cancelación de CFDIs

Facilita la cancelación de archivos CFDI estandarizando el llamado a través del mixin `base.cfdi`
parent a55957de
Pipeline #5374 failed with stage
in 2 minutes and 38 seconds
......@@ -68,6 +68,15 @@ class BaseCfdi(models.AbstractModel):
help='CFDI realed to the selected record.',
)
cfdi_state = fields.Selection(related='cfdi_id.state')
cfdi_relation_type = fields.Many2one(
'cfdi.relation.type', 'CFDI Relation type', copy=False,
)
related_cfdi_ids = fields.Many2many(
'ir.attachment.facturae.mx', 'cfdis_related_rel',
'related_cfdi_id', 'original_cfdi_id', 'Refund invoices',
readonly=True, copy=False,
help='Original CFDI to which this CFDI is referred to',
)
@api.one
def create_cfdi(self):
......@@ -79,3 +88,10 @@ class BaseCfdi(models.AbstractModel):
'company_id': self.company_id.id,
})
self.cfdi_id.action_validate()
@api.one
def cancel_cfdi(self):
"""Cancels the cfdi related with current record and delete relation"""
if self.cfdi_id and self.cfdi_id.state in ['signed', 'done']:
self.cfdi_id.action_cancel()
self.cfdi_id = False
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