Commit f1054043 authored by agb80's avatar agb80

feat(account.invoice): add CfdiRelacionados node on credit notes

When creating a credit note related with an invoice now we are setting the node CfdiRelacionados to

acomplish with CFDI 3.3 rules

Closes #6
parent 4dae4653
......@@ -199,6 +199,21 @@ class AccountInvoice(models.Model):
res['value']['cfdi_use'] = partner.cfdi_use
return res
@api.model
def _prepare_refund(
self, invoice, date=None, period_id=None, description=None,
journal_id=None,
):
"""Overrides the preprare refund function to set field UsoCFDI"""
values = super(AccountInvoice, self)._prepare_refund(
invoice, date=date, period_id=period_id, description=description,
journal_id=journal_id,
)
# We set field UsoCFDI to Descuentos y devoluciones for all refunds
usocfdi = self.env.ref('l10n_mx.cfdi_use_G02')
values['cfdi_use'] = usocfdi.id
return values
@signals.invoice_validate.connect
def sign_invoice_sat(self, cr, uid, ids, context=None):
context = dict(context or {})
......
......@@ -31,14 +31,14 @@
{% otherwise %}MetodoPago="$o.payment_term.payment_method_id.code"{% end %}
{% end %}
LugarExpedicion="${ o.company_id.zip }" >
{#{% if o.cfdi_related_type %}
{% if o.refund_invoice_id.exists() %}
<cfdi:CfdiRelacionados
TipoRelacion="{{ o.cfdi_related_type }}">
{% for cfdi in o.cfdi_related %}
<cfdi:CfdiRelacionado UUID="{{ cfdi.uuid }}"/>
TipoRelacion="01">
{% for cfdi in o.refund_invoice_id %}
<cfdi:CfdiRelacionado UUID="${ cfdi.cfdi_folio_fiscal }"/>
{% end %}
</cfdi:CfdiRelacionados>
{% end %} #}
{% end %}
<cfdi:Emisor
{% choose o.company_id.partner_id.vat_split %}
{% when '' %}${ validationerror(_('Missing VAT number for company')) }{% end %}
......
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