Check if duplicated invoices on SII report
This commit is contained in:
parent
3f625b30ba
commit
c8e053d997
12
aeat.py
12
aeat.py
|
@ -405,6 +405,7 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
def confirm(cls, reports):
|
||||
for report in reports:
|
||||
report.check_invoice_state()
|
||||
report.check_duplicate_invoices()
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
|
@ -1129,6 +1130,17 @@ class SIIReport(Workflow, ModelSQL, ModelView):
|
|||
cls.confirm(received_reports)
|
||||
cls.send(received_reports)
|
||||
|
||||
def check_duplicate_invoices(self):
|
||||
if self.operation_type in ('A0', 'D0'):
|
||||
invoices = set()
|
||||
for line in self.lines:
|
||||
if line.invoice in invoices:
|
||||
raise UserError(gettext(
|
||||
'aeat_sii.msg_report_duplicated_invoice',
|
||||
invoice=line.invoice.rec_name,
|
||||
report=self.rec_name))
|
||||
invoices.add(line.invoice)
|
||||
|
||||
|
||||
class SIIReportLine(ModelSQL, ModelView):
|
||||
'''
|
||||
|
|
|
@ -1789,4 +1789,8 @@ 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."
|
||||
msgstr "La factura \"%(invoice)s\" debe estar contabilizada o pagada."
|
||||
|
||||
msgctxt "model:ir.message,text:msg_report_duplicated_invoice"
|
||||
msgid "Invoice \"%(invoice)s\" is duplicated on SII Report \"%(report)s\"."
|
||||
msgstr "La factura \"%(invoice)s\" se ha incluído varias veces en el Libro SII \"%(report)s\"."
|
|
@ -48,6 +48,8 @@ If you edit them take care if you need to update again to SII</field>
|
|||
<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 model="ir.message" id="msg_report_duplicated_invoice">
|
||||
<field name="text">Invoice "%(invoice)s" is duplicated on SII Report "%(report)s".</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
Loading…
Reference in New Issue