From 8e31f4eff0cb29b04df612a1abcae1472ffed15a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20D=C3=ADaz=20Miralles?= Date: Wed, 25 May 2022 14:10:57 +0200 Subject: [PATCH] Add max_sii_lines to account configuration. This commit refs #23138. --- account.py | 5 +++++ aeat.py | 9 +++++---- locale/es.po | 10 +++++++++- view/configuration_form.xml | 2 ++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/account.py b/account.py index c1fd454..6f6c3c9 100644 --- a/account.py +++ b/account.py @@ -28,6 +28,11 @@ class Configuration(metaclass=PoolMeta): 'invisible': ~Eval('aeat_received_sii', False), }, depends=['aeat_received_sii'], help='Automatically send AEAT Received SII reports by cron') + max_sii_lines = fields.Integer('Max SII lines', help='Indicates the ' + 'maximum number of invoices to be included in each SII book.', + domain=['OR', + [('max_sii_lines', '=', None)], + [('max_sii_lines', '>', 0)]]) @staticmethod def default_aeat_pending_sii(): diff --git a/aeat.py b/aeat.py index 7948268..0da5d5b 100644 --- a/aeat.py +++ b/aeat.py @@ -1070,16 +1070,17 @@ class SIIReport(Workflow, ModelSQL, ModelView): pool = Pool() SIIReport = pool.get('aeat.sii.report') SIIReportLine = pool.get('aeat.sii.report.lines') - Company = Pool().get('company.company') + Company = pool.get('company.company') + Configuration = pool.get('account.configuration') + configuration = Configuration(1) company = Transaction().context.get('company') company = Company(company) - company_vat = company.party.sii_vat_code + max_sii_lines = configuration.max_sii_lines or MAX_SII_LINES cursor = Transaction().connection.cursor() report_line_table = SIIReportLine.__table__() - reports = [] reports = [] for company, book_invoices in company_invoices.items(): company = Company(company) @@ -1088,7 +1089,7 @@ class SIIReport(Workflow, ModelSQL, ModelView): values = book_invoices[operation] delete = True if operation == 'D0' else False for period, invoices in values.items(): - for invs in grouped_slice(invoices, MAX_SII_LINES): + for invs in grouped_slice(invoices, max_sii_lines): report = SIIReport() report.company = company report.company_vat = company_vat diff --git a/locale/es.po b/locale/es.po index 8a58b55..7f2439b 100644 --- a/locale/es.po +++ b/locale/es.po @@ -1866,4 +1866,12 @@ msgstr "Confirmado" msgctxt "model:ir.action.act_window.domain,name:act_aeat_sii_issued_reports_all" msgid "All" -msgstr "Todo" \ No newline at end of file +msgstr "Todo" + +msgctxt "field:account.configuration,max_sii_lines:" +msgid "Max SII lines" +msgstr "Máximo líneas SII" + +msgctxt "help:account.configuration,max_sii_lines:" +msgid "Indicates the maximum number of invoices to be included in each SII book." +msgstr "Indica el número máximo de facturas a incluir por libro del SII." \ No newline at end of file diff --git a/view/configuration_form.xml b/view/configuration_form.xml index 9f7965c..904bdf4 100644 --- a/view/configuration_form.xml +++ b/view/configuration_form.xml @@ -12,6 +12,8 @@ copyright notices and license types. -->