Add load data field in AEAT report to allow search invoice date or accounting date
task-032569
This commit is contained in:
parent
b1f4158843
commit
c1751b5e57
49
aeat.py
49
aeat.py
|
@ -266,6 +266,19 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
||||||
'readonly': ((Eval('state') != 'draft')
|
'readonly': ((Eval('state') != 'draft')
|
||||||
| (Eval('lines', [0]) & Eval('period'))),
|
| (Eval('lines', [0]) & Eval('period'))),
|
||||||
}, depends=['state', 'fiscalyear'])
|
}, depends=['state', 'fiscalyear'])
|
||||||
|
load_date = fields.Date('Load Date',
|
||||||
|
domain=['OR', [
|
||||||
|
('load_date', '=', None),
|
||||||
|
], [
|
||||||
|
('load_date', '>=', Eval('load_date_start')),
|
||||||
|
('load_date', '<=', Eval('load_date_end')),
|
||||||
|
]
|
||||||
|
], depends=['load_date_start', 'load_date_end'],
|
||||||
|
help='Filter invoices to the date whitin the period.')
|
||||||
|
load_date_start = fields.Function(fields.Date('Load Date Start'),
|
||||||
|
'on_change_with_load_date_start')
|
||||||
|
load_date_end = fields.Function(fields.Date('Load Date End'),
|
||||||
|
'on_change_with_load_date_end')
|
||||||
operation_type = fields.Selection(COMMUNICATION_TYPE, 'Operation Type',
|
operation_type = fields.Selection(COMMUNICATION_TYPE, 'Operation Type',
|
||||||
required=True,
|
required=True,
|
||||||
states={
|
states={
|
||||||
|
@ -348,11 +361,6 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
||||||
def default_company():
|
def default_company():
|
||||||
return Transaction().context.get('company')
|
return Transaction().context.get('company')
|
||||||
|
|
||||||
@fields.depends('company')
|
|
||||||
def on_change_with_currency(self, name=None):
|
|
||||||
if self.company:
|
|
||||||
return self.company.currency.id
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_fiscalyear():
|
def default_fiscalyear():
|
||||||
FiscalYear = Pool().get('account.fiscalyear')
|
FiscalYear = Pool().get('account.fiscalyear')
|
||||||
|
@ -367,11 +375,29 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
||||||
def default_version():
|
def default_version():
|
||||||
return '1.1'
|
return '1.1'
|
||||||
|
|
||||||
|
@fields.depends('period')
|
||||||
|
def on_change_period(self):
|
||||||
|
if not self.period:
|
||||||
|
self.load_date = None
|
||||||
|
|
||||||
@fields.depends('company')
|
@fields.depends('company')
|
||||||
def on_change_with_company_vat(self):
|
def on_change_with_company_vat(self):
|
||||||
if self.company:
|
if self.company:
|
||||||
return self.company.party.sii_vat_code
|
return self.company.party.sii_vat_code
|
||||||
|
|
||||||
|
@fields.depends('company')
|
||||||
|
def on_change_with_currency(self, name=None):
|
||||||
|
if self.company:
|
||||||
|
return self.company.currency.id
|
||||||
|
|
||||||
|
@fields.depends('period')
|
||||||
|
def on_change_with_load_date_start(self, name=None):
|
||||||
|
return self.period.start_date if self.period else None
|
||||||
|
|
||||||
|
@fields.depends('period')
|
||||||
|
def on_change_with_load_date_end(self, name=None):
|
||||||
|
return self.period.end_date if self.period else None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def copy(cls, records, default=None):
|
def copy(cls, records, default=None):
|
||||||
if default is None:
|
if default is None:
|
||||||
|
@ -452,22 +478,29 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
||||||
('sii_book_key', '=', report.book),
|
('sii_book_key', '=', report.book),
|
||||||
('move.period', '=', report.period.id),
|
('move.period', '=', report.period.id),
|
||||||
('state', 'in', ['posted', 'paid']),
|
('state', 'in', ['posted', 'paid']),
|
||||||
]
|
]
|
||||||
|
|
||||||
if report.operation_type == 'A0':
|
if report.operation_type == 'A0':
|
||||||
domain.append(('sii_state', 'in', [None, 'Incorrecto']))
|
domain.append(('sii_state', 'in', [None, 'Incorrecto']))
|
||||||
|
|
||||||
elif report.operation_type in ('A1', 'A4'):
|
elif report.operation_type in ('A1', 'A4'):
|
||||||
domain.append(('sii_state', 'in', [
|
domain.append(('sii_state', 'in', [
|
||||||
'AceptadoConErrores', 'AceptadaConErrores']))
|
'AceptadoConErrores', 'AceptadaConErrores']))
|
||||||
|
|
||||||
|
if report.load_date:
|
||||||
|
domain.append(['OR', [
|
||||||
|
('invoice_date', '<=', report.load_date),
|
||||||
|
('accounting_date', '=', None),
|
||||||
|
], [
|
||||||
|
('accounting_date', '<=', report.load_date),
|
||||||
|
]])
|
||||||
|
|
||||||
_logger.debug('Searching invoices for SII report: %s', domain)
|
_logger.debug('Searching invoices for SII report: %s', domain)
|
||||||
|
|
||||||
for invoice in Invoice.search(domain):
|
for invoice in Invoice.search(domain):
|
||||||
to_create.append({
|
to_create.append({
|
||||||
'report': report,
|
'report': report,
|
||||||
'invoice': invoice,
|
'invoice': invoice,
|
||||||
})
|
})
|
||||||
|
|
||||||
if to_create:
|
if to_create:
|
||||||
ReportLine.create(to_create)
|
ReportLine.create(to_create)
|
||||||
|
|
16
locale/ca.po
16
locale/ca.po
|
@ -170,6 +170,18 @@ msgctxt "field:aeat.sii.report,lines:"
|
||||||
msgid "Lines"
|
msgid "Lines"
|
||||||
msgstr "Líneas"
|
msgstr "Líneas"
|
||||||
|
|
||||||
|
msgctxt "field:aeat.sii.report,load_date:"
|
||||||
|
msgid "Load Date"
|
||||||
|
msgstr "Data límit"
|
||||||
|
|
||||||
|
msgctxt "field:aeat.sii.report,load_date_end:"
|
||||||
|
msgid "Load Date End"
|
||||||
|
msgstr "Fins data límit"
|
||||||
|
|
||||||
|
msgctxt "field:aeat.sii.report,load_date_start:"
|
||||||
|
msgid "Load Date Start"
|
||||||
|
msgstr "Desde data límit"
|
||||||
|
|
||||||
msgctxt "field:aeat.sii.report,operation_type:"
|
msgctxt "field:aeat.sii.report,operation_type:"
|
||||||
msgid "Operation Type"
|
msgid "Operation Type"
|
||||||
msgstr "Tipo de operación"
|
msgstr "Tipo de operación"
|
||||||
|
@ -398,6 +410,10 @@ msgctxt "field:party.party,sii_vat_country:"
|
||||||
msgid "SII VAT Country"
|
msgid "SII VAT Country"
|
||||||
msgstr "País NIF SII"
|
msgstr "País NIF SII"
|
||||||
|
|
||||||
|
msgctxt "help:aeat.sii.report,load_date:"
|
||||||
|
msgid "Filter invoices to the date whitin the period."
|
||||||
|
msgstr "Filtra les factures fins la data dins del període."
|
||||||
|
|
||||||
msgctxt "model:aeat.sii.issued.invoice.mapper,name:"
|
msgctxt "model:aeat.sii.issued.invoice.mapper,name:"
|
||||||
msgid "Tryton Issued Invoice to AEAT mapper"
|
msgid "Tryton Issued Invoice to AEAT mapper"
|
||||||
msgstr "Correspondencia Tryton - Aeat facturas emitidas"
|
msgstr "Correspondencia Tryton - Aeat facturas emitidas"
|
||||||
|
|
16
locale/es.po
16
locale/es.po
|
@ -170,6 +170,18 @@ msgctxt "field:aeat.sii.report,lines:"
|
||||||
msgid "Lines"
|
msgid "Lines"
|
||||||
msgstr "Líneas"
|
msgstr "Líneas"
|
||||||
|
|
||||||
|
msgctxt "field:aeat.sii.report,load_date:"
|
||||||
|
msgid "Load Date"
|
||||||
|
msgstr "Fecha límite"
|
||||||
|
|
||||||
|
msgctxt "field:aeat.sii.report,load_date_end:"
|
||||||
|
msgid "Load Date End"
|
||||||
|
msgstr "Hasta fecha límite"
|
||||||
|
|
||||||
|
msgctxt "field:aeat.sii.report,load_date_start:"
|
||||||
|
msgid "Load Date Start"
|
||||||
|
msgstr "Desde fecha límite"
|
||||||
|
|
||||||
msgctxt "field:aeat.sii.report,operation_type:"
|
msgctxt "field:aeat.sii.report,operation_type:"
|
||||||
msgid "Operation Type"
|
msgid "Operation Type"
|
||||||
msgstr "Tipo de operación"
|
msgstr "Tipo de operación"
|
||||||
|
@ -398,6 +410,10 @@ msgctxt "field:party.party,sii_vat_country:"
|
||||||
msgid "SII VAT Country"
|
msgid "SII VAT Country"
|
||||||
msgstr "País NIF SII"
|
msgstr "País NIF SII"
|
||||||
|
|
||||||
|
msgctxt "help:aeat.sii.report,load_date:"
|
||||||
|
msgid "Filter invoices to the date whitin the period."
|
||||||
|
msgstr "Filtra las facturas hasta la fecha dentro del período."
|
||||||
|
|
||||||
msgctxt "model:aeat.sii.issued.invoice.mapper,name:"
|
msgctxt "model:aeat.sii.issued.invoice.mapper,name:"
|
||||||
msgid "Tryton Issued Invoice to AEAT mapper"
|
msgid "Tryton Issued Invoice to AEAT mapper"
|
||||||
msgstr "Correspondencia Tryton - Aeat facturas emitidas"
|
msgstr "Correspondencia Tryton - Aeat facturas emitidas"
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
<field name="fiscalyear"/>
|
<field name="fiscalyear"/>
|
||||||
<label name="period"/>
|
<label name="period"/>
|
||||||
<field name="period"/>
|
<field name="period"/>
|
||||||
|
<label name="load_date"/>
|
||||||
|
<field name="load_date"/>
|
||||||
<label name="send_date"/>
|
<label name="send_date"/>
|
||||||
<field name="send_date"/>
|
<field name="send_date"/>
|
||||||
<button name="load_invoices" colspan="2"/>
|
<button name="load_invoices" colspan="2"/>
|
||||||
|
|
Loading…
Reference in New Issue