-
-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] account_move_tier_validation: Pass context to allow confirming …
…moves with tier validation Added tests for changes
- Loading branch information
1 parent
b195bf4
commit f156be2
Showing
2 changed files
with
60 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
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,6 +1,8 @@ | ||
# Copyright 2018 ForgeFlow S.L. | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from odoo import _, fields | ||
from odoo.exceptions import ValidationError | ||
from odoo.tests import common | ||
from odoo.tests.common import tagged | ||
|
||
|
@@ -26,3 +28,56 @@ def test_02_form(self): | |
) as form: | ||
form.save() | ||
self.assertTrue(form.hide_post_button) | ||
|
||
def test_03_move_post(self): | ||
group_ids = [ | ||
self.env.ref("base.group_system").id, | ||
self.env.ref("account.group_account_manager").id, | ||
] | ||
self.test_user_1 = self.env["res.users"].create( | ||
{ | ||
"name": "John", | ||
"login": "test1", | ||
"email": "[email protected]", | ||
"groups_id": [(6, 0, group_ids)], | ||
} | ||
) | ||
self.test_user_2 = self.env["res.users"].create( | ||
{ | ||
"name": "Mike", | ||
"login": "test2", | ||
"email": "[email protected]", | ||
"groups_id": [(6, 0, group_ids)], | ||
} | ||
) | ||
self.env["tier.definition"].create( | ||
{ | ||
"model_id": self.env["ir.model"] | ||
.search([("model", "=", "account.move")]) | ||
.id, | ||
"definition_domain": "[('move_type', '=', 'out_invoice')]", | ||
"reviewer_id": self.test_user_1.id, | ||
} | ||
) | ||
partner = self.env["res.partner"].create({"name": "Test Partner"}) | ||
product = self.env["product.product"].create({"name": "Test product"}) | ||
invoice = self.env["account.move"].create( | ||
{ | ||
"move_type": "out_invoice", | ||
"partner_id": partner.id, | ||
"invoice_date_due": fields.Date.from_string("2024-01-01"), | ||
"invoice_line_ids": [ | ||
(0, 0, {"product_id": product.id, "quantity": 1, "price_unit": 30}) | ||
], | ||
} | ||
) | ||
invoice.with_user(self.test_user_2.id).request_validation() | ||
invoice = invoice.with_user(self.test_user_1.id) | ||
invoice.invalidate_model() | ||
invoice.validate_tier() | ||
with self.assertRaisesRegex( | ||
ValidationError, _("The operation is under validation.") | ||
): | ||
invoice._post() | ||
# Calls _post method by passing context skip_validation_check set to True | ||
invoice.action_post() |