mirror of
https://gitlab.com/datalifeit/trytond-account_es_sii
synced 2023-12-14 06:13:02 +01:00
parent
3c2bae4052
commit
3c7a47b9c7
|
@ -24,14 +24,6 @@ def register():
|
|||
aeat_mapping.IssuedTrytonInvoiceMapper,
|
||||
aeat_mapping.RecievedTrytonInvoiceMapper,
|
||||
module='aeat_sii', type_='model')
|
||||
Pool.register(
|
||||
invoice.Sale,
|
||||
depends=['sale'],
|
||||
module='aeat_sii', type_='model')
|
||||
Pool.register(
|
||||
invoice.Purchase,
|
||||
depends=['purchase'],
|
||||
module='aeat_sii', type_='model')
|
||||
Pool.register(
|
||||
load_pkcs12.LoadPKCS12,
|
||||
module='aeat_sii', type_='wizard')
|
||||
|
|
54
invoice.py
54
invoice.py
|
@ -200,6 +200,22 @@ class Invoice(metaclass=PoolMeta):
|
|||
return
|
||||
self._set_sii_keys()
|
||||
|
||||
@classmethod
|
||||
def update_taxes(cls, invoices, exception=False):
|
||||
super().update_taxes(invoices, exception=exception)
|
||||
to_save = []
|
||||
for invoice in invoices:
|
||||
set_keys = True
|
||||
for field in _SII_INVOICE_KEYS:
|
||||
if getattr(invoice, field):
|
||||
set_keys = False
|
||||
break
|
||||
if set_keys:
|
||||
invoice._set_sii_keys()
|
||||
to_save.append(invoice)
|
||||
if to_save:
|
||||
cls.save(to_save)
|
||||
|
||||
@classmethod
|
||||
def copy(cls, records, default=None):
|
||||
if default is None:
|
||||
|
@ -235,44 +251,6 @@ class Invoice(metaclass=PoolMeta):
|
|||
cls.raise_user_warning(warning_name, 'invoices_sii', invoices_sii)
|
||||
|
||||
|
||||
class Sale(metaclass=PoolMeta):
|
||||
__name__ = 'sale.sale'
|
||||
|
||||
def create_invoice(self):
|
||||
invoice = super(Sale, self).create_invoice()
|
||||
if not invoice:
|
||||
return
|
||||
|
||||
tax = invoice.taxes and invoice.taxes[0]
|
||||
if not tax:
|
||||
return invoice
|
||||
|
||||
for field in _SII_INVOICE_KEYS:
|
||||
setattr(invoice, field, getattr(tax.tax, field))
|
||||
invoice.save()
|
||||
|
||||
return invoice
|
||||
|
||||
|
||||
class Purchase(metaclass=PoolMeta):
|
||||
__name__ = 'purchase.purchase'
|
||||
|
||||
def create_invoice(self):
|
||||
invoice = super(Purchase, self).create_invoice()
|
||||
if not invoice:
|
||||
return
|
||||
|
||||
tax = invoice.taxes and invoice.taxes[0]
|
||||
if not tax:
|
||||
return invoice
|
||||
|
||||
for field in _SII_INVOICE_KEYS:
|
||||
setattr(invoice, field, getattr(tax.tax, field))
|
||||
invoice.save()
|
||||
|
||||
return invoice
|
||||
|
||||
|
||||
class Invoice2(metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice'
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ depends:
|
|||
account_invoice_company_currency
|
||||
account_es
|
||||
extras_depend:
|
||||
sale
|
||||
purchase
|
||||
account_invoice_intercompany
|
||||
account_invoice_posted2draft
|
||||
xml:
|
||||
|
|
Loading…
Reference in a new issue