Add reset invoice SII keys
This commit is contained in:
parent
90864e572a
commit
cacdcb4b5b
32
invoice.py
32
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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<!--The COPYRIGHT file at the top level of this repository
|
||||
contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/notebook" position="inside">
|
||||
<page id="sii" string="Aeat SII">
|
||||
<xpath expr="/form/notebook" position="inside">
|
||||
<page id="sii" string="AEAT SII" col="4">
|
||||
<label name="sii_book_key"/>
|
||||
<field name="sii_book_key" colspan="3"/>
|
||||
<label name="sii_operation_key"/>
|
||||
|
@ -19,10 +19,17 @@ contains the full copyright notices and license terms. -->
|
|||
<label name="sii_excemption_key"/>
|
||||
<field name="sii_excemption_key" colspan="3"/>
|
||||
<field name="sii_records" colspan="4"/>
|
||||
<label name="sii_communication_type"/>
|
||||
<field name="sii_communication_type"/>
|
||||
<label name="sii_state"/>
|
||||
<field name="sii_state"/>
|
||||
<group col="4" colspan="4" id="state_buttons">
|
||||
<group col="2" colspan="2" id="states">
|
||||
<label name="sii_communication_type"/>
|
||||
<field name="sii_communication_type"/>
|
||||
<label name="sii_state"/>
|
||||
<field name="sii_state"/>
|
||||
</group>
|
||||
<group col="1" colspan="2" id="buttons">
|
||||
<button name="reset_sii_keys" string="Reset SII Keys"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
</data>
|
||||
|
|
|
@ -7,5 +7,6 @@ contains the full copyright notices and license terms. -->
|
|||
<field name="sii_operation_key"/>
|
||||
<field name="sii_communication_type"/>
|
||||
<field name="sii_state"/>
|
||||
<button name="reset_sii_keys" string="Reset SII Keys" tree_invisible="1"/>
|
||||
</xpath>
|
||||
</data>
|
||||
|
|
Loading…
Reference in New Issue