Check invoice state on report workflow transitions.
This commit is contained in:
parent
1d3384523e
commit
3f625b30ba
11
aeat.py
11
aeat.py
|
@ -403,7 +403,8 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
@ModelView.button
|
||||
@Workflow.transition('confirmed')
|
||||
def confirm(cls, reports):
|
||||
pass
|
||||
for report in reports:
|
||||
report.check_invoice_state()
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
|
@ -421,6 +422,7 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
for report in reports:
|
||||
if report.state != 'confirmed':
|
||||
continue
|
||||
report.check_invoice_state()
|
||||
if report.book == 'E': # issued invoices
|
||||
if report.operation_type in {'A0', 'A1'}:
|
||||
report.submit_issued_invoices()
|
||||
|
@ -469,6 +471,13 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
cls._save_response(report.response)
|
||||
report.save()
|
||||
|
||||
def check_invoice_state(self):
|
||||
for line in self.lines:
|
||||
if line.invoice and line.invoice.state not in ('posted', 'paid'):
|
||||
raise UserError(gettext(
|
||||
'aeat_sii.msg_report_wrong_invoice_state',
|
||||
invoice=line.invoice.rec_name))
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def load_invoices(cls, reports):
|
||||
|
|
|
@ -1785,4 +1785,8 @@ msgstr ""
|
|||
|
||||
msgctxt "model:res.group,name:group_invoice_sent_sii_posted2draft"
|
||||
msgid "Force Draft Account Invoice sent to SII"
|
||||
msgstr "Forzar borrador factura enviada a SII"
|
||||
msgstr "Forzar borrador factura enviada a SII"
|
||||
|
||||
msgctxt "model:ir.message,text:msg_report_wrong_invoice_state"
|
||||
msgid "Invoice \"%(invoice)s\" must be posted or paid."
|
||||
msgstr "La factura \"%(invoice)s\" debe estar contabilizada o pagada."
|
|
@ -46,6 +46,8 @@ If you edit them take care if you need to update again to SII</field>
|
|||
</record>
|
||||
<record model="ir.message" id="msg_invoice_deny_modify_sii_pk">
|
||||
<field name="text">Cannot modify "%(fields)s" on invoice "%(invoice)s" because its SII state is "%(sii_state)s". Please first include the invoice in a Delete Invoice SII Book and send to AEAT.</field>
|
||||
<record model="ir.message" id="msg_report_wrong_invoice_state">
|
||||
<field name="text">Invoice "%(invoice)s" must be posted or paid.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
Loading…
Reference in New Issue