From d7488ed6d9f32ac0d004211c2b76e6c1439fcaf8 Mon Sep 17 00:00:00 2001 From: Bernat Brunet Date: Fri, 18 Aug 2023 12:50:23 +0200 Subject: [PATCH] Make possible to not send and not create the Facturae automatically and allow to do it manually. Or send by any of the services selected or create only the file and do not send. --- account.py | 3 ++- invoice.py | 33 +++++++++++++++++---------------- locale/ca.po | 8 ++++++++ locale/es.po | 8 ++++++++ 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/account.py b/account.py index d529ca3..b4e7566 100644 --- a/account.py +++ b/account.py @@ -77,7 +77,8 @@ class ConfigurationFacturae(ModelSQL, CompanyValueMixin): facturae_certificate = fields.Many2One('certificate', "Factura-e Certificate", help='Certificate to sign Factura-e') facturae_service = fields.Selection([ - (None, 'Only Generate Facturae'), + (None, 'None'), + ('only_file', 'Only Generate Facturae'), ], "Factura-e Service") @staticmethod diff --git a/invoice.py b/invoice.py index 81b0690..88bd23d 100644 --- a/invoice.py +++ b/invoice.py @@ -255,24 +255,24 @@ class Invoice(metaclass=PoolMeta): config = Configuration(1) transaction = Transaction() - if not self.invoice_facturae: - facturae_content = self.get_facturae() - self._validate_facturae(facturae_content) - if backend.name != 'sqlite': - invoice_facturae = self._sign_facturae(facturae_content, - 'default', certificate) - else: - invoice_facturae = facturae_content - self.invoice_facturae = invoice_facturae - self.save() - # send facturae to service if not service and config.facturae_service: service = config.facturae_service - if self.invoice_facturae and service: - with transaction.set_context( - queue_scheduled_at=config.invoice_facturae_after): - Invoice.__queue__.send_facturae(self, service) + if not self.invoice_facturae: + facturae_content = self.get_facturae() + self._validate_facturae(facturae_content) + if backend.name != 'sqlite': + invoice_facturae = self._sign_facturae(facturae_content, + 'default', certificate) + else: + invoice_facturae = facturae_content + self.invoice_facturae = invoice_facturae + self.save() + + if self.invoice_facturae and service and service != 'only_file': + with transaction.set_context( + queue_scheduled_at=config.invoice_facturae_after): + Invoice.__queue__.send_facturae(self, service) def send_facturae(self, service): Invoice = Pool().get('account.invoice') @@ -816,7 +816,8 @@ class GenerateFacturaeStart(ModelView): 'Generate Factura-e file - Start' __name__ = 'account.invoice.generate_facturae.start' service = fields.Selection([ - (None, 'Only generate facturae'), + (None, 'None'), + ('only_file', 'Only Generate Facturae'), ], 'Factura-e Service') certificate = fields.Many2One('certificate', 'Factura-e Certificate', depends=['service']) diff --git a/locale/ca.po b/locale/ca.po index 7a8353d..eea9f07 100644 --- a/locale/ca.po +++ b/locale/ca.po @@ -895,6 +895,14 @@ msgctxt "selection:account.configuration.facturae,facturae_service:" msgid "Only Generate Facturae" msgstr "Només genera la Factura-e" +msgctxt "selection:account.configuration.facturae,service:" +msgid "None" +msgstr "Cap" + msgctxt "selection:account.invoice.generate_facturae.start,service:" msgid "Only Generate Facturae" msgstr "Només genera la Factura-e" + +msgctxt "selection:account.invoice.generate_facturae.start,service:" +msgid "None" +msgstr "Cap" diff --git a/locale/es.po b/locale/es.po index 0f049d1..a68698f 100644 --- a/locale/es.po +++ b/locale/es.po @@ -889,6 +889,14 @@ msgctxt "selection:account.configuration.facturae,service:" msgid "Only Generate Facturae" msgstr "Solo genera la Factura-e" +msgctxt "selection:account.configuration.facturae,service:" +msgid "None" +msgstr "Ninguno" + msgctxt "selection:account.invoice.generate_facturae.start,service:" msgid "Only Generate Facturae" msgstr "Solo genera la Factura-e" + +msgctxt "selection:account.invoice.generate_facturae.start,service:" +msgid "None" +msgstr "Ninguno"