mirror of
https://gitlab.com/datalifeit/trytond-aeat_sii
synced 2023-12-13 20:30:37 +01:00
Merged trytonspain/trytond-aeat_sii into default
This commit is contained in:
commit
8f8e583b98
14 changed files with 507 additions and 907 deletions
|
@ -1,4 +0,0 @@
|
||||||
|
|
||||||
\.pyc$
|
|
||||||
\.egg-info
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0"?>
|
||||||
|
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||||
|
copyright notices and license terms. -->
|
||||||
<tryton>
|
<tryton>
|
||||||
<data>
|
<data>
|
||||||
<record model="ir.ui.view" id="aeat_sii_tax_form_view">
|
<record model="ir.ui.view" id="aeat_sii_tax_form_view">
|
||||||
|
|
34
aeat.py
34
aeat.py
|
@ -1,14 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# The COPYRIGHT file at the top level of this repository contains the full
|
# The COPYRIGHT file at the top level of this repository contains the full
|
||||||
# copyright notices and license terms.
|
# copyright notices and license terms.
|
||||||
|
|
||||||
__all__ = [
|
|
||||||
'SIIReport',
|
|
||||||
'SIIReportLine',
|
|
||||||
'IssuedTrytonInvoiceMapper',
|
|
||||||
'RecievedTrytonInvoiceMapper',
|
|
||||||
]
|
|
||||||
|
|
||||||
import unicodedata
|
import unicodedata
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
@ -23,6 +15,8 @@ from trytond.pyson import Eval
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
|
__all__ = ['SIIReport', 'SIIReportLine',
|
||||||
|
'IssuedTrytonInvoiceMapper', 'RecievedTrytonInvoiceMapper']
|
||||||
|
|
||||||
_logger = getLogger(__name__)
|
_logger = getLogger(__name__)
|
||||||
_ZERO = Decimal('0.0')
|
_ZERO = Decimal('0.0')
|
||||||
|
@ -252,24 +246,20 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
||||||
'required': Eval('state').in_(['confirmed', 'done']),
|
'required': Eval('state').in_(['confirmed', 'done']),
|
||||||
'readonly': ~Eval('state').in_(['draft', 'confirmed']),
|
'readonly': ~Eval('state').in_(['draft', 'confirmed']),
|
||||||
}, depends=['state'])
|
}, depends=['state'])
|
||||||
|
|
||||||
period = fields.Many2One('account.period', 'Period', required=True,
|
period = fields.Many2One('account.period', 'Period', required=True,
|
||||||
domain=[('fiscalyear', '=', Eval('fiscalyear'))],
|
domain=[('fiscalyear', '=', Eval('fiscalyear'))],
|
||||||
states={
|
states={
|
||||||
'readonly': Eval('state') != 'draft',
|
'readonly': Eval('state') != 'draft',
|
||||||
}, depends=['state', 'fiscalyear'])
|
}, depends=['state', 'fiscalyear'])
|
||||||
|
|
||||||
operation_type = fields.Selection(COMMUNICATION_TYPE, 'Operation Type',
|
operation_type = fields.Selection(COMMUNICATION_TYPE, 'Operation Type',
|
||||||
required=True,
|
required=True,
|
||||||
states={
|
states={
|
||||||
'readonly': ~Eval('state').in_(['draft', 'confirmed']),
|
'readonly': ~Eval('state').in_(['draft', 'confirmed']),
|
||||||
}, depends=['state'])
|
}, depends=['state'])
|
||||||
|
|
||||||
book = fields.Selection(BOOK_KEY, 'Book', required=True,
|
book = fields.Selection(BOOK_KEY, 'Book', required=True,
|
||||||
states={
|
states={
|
||||||
'readonly': ~Eval('state').in_(['draft', 'confirmed']),
|
'readonly': ~Eval('state').in_(['draft', 'confirmed']),
|
||||||
}, depends=['state'])
|
}, depends=['state'])
|
||||||
|
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
('draft', 'Draft'),
|
('draft', 'Draft'),
|
||||||
('confirmed', 'Confirmed'),
|
('confirmed', 'Confirmed'),
|
||||||
|
@ -280,19 +270,14 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
||||||
|
|
||||||
communication_state = fields.Selection(AEAT_COMMUNICATION_STATE,
|
communication_state = fields.Selection(AEAT_COMMUNICATION_STATE,
|
||||||
'Communication State', readonly=True)
|
'Communication State', readonly=True)
|
||||||
|
csv = fields.Char('CSV', readonly=True)
|
||||||
csv = fields.Char(
|
|
||||||
'CSV', readonly=True
|
|
||||||
)
|
|
||||||
|
|
||||||
version = fields.Selection([
|
version = fields.Selection([
|
||||||
('0.7', '0.7'),
|
('0.7', '0.7'),
|
||||||
], 'Version', required=True, states={
|
], 'Version', required=True, states={
|
||||||
}, depends=['state'])
|
}, depends=['state'])
|
||||||
|
|
||||||
lines = fields.One2Many('aeat.sii.report.lines', 'report',
|
lines = fields.One2Many('aeat.sii.report.lines', 'report',
|
||||||
'Lines', states={
|
'Lines', states={
|
||||||
'readonly': ~Eval('state').in_(['draft']),
|
'readonly': Eval('state') != 'draft',
|
||||||
}, depends=['state'])
|
}, depends=['state'])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -321,7 +306,6 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
||||||
Eval('operation_type').in_(['A0', 'A1'])),
|
Eval('operation_type').in_(['A0', 'A1'])),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
cls._transitions |= set((
|
cls._transitions |= set((
|
||||||
('draft', 'confirmed'),
|
('draft', 'confirmed'),
|
||||||
('draft', 'cancelled'),
|
('draft', 'cancelled'),
|
||||||
|
@ -697,9 +681,8 @@ class BaseTrytonInvoiceMapper(Model):
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
class IssuedTrytonInvoiceMapper(
|
class IssuedTrytonInvoiceMapper(mapping.IssuedInvoiceMapper,
|
||||||
mapping.IssuedInvoiceMapper, BaseTrytonInvoiceMapper
|
BaseTrytonInvoiceMapper):
|
||||||
):
|
|
||||||
"""
|
"""
|
||||||
Tryton Issued Invoice to AEAT mapper
|
Tryton Issued Invoice to AEAT mapper
|
||||||
"""
|
"""
|
||||||
|
@ -708,9 +691,8 @@ class IssuedTrytonInvoiceMapper(
|
||||||
specialkey_or_trascendence = attrgetter('sii_issued_key')
|
specialkey_or_trascendence = attrgetter('sii_issued_key')
|
||||||
|
|
||||||
|
|
||||||
class RecievedTrytonInvoiceMapper(
|
class RecievedTrytonInvoiceMapper(mapping.RecievedInvoiceMapper,
|
||||||
mapping.RecievedInvoiceMapper, BaseTrytonInvoiceMapper
|
BaseTrytonInvoiceMapper):
|
||||||
):
|
|
||||||
"""
|
"""
|
||||||
Tryton Recieved Invoice to AEAT mapper
|
Tryton Recieved Invoice to AEAT mapper
|
||||||
"""
|
"""
|
||||||
|
|
8
aeat.xml
8
aeat.xml
|
@ -1,9 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0"?>
|
||||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||||
copyright notices and license terms. -->
|
copyright notices and license terms. -->
|
||||||
<tryton>
|
<tryton>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<record model="res.group" id="group_aeat_sii_admin">
|
<record model="res.group" id="group_aeat_sii_admin">
|
||||||
<field name="name">AEAT SII Administration</field>
|
<field name="name">AEAT SII Administration</field>
|
||||||
</record>
|
</record>
|
||||||
|
@ -57,7 +56,6 @@
|
||||||
<field name="perm_delete" eval="True"/>
|
<field name="perm_delete" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
<!-- aeat.sii.report.issued -->
|
<!-- aeat.sii.report.issued -->
|
||||||
<record model="ir.ui.view" id="aeat_sii_report_line_form_view">
|
<record model="ir.ui.view" id="aeat_sii_report_line_form_view">
|
||||||
<field name="model">aeat.sii.report.lines</field>
|
<field name="model">aeat.sii.report.lines</field>
|
||||||
|
@ -87,7 +85,6 @@
|
||||||
<field name="act_window" ref="act_aeat_sii_report_line"/>
|
<field name="act_window" ref="act_aeat_sii_report_line"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
<record model="ir.model.access" id="access_aeat_sii_report_line">
|
<record model="ir.model.access" id="access_aeat_sii_report_line">
|
||||||
<field name="model" search="[('model', '=', 'aeat.sii.report.lines')]"/>
|
<field name="model" search="[('model', '=', 'aeat.sii.report.lines')]"/>
|
||||||
<field name="perm_read" eval="True"/>
|
<field name="perm_read" eval="True"/>
|
||||||
|
@ -196,6 +193,5 @@
|
||||||
id="menu_aeat_sii_report"
|
id="menu_aeat_sii_report"
|
||||||
parent="menu_aeat_sii_report_menu" sequence="10"
|
parent="menu_aeat_sii_report_menu" sequence="10"
|
||||||
name="AEAT SII Report Lines"/>
|
name="AEAT SII Report Lines"/>
|
||||||
|
</data>
|
||||||
</data>
|
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
822
aeatsii.xml
822
aeatsii.xml
File diff suppressed because it is too large
Load diff
22
company.py
22
company.py
|
@ -1,6 +1,5 @@
|
||||||
# The COPYRIGHT file at the top level of this repository contains
|
# The COPYRIGHT file at the top level of this repository contains
|
||||||
# the full copyright notices and license terms.
|
# the full copyright notices and license terms.
|
||||||
|
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
|
@ -20,6 +19,11 @@ class Company:
|
||||||
__name__ = 'company.company'
|
__name__ = 'company.company'
|
||||||
__metaclass__ = PoolMeta
|
__metaclass__ = PoolMeta
|
||||||
|
|
||||||
|
pem_certificate = fields.Binary('PEM Certificate')
|
||||||
|
encrypted_private_key = fields.Binary('Encrypted Private Key')
|
||||||
|
private_key = fields.Function(fields.Binary('Private Key'),
|
||||||
|
'get_private_key', 'set_private_key')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
super(Company, cls).__setup__()
|
super(Company, cls).__setup__()
|
||||||
|
@ -29,22 +33,6 @@ class Company:
|
||||||
'missing_pem_cert': "Missing PEM certificate"
|
'missing_pem_cert': "Missing PEM certificate"
|
||||||
})
|
})
|
||||||
|
|
||||||
pem_certificate = fields.Binary(
|
|
||||||
'PEM Certificate'
|
|
||||||
)
|
|
||||||
|
|
||||||
encrypted_private_key = fields.Binary(
|
|
||||||
'Encrypted Private Key'
|
|
||||||
)
|
|
||||||
|
|
||||||
private_key = fields.Function(
|
|
||||||
fields.Binary(
|
|
||||||
'Private Key'
|
|
||||||
),
|
|
||||||
'get_private_key',
|
|
||||||
'set_private_key',
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_private_key(cls, companies, name=None):
|
def get_private_key(cls, companies, name=None):
|
||||||
converter = buffer
|
converter = buffer
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
copyright notices and license terms. -->
|
copyright notices and license terms. -->
|
||||||
<tryton>
|
<tryton>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="company_view_form">
|
<record model="ir.ui.view" id="company_view_form">
|
||||||
<field name="model">company.company</field>
|
<field name="model">company.company</field>
|
||||||
<field name="inherit" ref="company.company_view_form"/>
|
<field name="inherit" ref="company.company_view_form"/>
|
||||||
|
@ -61,6 +60,5 @@
|
||||||
<field name="perm_create" eval="True"/>
|
<field name="perm_create" eval="True"/>
|
||||||
<field name="perm_delete" eval="True"/>
|
<field name="perm_delete" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# The COPYRIGHT file at the top level of this repository contains the full
|
# The COPYRIGHT file at the top level of this repository contains the full
|
||||||
# copyright notices and license terms.
|
# copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.model import fields
|
from trytond.model import fields
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.pyson import Eval
|
from trytond.pyson import Eval
|
||||||
|
@ -105,14 +104,15 @@ class Invoice:
|
||||||
table = SIILines.__table__()
|
table = SIILines.__table__()
|
||||||
cursor = Transaction().connection.cursor()
|
cursor = Transaction().connection.cursor()
|
||||||
cursor.execute(*table.select(Max(table.id), table.invoice,
|
cursor.execute(*table.select(Max(table.id), table.invoice,
|
||||||
where=table.invoice.in_([x.id for x in invoices]),
|
where=(table.invoice.in_([x.id for x in invoices]) &
|
||||||
|
(table.state != None)),
|
||||||
group_by=table.invoice))
|
group_by=table.invoice))
|
||||||
|
|
||||||
lines = [a[0] for a in cursor.fetchall()]
|
lines = [a[0] for a in cursor.fetchall()]
|
||||||
|
|
||||||
if lines:
|
if lines:
|
||||||
cursor.execute(*table.select(table.state, table.invoice,
|
cursor.execute(*table.select(table.state, table.invoice,
|
||||||
where=table.id.in_(lines)))
|
where=(table.id.in_(lines)) & (table.state != None)))
|
||||||
|
|
||||||
for state, inv in cursor.fetchall():
|
for state, inv in cursor.fetchall():
|
||||||
result['sii_state'][inv] = state
|
result['sii_state'][inv] = state
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0"?>
|
||||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||||
copyright notices and license terms. -->
|
copyright notices and license terms. -->
|
||||||
<tryton>
|
<tryton>
|
||||||
|
@ -15,5 +15,4 @@
|
||||||
<field name="name">account_invoice_list</field>
|
<field name="name">account_invoice_list</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# The COPYRIGHT file at the top level of this repository contains the full
|
# The COPYRIGHT file at the top level of this repository contains the full
|
||||||
# copyright notices and license terms.
|
# copyright notices and license terms.
|
||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
||||||
|
@ -10,7 +9,6 @@ from OpenSSL.crypto import dump_privatekey
|
||||||
from OpenSSL.crypto import FILETYPE_PEM
|
from OpenSSL.crypto import FILETYPE_PEM
|
||||||
from OpenSSL.crypto import Error as CryptoError
|
from OpenSSL.crypto import Error as CryptoError
|
||||||
|
|
||||||
|
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from trytond.model import ModelView
|
from trytond.model import ModelView
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0"?>
|
||||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||||
copyright notices and license terms. -->
|
copyright notices and license terms. -->
|
||||||
<tryton>
|
<tryton>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="load_pkcs12_start_view">
|
<record model="ir.ui.view" id="load_pkcs12_start_view">
|
||||||
<field name="model">aeat.sii.load_pkcs12.start</field>
|
<field name="model">aeat.sii.load_pkcs12.start</field>
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
|
@ -18,6 +17,5 @@
|
||||||
<field name="keyword">form_action</field>
|
<field name="keyword">form_action</field>
|
||||||
<field name="model">company.company,-1</field>
|
<field name="model">company.company,-1</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
|
@ -8,22 +8,18 @@
|
||||||
<field name="company_vat"/>
|
<field name="company_vat"/>
|
||||||
<label name="currency"/>
|
<label name="currency"/>
|
||||||
<field name="currency"/>
|
<field name="currency"/>
|
||||||
|
|
||||||
<label name="book"/>
|
<label name="book"/>
|
||||||
<field name="book"/>
|
<field name="book"/>
|
||||||
<label name="operation_type"/>
|
<label name="operation_type"/>
|
||||||
<field name="operation_type"/>
|
<field name="operation_type"/>
|
||||||
<label name="version"/>
|
<label name="version"/>
|
||||||
<field name="version"/>
|
<field name="version"/>
|
||||||
|
|
||||||
<label name="fiscalyear"/>
|
<label name="fiscalyear"/>
|
||||||
<field name="fiscalyear"/>
|
<field name="fiscalyear"/>
|
||||||
<label name="period"/>
|
<label name="period"/>
|
||||||
<field name="period"/>
|
<field name="period"/>
|
||||||
<button string="Load Invoices" name="load_invoices" colspan="2"/>
|
<button string="Load Invoices" name="load_invoices" colspan="2"/>
|
||||||
|
|
||||||
<field name="lines" colspan="6"/>
|
<field name="lines" colspan="6"/>
|
||||||
|
|
||||||
<label name="state"/>
|
<label name="state"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<label name="communication_state"/>
|
<label name="communication_state"/>
|
||||||
|
|
|
@ -12,7 +12,6 @@ contains the full copyright notices and license terms. -->
|
||||||
<field name="sii_received_key"/>
|
<field name="sii_received_key"/>
|
||||||
<label name="sii_intracomunity_key"/>
|
<label name="sii_intracomunity_key"/>
|
||||||
<field name="sii_intracomunity_key"/>
|
<field name="sii_intracomunity_key"/>
|
||||||
|
|
||||||
<label name="sii_subjected_key"/>
|
<label name="sii_subjected_key"/>
|
||||||
<field name="sii_subjected_key"/>
|
<field name="sii_subjected_key"/>
|
||||||
<label name="sii_excemption_key"/>
|
<label name="sii_excemption_key"/>
|
||||||
|
|
Loading…
Reference in a new issue