feat: restore fiscal invoice as default report

This commit is contained in:
José Arturo García
2026-08-30 08:27:42 -04:00
parent 62849f7945
commit 7e62a9d430
8 changed files with 3324 additions and 2 deletions
+4
View File
@@ -4,6 +4,7 @@ from . import ncf_manager
from . import sequence
from . import configuration
from . import party
from . import report
def register():
Pool.register(
@@ -17,3 +18,6 @@ def register():
party.PartyNcfType,
party.Party,
module='ncf_manager', type_='model')
Pool.register(
report.InvoiceReport,
module='ncf_manager', type_='report')
+3261
View File
File diff suppressed because it is too large Load Diff
+11
View File
@@ -27,6 +27,17 @@ this repository contains the full copyright notices and license terms. -->
<field name="inherit" ref="account_invoice.invoice_line_view_tree"/>
<field name="name">invoice_line_tree</field>
</record>
<record model="ir.action.report" id="account_invoice.report_invoice">
<field name="name">Factura</field>
<field name="active" eval="True"/>
<field name="model">account.invoice</field>
<field name="report_name">account.invoice</field>
<field name="report">ncf_manager/invoice.fodt</field>
<field name="template_extension">odt</field>
<field name="extension">pdf</field>
<field name="single" eval="True"/>
</record>
</data>
</tryton>
+4
View File
@@ -119,6 +119,10 @@ msgstr "Gestión de NCF"
# Class: Invoice
# Model: account.invoice
msgctxt "model:ir.action,name:report_invoice"
msgid "Factura"
msgstr "Factura"
msgctxt "field:account.invoice,expiration_date:"
msgid "Expiration Date"
msgstr "Fecha de Vencimiento"
+20
View File
@@ -0,0 +1,20 @@
from trytond.pool import PoolMeta
class InvoiceReport(metaclass=PoolMeta):
"""Add the NCF label required by the fiscal invoice template."""
__name__ = 'account.invoice'
@classmethod
def get_context(cls, records, header, data):
context = super().get_context(records, header, data)
invoice = context['invoice']
context['ncf_type_name'] = cls._get_ncf_type_name(invoice)
return context
@staticmethod
def _get_ncf_type_name(invoice):
if not invoice.ncf_type:
return ''
return invoice.__class__._ncf_type_label_map().get(
invoice.ncf_type, '')
+1 -1
View File
@@ -83,7 +83,7 @@ setup(name=name,
),
package_data={
'trytond.modules.ncf_manager': (info.get('xml', [])
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po',
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
'icons/*.svg', 'tests/*.rst']),
},
classifiers=[
+22
View File
@@ -1,10 +1,32 @@
from pathlib import Path
from trytond.tests.test_tryton import ModuleTestCase
from trytond.modules.ncf_manager.report import InvoiceReport
class NcfManagerTestCase(ModuleTestCase):
"Test Ncf Manager module"
module = 'ncf_manager'
def test_fiscal_report_overrides_single_invoice_action(self):
report_xml = (Path(__file__).parent.parent / 'invoice.xml').read_text()
self.assertIn('id="account_invoice.report_invoice"', report_xml)
self.assertIn('ncf_manager/invoice.fodt', report_xml)
self.assertNotIn('ir.action.keyword', report_xml)
def test_fiscal_report_resolves_ncf_label(self):
class Invoice:
ncf_type = '31'
@staticmethod
def _ncf_type_label_map():
return {'31': 'Factura de Crédito Fiscal'}
self.assertEqual(
InvoiceReport._get_ncf_type_name(Invoice()),
'Factura de Crédito Fiscal')
del ModuleTestCase
+1 -1
View File
@@ -1,5 +1,5 @@
[tryton]
version=7.0.1
version=7.0.2
depends:
account_invoice_do
xml: