diff --git a/l10n_mx_facturae/__openerp__.py b/l10n_mx_facturae/__openerp__.py index 1eabee2907ef04ed1c67f6a1fdfe746a71bad3c2..4c458e99c53cba1f0bb6c507c18f6d9a17e89d8d 100644 --- a/l10n_mx_facturae/__openerp__.py +++ b/l10n_mx_facturae/__openerp__.py @@ -21,8 +21,10 @@ ], 'data': [ 'views/account_invoice.xml', + 'views/account_voucher.xml', 'views/res_partner.xml', 'report/account_invoice.xml', + 'report/account_voucher.xml', 'data/email_template.xml', 'data/ir_attachment_facturae_config.xml', ], diff --git a/l10n_mx_facturae/data/ir_attachment_facturae_config.xml b/l10n_mx_facturae/data/ir_attachment_facturae_config.xml index 817eecf6507412220409c37226405101bd2acaee..1f97cb2d8588b444f554dcaeb676eb121799f9f2 100644 --- a/l10n_mx_facturae/data/ir_attachment_facturae_config.xml +++ b/l10n_mx_facturae/data/ir_attachment_facturae_config.xml @@ -21,6 +21,15 @@ <field name="template_pdf_cancel">invoice.report.aaero</field> <field name="email_template_id" ref="email_template_template_facturae_mx"/> </record> + <record id="ir_attachment_facturae_mx_config_account_voucher_33" model="ir.attachment.facturae.mx.config"> + <field name="model">account.voucher</field> + <field name="version">3.3</field> + <field name="template_xml_sign">account.voucher.cfdi.xml.33</field> + <field name="template_xml_cancel">Aun.no.hay.uno</field> + <field name="template_pdf_sign">account.voucher.cfdi.pdf</field> + <field name="template_pdf_cancel">account.voucher.cfdi.pdf</field> + <field name="email_template_id" ref="email_template_template_facturae_mx"/> + </record> </data> </openerp> diff --git a/l10n_mx_facturae/models/__init__.py b/l10n_mx_facturae/models/__init__.py index 9db21c3b3e270f96fe2abf4fbc2ec9083ae65673..58e8d343b7915fbfd86595b38f1d32b237072109 100644 --- a/l10n_mx_facturae/models/__init__.py +++ b/l10n_mx_facturae/models/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from . import account_invoice +from . import account_voucher from . import email_template from . import res_partner diff --git a/l10n_mx_facturae/models/account_invoice.py b/l10n_mx_facturae/models/account_invoice.py index 9131cf22b32b4b378d4240600853e3f507f628f3..4cc90ae1d77494fbfed8f792fc39a286aca1b1ba 100644 --- a/l10n_mx_facturae/models/account_invoice.py +++ b/l10n_mx_facturae/models/account_invoice.py @@ -2,7 +2,6 @@ import logging from datetime import datetime - from pytz import timezone, UTC from openerp import api, fields, models @@ -30,9 +29,8 @@ class AccountInvoice(models.Model): if self.state == 'draft': return '' fname = '_'.join([ - self.company_id.partner_id.vat_split or - self.company_id.partner_id.vat, self.number or - self.internal_number, + self.company_id.partner_id.vat_split, + self.number or self.internal_number, ]) return fname @@ -63,7 +61,7 @@ class AccountInvoice(models.Model): """ self.ensure_one() try: - code = self.payment_type[0].code + code = self.payment_type_ids[0].code except IndexError: code = '99' return code @@ -88,10 +86,9 @@ class AccountInvoice(models.Model): def total(self): self.ensure_one() return ( - self.subtotal - - self.descuento - + self.impuestos['total_traslados'] - - self.impuestos['total_retenciones'] + self.subtotal - self.descuento + + self.impuestos['total_traslados'] - + self.impuestos['total_retenciones'] ) @property diff --git a/l10n_mx_facturae/models/account_voucher.py b/l10n_mx_facturae/models/account_voucher.py new file mode 100644 index 0000000000000000000000000000000000000000..054415d8fa6f8f531a535cbf358718e03d9f6241 --- /dev/null +++ b/l10n_mx_facturae/models/account_voucher.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- + +from openerp import api, models + + +class AccountVoucher(models.Model): + _name = 'account.voucher' + _inherit = [ + 'account.voucher', + 'base.cfdi', + ] + + @api.multi + def sign_voucher(self): + """Create CFDI for selected vouchers""" + # Only vouchers to sign are the receipts + receipts = self.filtered(lambda r: r.type == 'receipt') + # Get only receipts that doesn't have a CFDI yet and create it + receipts.filtered(lambda r: not r.cfdi_id.exists()).create_cfdi() + + @property + def doctos_relacionados(self): + """Return a list with all related invoices to this payment""" + self.ensure_one() + + # Get all records from account.move.line related to this voucher but + # affecting an account different than the selected for this voucher + move_lines = self.move_ids.filtered( + lambda x: x.account_id != self.account_id, + ) + # Get all lines form partial and full reconciliations + temp_lines = move_lines.mapped('reconcile_partial_id.line_partial_ids') + temp_lines |= move_lines.mapped('reconcile_id.line_id') + + # Get invoices related to this voucher + invoices = (temp_lines - move_lines).mapped('invoice') + return invoices + + @api.multi + def numparcialidad(self, invoice): + """Computes payment number based on all payments done to invoice""" + return len(invoice.mapped('payment_ids')) - 1 + + @api.multi + def impsaldoant(self, invoice): + """Computes amount_residual for invoice before current voucher""" + self.ensure_one() + # Original residual amount for given invoice + amount_residual = invoice.amount_total + + # Get payments done to given invoice in vouchers older than current + payments = invoice.mapped('payment_ids') - self.move_ids + payments = payments.filtered(lambda r: r.date < self.date) + + for payment in payments: + amount_currency = abs(payment.amount_currency) or 0.0 + # If amount_currency exists it means we are dealing with a multi + # currency payment, and thus we need to sum amount_currency to + # amount_paid instead of normal debit - credit + if amount_currency: + amount_residual -= amount_currency + else: + amount_residual -= abs(payment.debit - payment.credit) + return self.currency_id.cfdi_round(amount_residual) + + @api.multi + def imppagado(self, invoice): + """Computes total amount payment on this voucher for given invoice""" + self.ensure_one() + + amount_paid = 0.0 + # Get payments done in this voucher for given invoice + payments = invoice.mapped('payment_ids') & self.move_ids + + for payment in payments: + amount_currency = abs(payment.amount_currency) or 0.0 + # If amount_currency exists it means we are dealing with a multi + # currency payment, and thus we need to sum amount_currency to + # amount_paid instead of normal debit - credit + if amount_currency: + amount_paid += amount_currency + else: + amount_paid += abs(payment.debit - payment.credit) + return self.currency_id.cfdi_round(amount_paid) diff --git a/l10n_mx_facturae/report/account_invoice.xml b/l10n_mx_facturae/report/account_invoice.xml index 782331c287ba81765bc7dae6ad55c585510ae54b..3031ec6ef328fbc2c173dd534682faaf22328b85 100644 --- a/l10n_mx_facturae/report/account_invoice.xml +++ b/l10n_mx_facturae/report/account_invoice.xml @@ -1,68 +1,68 @@ <?xml version="1.0" encoding="utf-8"?> <openerp> - <!-- XML invoice report definition --> - <data> - <record id="l10n_mx_facturae_template_xml" model="report.templates.aeroo"> - <field name="name">Defaut XML Invoice Report teplate</field> - <field name="model">account.invoice</field> - <field name="report_name">invoice.report.aaero.xml</field> - <field name="report_rml">l10n_mx_facturae/templates/account_invoice_32.txt</field> - <field name="tml_source">file</field> - </record> - <record id="l10n_mx_facturae_report_aeroo_xml" model="ir.actions.report.xml"> - <field name="name">Invoice XML Report aero</field> - <field name="type">ir.actions.report.xml</field> - <field name="model">account.invoice</field> - <field name="report_name">invoice.report.aaero.xml</field> - <field name="report_type">aeroo</field> - <field name="in_format">genshi-raw</field> - <field name="out_format" ref="report_aeroo.report_mimetypes_raw" /> - <field name="aeroo_templates_ids" - eval="[(6, 0, [l10n_mx_facturae_template_xml])]" /> - <field name="parser_state">default</field> - </record> +<!-- XML invoice report definition --> +<data> + <record id="l10n_mx_facturae_template_xml" model="report.templates.aeroo"> + <field name="name">Defaut XML Invoice Report teplate</field> + <field name="model">account.invoice</field> + <field name="report_name">invoice.report.aaero.xml</field> + <field name="report_rml">l10n_mx_facturae/templates/account_invoice_32.txt</field> + <field name="tml_source">file</field> + </record> + <record id="l10n_mx_facturae_report_aeroo_xml" model="ir.actions.report.xml"> + <field name="name">Invoice XML Report aero</field> + <field name="type">ir.actions.report.xml</field> + <field name="model">account.invoice</field> + <field name="report_name">invoice.report.aaero.xml</field> + <field name="report_type">aeroo</field> + <field name="in_format">genshi-raw</field> + <field name="out_format" ref="report_aeroo.report_mimetypes_raw" /> + <field name="aeroo_templates_ids" + eval="[(6, 0, [l10n_mx_facturae_template_xml])]" /> + <field name="parser_state">default</field> + </record> - <record id="report_templates_aeroo_account_invoice_cfdi_33" model="report.templates.aeroo"> - <field name="name">Account Invoice XML CFDI 3.3</field> - <field name="model">account.invoice</field> - <field name="report_name">account.invoice.cfdi.33</field> - <field name="report_rml">l10n_mx_facturae/templates/account_invoice_33.txt</field> - <field name="tml_source">file</field> - </record> - <record id="ir_actions_report_xml_account_invioice_cfdi_33" model="ir.actions.report.xml"> - <field name="name">Account Invoice XML CFDI 3.3</field> - <field name="type">ir.actions.report.xml</field> - <field name="model">account.invoice</field> - <field name="report_name">account.invoice.cfdi.xml.33</field> - <field name="report_type">aeroo</field> - <field name="in_format">genshi-raw</field> - <field name="out_format" ref="report_aeroo.report_mimetypes_raw" /> - <field name="aeroo_templates_ids" - eval="[(6, 0, [report_templates_aeroo_account_invoice_cfdi_33])]" /> - <field name="parser_state">default</field> - </record> - </data> + <record id="report_templates_aeroo_account_invoice_cfdi_33" model="report.templates.aeroo"> + <field name="name">Account Invoice XML CFDI 3.3</field> + <field name="model">account.invoice</field> + <field name="report_name">account.invoice.cfdi.33</field> + <field name="report_rml">l10n_mx_facturae/templates/account_invoice_33.txt</field> + <field name="tml_source">file</field> + </record> + <record id="ir_actions_report_xml_account_invioice_cfdi_33" model="ir.actions.report.xml"> + <field name="name">Account Invoice XML CFDI 3.3</field> + <field name="type">ir.actions.report.xml</field> + <field name="model">account.invoice</field> + <field name="report_name">account.invoice.cfdi.xml.33</field> + <field name="report_type">aeroo</field> + <field name="in_format">genshi-raw</field> + <field name="out_format" ref="report_aeroo.report_mimetypes_raw" /> + <field name="aeroo_templates_ids" + eval="[(6, 0, [report_templates_aeroo_account_invoice_cfdi_33])]" /> + <field name="parser_state">default</field> + </record> +</data> - <!-- PDF invoice report definition --> - <data noupdate="1"> - <record id="l10n_mx_facturae_template" model="report.templates.aeroo"> - <field name="name">Defaut Invoice Report teplate</field> - <field name="model">account.invoice</field> - <field name="report_name">invoice.report.aaero</field> - <field name="report_rml">l10n_mx_facturae/report/account_print_invoice.odt</field> - <field name="tml_source">file</field> - </record> - <record id="l10n_mx_facturae_report_aeroo" model="ir.actions.report.xml"> - <field name="name">Invoice Report aero</field> - <field name="type">ir.actions.report.xml</field> - <field name="model">account.invoice</field> - <field name="report_name">invoice.report.aaero</field> - <field name="report_type">aeroo</field> - <field name="in_format">oo-odt</field> - <field name="out_format" ref="report_aeroo.report_mimetypes_pdf_odt" /> - <field name="aeroo_templates_ids" eval="[(6, 0, [l10n_mx_facturae_template])]" /> - <field name="parser_state">default</field> - <field name="tml_source">file</field> - </record> - </data> +<!-- PDF invoice report definition --> +<data noupdate="1"> + <record id="l10n_mx_facturae_template" model="report.templates.aeroo"> + <field name="name">Defaut Invoice Report teplate</field> + <field name="model">account.invoice</field> + <field name="report_name">invoice.report.aaero</field> + <field name="report_rml">l10n_mx_facturae/report/account_invoice_33.odt</field> + <field name="tml_source">file</field> + </record> + <record id="l10n_mx_facturae_report_aeroo" model="ir.actions.report.xml"> + <field name="name">Invoice Report aero</field> + <field name="type">ir.actions.report.xml</field> + <field name="model">account.invoice</field> + <field name="report_name">invoice.report.aaero</field> + <field name="report_type">aeroo</field> + <field name="in_format">oo-odt</field> + <field name="out_format" ref="report_aeroo.report_mimetypes_pdf_odt" /> + <field name="aeroo_templates_ids" eval="[(6, 0, [l10n_mx_facturae_template])]" /> + <field name="parser_state">default</field> + <field name="tml_source">file</field> + </record> +</data> </openerp> diff --git a/l10n_mx_facturae/report/account_invoice_33.odt b/l10n_mx_facturae/report/account_invoice_33.odt index 5cd99497218f377113e97703291460595838f3df..fbc71528e584656782e7f38858cdbc1f5abb5a98 100644 Binary files a/l10n_mx_facturae/report/account_invoice_33.odt and b/l10n_mx_facturae/report/account_invoice_33.odt differ diff --git a/l10n_mx_facturae/report/account_print_invoice.odt b/l10n_mx_facturae/report/account_voucher.odt similarity index 100% rename from l10n_mx_facturae/report/account_print_invoice.odt rename to l10n_mx_facturae/report/account_voucher.odt diff --git a/l10n_mx_facturae/report/account_voucher.xml b/l10n_mx_facturae/report/account_voucher.xml new file mode 100644 index 0000000000000000000000000000000000000000..f914f7248da9eea2f85de356ca701c9176934403 --- /dev/null +++ b/l10n_mx_facturae/report/account_voucher.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> +<data> + <!-- XML invoice report definition --> + <record id="report_templates_aeroo_account_voucher_cfdi_33" model="report.templates.aeroo"> + <field name="name">Account Invoice XML CFDI 3.3</field> + <field name="model">account.voucher</field> + <field name="report_name">account.voucher.cfdi.33</field> + <field name="report_rml">l10n_mx_facturae/templates/account_voucher_33.txt</field> + <field name="tml_source">file</field> + </record> + <record id="ir_actions_report_xml_account_voucher_cfdi_33" model="ir.actions.report.xml"> + <field name="name">Account Voucher XML CFDI 3.3</field> + <field name="type">ir.actions.report.xml</field> + <field name="model">account.voucher</field> + <field name="report_name">account.voucher.cfdi.xml.33</field> + <field name="report_type">aeroo</field> + <field name="in_format">genshi-raw</field> + <field name="out_format" ref="report_aeroo.report_mimetypes_raw" /> + <field name="aeroo_templates_ids" + eval="[(6, 0, [report_templates_aeroo_account_voucher_cfdi_33])]" /> + <field name="parser_state">default</field> + </record> +</data> + +<data noupdate="1"> + <!-- PDF invoice report definition --> + <record id="report_templates_aeroo_account_voucher_cfdi_33" model="report.templates.aeroo"> + <field name="name">Defaut Voucher PDF</field> + <field name="model">account.voucher</field> + <field name="report_name">account.voucher.cfdi.33.pdf</field> + <field name="report_rml">l10n_mx_facturae/report/account_voucher.odt</field> + <field name="tml_source">file</field> + </record> + <record id="ir_actions_report_xml_account_voucher_cfdi_33" model="ir.actions.report.xml"> + <field name="name">Account Voucher CFDI PDF</field> + <field name="type">ir.actions.report.xml</field> + <field name="model">account.voucher</field> + <field name="report_name">account.voucher.cfdi.pdf</field> + <field name="report_type">aeroo</field> + <field name="in_format">oo-odt</field> + <field name="out_format" ref="report_aeroo.report_mimetypes_pdf_odt" /> + <field name="aeroo_templates_ids" eval="[(6, 0, [report_templates_aeroo_account_voucher_cfdi_33])]" /> + <field name="tml_source">file</field> + </record> +</data> +</openerp> diff --git a/l10n_mx_facturae/templates/account_invoice_33.txt b/l10n_mx_facturae/templates/account_invoice_33.txt index 8e48f5051a11f7acb781c5156614a9ee1aa44f68..3647867003976e0c531a24d70550bd653ec29f77 100644 --- a/l10n_mx_facturae/templates/account_invoice_33.txt +++ b/l10n_mx_facturae/templates/account_invoice_33.txt @@ -44,7 +44,7 @@ {% when '' %}${ validationerror(_('Missing VAT number for company')) }{% end %} {% otherwise %}Rfc="${ html_escape(o.company_id.partner_id.vat_split) }"{% end %} {% end %} - Nombre="${ o.company_id.name }" + Nombre="${ html_escape(o.company_id.name) }" RegimenFiscal="$o.company_id.account_position_id.code"/> <cfdi:Receptor {% choose o.partner_id.vat_split %} @@ -141,7 +141,7 @@ {% if taxes %} <cfdi:Impuestos TotalImpuestosTrasladados="${ '{0:.2f}'.format(taxes.total_traslados) }" - {% if taxes.retenciones %} + {% if taxes.total_retenciones %} TotalImpuestosRetenidos="${ '{0:.2f}'.format(abs(taxes.total_retenciones)) }" {% end %}> {% if taxes.traslados %} diff --git a/l10n_mx_facturae/templates/account_voucher_33.txt b/l10n_mx_facturae/templates/account_voucher_33.txt new file mode 100644 index 0000000000000000000000000000000000000000..a9752d80c17a0b790d1a9a8dbe1d7174e4108ac7 --- /dev/null +++ b/l10n_mx_facturae/templates/account_voucher_33.txt @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8"?> +{% python setLang(o.create_uid.lang or 'en_US') %} +<cfdi:Comprobante + xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd http://www.sat.gob.mx/Pagos http://www.sat.gob.mx/sitio_internet/cfd/Pagos/Pagos10.xsd" + xmlns:cfdi="http://www.sat.gob.mx/cfd/3" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:pago10="http://www.sat.gob.mx/Pagos" + Version="3.3" + {% if o.journal_id.sequence_id.prefix %} + Serie="$o.serie" + {% end %} + Folio="$o.folio" + Fecha="${ format_datetime(o.cfdi_datetime, '%Y-%m-%dT%H:%M:%S') }" + Sello="@" + NoCertificado="@" + Certificado="@" + SubTotal="0" + Moneda="XXX" + Total="0" + TipoDeComprobante="P" + LugarExpedicion="${ o.company_id.zip }" > + <cfdi:Emisor + {% choose o.company_id.partner_id.vat_split %} + {% when False %}${ validationerror(_('Missing VAT number for company')) }{% end %} + {% otherwise %}Rfc="${ html_escape(o.company_id.partner_id.vat_split) }"{% end %} + {% end %} + Nombre="${ html_escape(o.company_id.name) }" + RegimenFiscal="$o.company_id.account_position_id.code"/> + <cfdi:Receptor + {% choose o.partner_id.vat_split %} + {% when False %}${ validationerror(_('Missing VAT number for receiver')) }{% end %} + {% otherwise %}Rfc="${ html_escape(o.partner_id.vat_split) }"{% end %} + {% end %} + {% if o.partner_id.vat_split not in ('XAXX010101000', 'XEXX010101000') %} + Nombre="${ html_escape(o.partner_id.name) }" + {% end %} + {% if o.partner_id.country_id and o.partner_id.country_id.code != 'MX' %} + ResidenciaFiscal="$o.partner_id.country_id.code3" + NumRegIdTrib="${ html_escape(o.partner_id.vat) }" + {% end %} + UsoCFDI="P01" /> + <cfdi:Conceptos> + <cfdi:Concepto + ClaveProdServ="84111506" + Cantidad="1" + ClaveUnidad="ACT" + Descripcion="Pago" + ValorUnitario="0" + Importe="0" /> + </cfdi:Conceptos> + <cfdi:Complemento> + <pago10:Pagos Version="1.0"> + <pago10:Pago + FechaPago="${ format_date(o.date, '%Y-%m-%dT%H:%M:%S') }" + {% choose o.payment_type_id.code %} + {% when False %}${ validationerror(_('Missing payment method for voucher')) }{% end %} + {% when '99' %}${ validationerror(_('Payment method must be different than 99.')) }{% end %} + {% otherwise %}FormaDePagoP="${ o.payment_type_id.code }"{% end %} + {% end %} + MonedaP="${ o.currency_id.name }" + {% if o.currency_id.name != 'MXN' %} + TipoCambio="${ o.currency_rate }" + {% end %} + Monto="${ o.currency_id.cfdi_round(o.amount) }" + NumOperacion="${ o.number }" > + {% for invoice in o.doctos_relacionados %} + <pago10:DoctoRelacionado + IdDocumento="${ invoice.cfdi_folio_fiscal }" + MonedaDR="${ invoice.currency_id.name }" + {% if invoice.currency_id != o.currency_id %} + {% choose invoice.currency_id.name %} + {% when 'MXN' %}TipoCambioDR="1"{% end %} + {% otherwise %}TipoCambioDR="${ invoice.currency_rate }"{% end %} + {% end %} + {% end %} + {% choose invoice.payment_term.payment_method_id.code %} + {% when False %}MetodoDePagoDR="PUE"{% end %} + {% otherwise %} + MetodoDePagoDR="$invoice.payment_term.payment_method_id.code" + {% if invoice.payment_term.payment_method_id.code == 'PPD' %} + NumParcialidad="${ o.numparcialidad(invoice) }" + ImpSaldoAnt="${ o.impsaldoant(invoice) }" + ImpSaldoInsoluto="${ o.impsaldoant(invoice) - o.imppagado(invoice) }" + {% end %} + {% end %} + {% end %} + {% if invoice.payment_term.payment_method_id.code == 'PPD' or len(o.doctos_relacionados) > 1 %} + ImpPagado="${ o.imppagado(invoice) }" + {% end %} /> + {% end %} + </pago10:Pago> + </pago10:Pagos> + </cfdi:Complemento> +</cfdi:Comprobante> diff --git a/l10n_mx_facturae/views/account_invoice.xml b/l10n_mx_facturae/views/account_invoice.xml index 757710f0934c3d4eb51ce9527bfe646b36a53038..8ea0f3e20d8dc4bedaae1b877ba1a3c5696ceb23 100644 --- a/l10n_mx_facturae/views/account_invoice.xml +++ b/l10n_mx_facturae/views/account_invoice.xml @@ -22,12 +22,10 @@ attrs="{'readonly': [('state', 'in', ('paid', 'open', 'cancel'))]}" options="{'no_create':True}"/> </field> - <xpath expr="//field[@name='partner_id']" position="replace"> - <field string="Customer" name="partner_id" - on_change="onchange_partner_id(type,partner_id,date_invoice,payment_term, partner_bank_id,company_id)" - groups="base.group_user" context="{'search_default_customer':1, 'show_address': 1, 'default_is_company': 1}" - options="{'always_reload': True,'no_quick_create': True}" - domain="[('customer', '=', True), ('is_company', '=', True)]"/> + <xpath expr="//field[@name='partner_id']" position="attributes"> + <attribute name="context">{'search_default_customer':1, 'show_address': 1, 'default_is_company': 1}</attribute> + <attribute name="domain">[('customer', '=', True), ('is_company', '=', True)]</attribute> + <attribute name="options">{'always_reload': True,'no_quick_create': True}</attribute> </xpath> </field> </record> diff --git a/l10n_mx_facturae/views/account_voucher.xml b/l10n_mx_facturae/views/account_voucher.xml new file mode 100644 index 0000000000000000000000000000000000000000..2011dc0b350d1e90cb141cbe3d17c016920223d5 --- /dev/null +++ b/l10n_mx_facturae/views/account_voucher.xml @@ -0,0 +1,57 @@ +<?xml version="1.0"?> +<openerp> +<data> + + <record id="account_voucher_action_sign" model="ir.actions.server"> + <field name="name">Sign Vouchers</field> + <field name="type">ir.actions.server</field> + <field name="model_id" ref="model_account_voucher"/> + <field name="state">code</field> + <field name="code">self.sign_voucher(cr, uid, context.get('active_ids', []), context=context)</field> + </record> + + <record id="ir_values_action_sign" model="ir.values"> + <field name="name">Sign Vouchers</field> + <field name="action_id" ref="account_voucher_action_sign"/> + <field name="value" eval="'ir.actions.server,' + str(ref('account_voucher_action_sign'))"/> + <field name="key">action</field> + <field name="model_id" ref="model_account_voucher"/> + <field name="model">account.voucher</field> + <field name="key2">client_action_multi</field> + </record> + + <record id="account_voucher_view_form" model="ir.ui.view"> + <field name="name">account.voucher.view.form</field> + <field name="model">account.voucher</field> + <field name="inherit_id" ref="account_voucher.view_vendor_receipt_form"/> + <field name="arch" type="xml"> + <button name="proforma_voucher" position="after"> + <button name="sign_voucher" type="object" string="Sign" class="oe_highlight" attrs="{'invisible':['|',('state','!=','posted'),('cfdi_state','in',['signed', 'done'])]}"/> + </button> + <xpath expr="//sheet/h1" position="after"> + <h4 attrs="{'invisible': [('number','=',False)]}" collspan="2"> + <field string="Fiscal Number" name="cfdi_id" readonly="1"/> + <field name="cfdi_state" invisible="1"/> + </h4> + </xpath> + </field> + </record> + + <record id="account_voucher_view_search" model="ir.ui.view"> + <field name="name">account.voucher.view.search</field> + <field name="model">account.voucher</field> + <field name="inherit_id" ref="account_voucher.view_voucher_filter_customer_pay"/> + <field name="arch" type="xml"> + <field name="partner_id" position="after"> + <field name="cfdi_id" string="UUID" /> + </field> + <filter string="Posted" position="after"> + <separator/> + <filter string="Unsigned" domain="[('cfdi_id','=',False)]" help="Not Signed Vouchers"/> + <filter string="Signed" domain="[('cfdi_id','!=',False)]" help="Signed Vouchers"/> + </filter> + </field> + </record> + +</data> +</openerp>