-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify transaction ID for the following cases: * Dispatches: * out_invoice B2B: 11 * out_invoice B2C: 12 * in_refund: 21 * Arrivals: * out_refund: 21 * in_invoice: 11 Don't propagate intrastat transaction to refund. Add some tests. Remove unused files.
- Loading branch information
1 parent
1a85da9
commit 6bbf071
Showing
8 changed files
with
220 additions
and
19 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 was deleted.
Oops, something went wrong.
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
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,88 @@ | ||
# © 2023 FactorLibre - Luis J. Salvatierra <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import fields | ||
from odoo.tests.common import tagged | ||
|
||
from .common_purchase import IntrastatPurchaseCommon | ||
from .common_sale import IntrastatSaleCommon | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestIntrastatAccountMoveReversal(IntrastatSaleCommon, IntrastatPurchaseCommon): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.tr_11 = cls.env.ref("intrastat_product.intrastat_transaction_11") | ||
cls.tr_12 = cls.env.ref("intrastat_product.intrastat_transaction_12") | ||
cls.tr_21 = cls.env.ref("intrastat_product.intrastat_transaction_21") | ||
|
||
def _create_out_invoice(self): | ||
self._create_sale_order() | ||
self.sale.action_confirm() | ||
self.sale.picking_ids.action_assign() | ||
for line in self.sale.picking_ids.move_line_ids: | ||
line.qty_done = line.reserved_uom_qty | ||
self.sale.picking_ids._action_done() | ||
self.assertEqual("done", self.sale.picking_ids.state) | ||
return self.sale._create_invoices() | ||
|
||
def _create_in_invoice(self): | ||
self._create_purchase_order() | ||
self.purchase.button_confirm() | ||
self.purchase.picking_ids.action_assign() | ||
for line in self.purchase.picking_ids.move_line_ids: | ||
line.qty_done = line.reserved_uom_qty | ||
self.purchase.picking_ids._action_done() | ||
self.assertEqual("done", self.purchase.picking_ids.state) | ||
action = self.purchase.action_create_invoice() | ||
invoice_id = action["res_id"] | ||
return self.move_obj.browse(invoice_id) | ||
|
||
def test_out_invoice_reversal(self): | ||
date_order = "2021-09-01" | ||
invoice = self._create_out_invoice() | ||
invoice.invoice_date = fields.Date.from_string(date_order) | ||
invoice.intrastat_fiscal_position = "b2c" | ||
invoice.action_post() | ||
self.assertFalse(invoice.intrastat_transaction_id) | ||
invoice.intrastat_transaction_id = self.tr_12 | ||
|
||
move_reversal = ( | ||
self.env["account.move.reversal"] | ||
.with_context(active_model="account.move", active_ids=invoice.ids) | ||
.create( | ||
{ | ||
"date": fields.Date.from_string("2021-09-02"), | ||
"reason": "no reason", | ||
"refund_method": "refund", | ||
"journal_id": invoice.journal_id.id, | ||
} | ||
) | ||
) | ||
reversal = move_reversal.reverse_moves() | ||
in_refund = self.env["account.move"].browse(reversal["res_id"]) | ||
self.assertFalse(in_refund.intrastat_transaction_id) | ||
|
||
def test_in_invoice_reversal(self): | ||
date_order = "2021-09-01" | ||
invoice = self._create_in_invoice() | ||
invoice.invoice_date = fields.Date.from_string(date_order) | ||
invoice.action_post() | ||
self.assertFalse(invoice.intrastat_transaction_id) | ||
invoice.intrastat_transaction_id = self.tr_11 | ||
|
||
move_reversal = ( | ||
self.env["account.move.reversal"] | ||
.with_context(active_model="account.move", active_ids=invoice.ids) | ||
.create( | ||
{ | ||
"date": fields.Date.from_string("2021-09-02"), | ||
"reason": "no reason", | ||
"refund_method": "refund", | ||
"journal_id": invoice.journal_id.id, | ||
} | ||
) | ||
) | ||
reversal = move_reversal.reverse_moves() | ||
in_refund = self.env["account.move"].browse(reversal["res_id"]) | ||
self.assertFalse(in_refund.intrastat_transaction_id) |
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 res_config_settings | ||
from . import intrastat_result_view | ||
from . import account_move_reversal |
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,12 @@ | ||
# © 2023 FactorLibre - Luis J. Salvatierra <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import models | ||
|
||
|
||
class AccountMoveReversal(models.TransientModel): | ||
_inherit = "account.move.reversal" | ||
|
||
def _prepare_default_reversal(self, move): | ||
res = super()._prepare_default_reversal(move) | ||
res["intrastat_transaction_id"] = False | ||
return res |