Skip to content

Commit

Permalink
Merge PR #3280 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Oct 23, 2023
2 parents ade7af8 + 6406e9d commit 5d685bb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions l10n_es_aeat_sii_oca/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Copyright 2011-2023 Tecnativa - Pedro M. Baeza
# Copyright 2023 Aures Tic - Almudena de la Puente <[email protected]>
# Copyright 2023 Aures Tic - Jose Zambudio <[email protected]>
# Copyright 2023 Moduon Team - Eduardo de Miguel
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import json
Expand Down Expand Up @@ -587,6 +588,7 @@ def _sii_invoice_dict_not_modified(self):
def _post(self, soft=True):
res = super()._post(soft=soft)
for invoice in self.filtered(lambda x: x.sii_enabled and x.is_invoice()):
invoice._sii_check_exceptions()
if (
invoice.sii_state in ["sent_modified", "sent"]
and self._sii_invoice_dict_not_modified()
Expand Down
30 changes: 30 additions & 0 deletions l10n_es_aeat_sii_oca/tests/test_l10n_es_aeat_sii.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright 2020 Valentin Vinagre <[email protected]>
# Copyright 2021 Tecnativa - João Marques
# Copyright 2017-2023 Tecnativa - Pedro M. Baeza
# Copyright 2023 Moduon Team - Eduardo de Miguel
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

import json
Expand Down Expand Up @@ -437,6 +438,35 @@ def test_sii_check_exceptions_case_supplier_simplified(self):
with self.assertRaises(exceptions.UserError):
invoice._sii_check_exceptions()

def test_sii_check_exceptions_case_supplier_on_post(self):
"""Check sii exceptions when posting supplier bills"""
supplier = self.supplier.copy()
supplier.country_id = self.env.ref("base.es")
supplier.vat = "A46180576"
# Extra data without `ref` field
extra_data_wo_ref = {
"partner_id": supplier.id,
"invoice_line_ids": [
(
0,
0,
{
"name": "Test line",
"account_id": self.accounts["600000"].id,
"price_unit": 100.0,
"quantity": 1,
},
)
],
}
with self.assertRaises(exceptions.UserError):
self._invoice_purchase_create("2018-02-01", extra_vals=extra_data_wo_ref)
self.assertTrue(
self._invoice_purchase_create(
"2018-02-01", extra_vals=dict(extra_data_wo_ref, ref="TEST REF")
)
)

def test_unlink_draft_invoice_when_not_sent_to_sii(self):
draft_invoice = self.invoice.copy({})
draft_invoice.unlink()
Expand Down

0 comments on commit 5d685bb

Please sign in to comment.