-
-
Notifications
You must be signed in to change notification settings - Fork 309
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 eLBati
- Loading branch information
Showing
14 changed files
with
235 additions
and
32 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
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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import account_rc_type | ||
from . import account_invoice | ||
from . import attachment |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from odoo import models, api | ||
|
||
|
||
class Attachment(models.Model): | ||
_inherit = "fatturapa.attachment.in" | ||
|
||
@api.model | ||
def create(self, vals): | ||
attachments = super(Attachment, self).create(vals) | ||
rc_invoices = self.env["account.invoice"].search( | ||
[ | ||
("type", "in", ("in_invoice", "in_refund")), | ||
("rc_self_invoice_id", "!=", False), | ||
("fatturapa_attachment_in_id", "=", False), | ||
], | ||
) | ||
for attachment in attachments: | ||
if attachment.linked_invoice_id_xml and attachment.is_self_invoice: | ||
rc_invoice = rc_invoices.filtered( | ||
lambda i: i.number == attachment.linked_invoice_id_xml | ||
) | ||
if len(rc_invoice) == 1: | ||
rc_invoice.fatturapa_attachment_in_id = attachment | ||
return attachments |
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
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
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
Binary file modified
BIN
+18 KB
(180%)
l10n_it_reverse_charge/static/description/fiscal_pos_extra.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+19.9 KB
(140%)
l10n_it_reverse_charge/static/description/rc_selfinvoice_extra.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import test_rc | ||
from . import test_account_rc_type |
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
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Copyright 2022 Simone Rubino - TAKOBI | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.exceptions import UserError, ValidationError | ||
from odoo.fields import first | ||
|
||
from .rc_common import ReverseChargeCommon | ||
|
||
|
||
class TestAccountRCType(ReverseChargeCommon): | ||
|
||
def test_with_supplier_self_invoice(self): | ||
""" | ||
Check that Reverse Charge Types | ||
that require a supplier self invoice, | ||
must have an Original Purchase Tax in the mapping. | ||
""" | ||
rc_type = self.rc_type_eeu | ||
rc_type_mapping = first(rc_type.tax_ids) | ||
self.assertTrue(rc_type.with_supplier_self_invoice) | ||
self.assertTrue(rc_type_mapping.original_purchase_tax_id) | ||
|
||
with self.assertRaises(ValidationError) as ve: | ||
rc_type_mapping.original_purchase_tax_id = False | ||
exc_message = ve.exception.args[0] | ||
|
||
self.assertIn("Original Purchase Tax is required", exc_message) | ||
self.assertIn(rc_type.display_name, exc_message) | ||
|
||
def test_tax_map_find(self): | ||
""" | ||
Check that Reverse Charge Types can map | ||
Original Purchase Tax to Purchase Tax. | ||
""" | ||
rc_type = self.rc_type_eeu | ||
rc_type_mapping = first(rc_type.tax_ids) | ||
key_tax = rc_type_mapping.original_purchase_tax_id | ||
|
||
mapped_tax = rc_type.map_tax( | ||
key_tax, | ||
'original_purchase_tax_id', | ||
'purchase_tax_id', | ||
) | ||
|
||
value_tax = rc_type_mapping.purchase_tax_id | ||
self.assertEqual(value_tax, mapped_tax) | ||
|
||
def test_tax_map_not_found(self): | ||
""" | ||
Check that Reverse Charge Types | ||
raise an Error when can't map a tax. | ||
""" | ||
rc_type = self.rc_type_eeu | ||
key_taxes = rc_type.tax_ids.mapped('original_purchase_tax_id') | ||
other_tax = self.env['account.tax'].search( | ||
[ | ||
('id', 'not in', key_taxes.ids), | ||
], | ||
limit=1, | ||
) | ||
self.assertTrue(other_tax) | ||
|
||
with self.assertRaises(UserError) as ue: | ||
rc_type.map_tax( | ||
other_tax, | ||
'original_purchase_tax_id', | ||
'purchase_tax_id', | ||
) | ||
exc_message = ue.exception.args[0] | ||
|
||
self.assertIn("Can't find tax mapping", exc_message) | ||
self.assertIn(rc_type.display_name, exc_message) | ||
self.assertIn(other_tax.display_name, exc_message) |
Oops, something went wrong.