Commit c1728853 authored by Cuauhtémoc Díaz Minor's avatar Cuauhtémoc Díaz Minor

perf(base.cfdi): cambios necesarios para la integracion con account.invoice

Se crea el campo `cfdi_folio_fiscal` y se relaciona con cfdi_id
 En la funcion de `cancel_cfdi()`
se modifica la logica para la cancelacion de CFDi 3.3, de la cancelacion del CFDI con el pac se
espera saber si la cancelacion se realiza o no
parent 3d8c2e02
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import logging
from datetime import datetime from datetime import datetime
from pytz import timezone, UTC from pytz import timezone, UTC
from openerp import api, fields, models from openerp import api, fields, models
_logger = logging.getLogger(__name__)
def _sanitize(text): def _sanitize(text):
# Chars not allowed on CFDI # Chars not allowed on CFDI
...@@ -67,6 +71,10 @@ class BaseCfdi(models.AbstractModel): ...@@ -67,6 +71,10 @@ class BaseCfdi(models.AbstractModel):
'ir.attachment.facturae.mx', 'CFDI', copy=False, 'ir.attachment.facturae.mx', 'CFDI', copy=False,
help='CFDI realed to the selected record.', help='CFDI realed to the selected record.',
) )
cfdi_folio_fiscal = fields.Char(
'CFD-I Folio Fiscal', related='cfdi_id.uuid',
help='Folio used in the electronic invoice',
)
cfdi_state = fields.Selection(related='cfdi_id.state') cfdi_state = fields.Selection(related='cfdi_id.state')
cfdi_relation_type = fields.Many2one( cfdi_relation_type = fields.Many2one(
'cfdi.relation.type', 'CFDI Relation type', copy=False, 'cfdi.relation.type', 'CFDI Relation type', copy=False,
...@@ -93,5 +101,8 @@ class BaseCfdi(models.AbstractModel): ...@@ -93,5 +101,8 @@ class BaseCfdi(models.AbstractModel):
def cancel_cfdi(self): def cancel_cfdi(self):
"""Cancels the cfdi related with current record and delete relation""" """Cancels the cfdi related with current record and delete relation"""
if self.cfdi_id and self.cfdi_id.state in ['signed', 'done']: if self.cfdi_id and self.cfdi_id.state in ['signed', 'done']:
self.cfdi_id.action_cancel() cancelacion = self.cfdi_id.action_cancel()
self.cfdi_id = False if cancelacion:
self.cfdi_id = False
return cancelacion
return cancelacion
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