-
-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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() | ||
|