mirror of
https://gitlab.com/datalifeit/trytond-aeat_sii
synced 2023-12-13 20:30:37 +01:00
Add fill keys on invoice sale/purchase
Merge from changset-087f67664279 and changeset-295373bac60d
This commit is contained in:
parent
2660453818
commit
7d4ebabc70
3 changed files with 45 additions and 1 deletions
|
@ -17,6 +17,8 @@ def register():
|
|||
party.Party,
|
||||
company.Company,
|
||||
invoice.Invoice,
|
||||
invoice.Sale,
|
||||
invoice.Purchase,
|
||||
load_pkcs12.LoadPKCS12Start,
|
||||
aeat.SIIReport,
|
||||
aeat.SIIReportLine,
|
||||
|
|
42
invoice.py
42
invoice.py
|
@ -13,7 +13,7 @@ from .aeat import (
|
|||
EXCEMPTION_CAUSE, INTRACOMUNITARY_TYPE, COMMUNICATION_TYPE)
|
||||
|
||||
|
||||
__all__ = ['Invoice']
|
||||
__all__ = ['Invoice', 'Sale', 'Purchase']
|
||||
|
||||
_SII_INVOICE_KEYS = ['sii_book_key', 'sii_issued_key', 'sii_received_key',
|
||||
'sii_subjected_key', 'sii_excemption_key',
|
||||
|
@ -155,3 +155,43 @@ class Invoice:
|
|||
default = default.copy()
|
||||
default['sii_records'] = None
|
||||
return super(Invoice, cls).copy(records, default=default)
|
||||
|
||||
|
||||
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
|
||||
|
|
|
@ -5,6 +5,8 @@ depends:
|
|||
extras_depend:
|
||||
account_es
|
||||
account_es_pyme
|
||||
sale
|
||||
purchase
|
||||
xml:
|
||||
account.xml
|
||||
aeat.xml
|
||||
|
|
Loading…
Reference in a new issue