From cacdcb4b5b89cb0af8867af7ff3dd9d6cfcf4c59 Mon Sep 17 00:00:00 2001 From: Sergio Morillo Date: Tue, 4 Jul 2017 11:44:44 +0200 Subject: [PATCH] Add reset invoice SII keys --- invoice.py | 32 +++++++++++++++++++++++++------- locale/es_ES.po | 10 +++++++++- view/account_invoice_form.xml | 19 +++++++++++++------ view/account_invoice_list.xml | 1 + 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/invoice.py b/invoice.py index 8b2b9b3..f0df11e 100644 --- a/invoice.py +++ b/invoice.py @@ -1,6 +1,6 @@ # The COPYRIGHT file at the top level of this repository contains the full # copyright notices and license terms. -from trytond.model import fields +from trytond.model import ModelView, fields from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval from trytond.transaction import Transaction @@ -58,6 +58,11 @@ class Invoice: cls._check_modify_exclude += ['sii_book_key', 'sii_operation_key', 'sii_received_key', 'sii_issued_key', 'sii_subjected_key', 'sii_excemption_key', 'sii_intracomunity_key'] + cls._buttons.update({ + 'reset_sii_keys': { + 'invisible': Eval('sii_state', None) != None, + 'icon': 'tryton-executable'} + }) @staticmethod def default_sii_operation_key(): @@ -147,18 +152,20 @@ class Invoice: res['sii_operation_key'] = 'R4' return res + def _set_sii_keys(self): + tax = self.taxes and self.taxes[0] + if not tax: + return + for field in _SII_INVOICE_KEYS: + setattr(self, field, getattr(tax.tax, field)) + @fields.depends(*_SII_INVOICE_KEYS) def _on_change_lines_taxes(self): super(Invoice, self)._on_change_lines_taxes() for field in _SII_INVOICE_KEYS: if getattr(self, field): return - - tax = self.taxes and self.taxes[0] - if not tax: - return - for field in _SII_INVOICE_KEYS: - setattr(self, field, getattr(tax.tax, field)) + self._set_sii_keys() @classmethod def copy(cls, records, default=None): @@ -168,6 +175,17 @@ class Invoice: default['sii_records'] = None return super(Invoice, cls).copy(records, default=default) + @classmethod + @ModelView.button + def reset_sii_keys(cls, records): + to_write = [] + for record in records: + record._set_sii_keys() + to_write.extend(([record], record._save_values)) + + if to_write: + cls.write(*to_write) + class Sale: __metaclass__ = PoolMeta diff --git a/locale/es_ES.po b/locale/es_ES.po index cb2bc12..066f8e0 100644 --- a/locale/es_ES.po +++ b/locale/es_ES.po @@ -458,6 +458,10 @@ msgctxt "model:ir.action,name:act_aeat_sii_report_lines" msgid "SII Report Lines" msgstr "Líneas informe SII" +msgctxt "model:ir.ui.menu,name:None" +msgid "AEAT SII Report" +msgstr "Informe AEAT SII" + msgctxt "model:ir.ui.menu,name:menu_aeat_sii_lines_report" msgid "AEAT SII Report Lines" msgstr "Líneas informe AEAT SII" @@ -1567,9 +1571,13 @@ msgid "Residence certificate" msgstr "Certificado de residencia" msgctxt "view:account.invoice:" -msgid "Aeat SII" +msgid "AEAT SII" msgstr "AEAT SII" +msgctxt "view:account.invoice:" +msgid "Reset SII Keys" +msgstr "Reiniciar claves SII" + msgctxt "view:account.tax.template:" msgid "AEAT SII" msgstr "AEAT SII" diff --git a/view/account_invoice_form.xml b/view/account_invoice_form.xml index 64ba303..17c9f5b 100644 --- a/view/account_invoice_form.xml +++ b/view/account_invoice_form.xml @@ -2,8 +2,8 @@ - - + +