-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] hr_expense_advance_clearing: Migration to 17.0
- Loading branch information
Showing
10 changed files
with
96 additions
and
153 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
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 |
---|---|---|
|
@@ -33,9 +33,11 @@ def setUpClass(cls): | |
"price_include": True, | ||
} | ||
) | ||
employee_home = cls.env["res.partner"].create({"name": "Employee Home Address"}) | ||
employee_home = cls.env["res.partner"].create( | ||
{"name": "Employee Home Address", "email": "[email protected]"} | ||
) | ||
cls.employee = cls.env["hr.employee"].create( | ||
{"name": "Employee A", "address_home_id": employee_home.id} | ||
{"name": "Employee A", "work_contact_id": employee_home.id} | ||
) | ||
advance_account = cls.env["account.account"].create( | ||
{ | ||
|
@@ -87,7 +89,7 @@ def _create_expense( | |
expense.employee_id = employee | ||
if not advance: | ||
expense.product_id = product | ||
expense.total_amount = amount | ||
expense.total_amount_currency = amount | ||
expense.payment_mode = payment_mode | ||
expense = expense.save() | ||
expense.tax_ids = False # Test no vat | ||
|
@@ -188,10 +190,10 @@ def test_1_clear_equal_advance(self): | |
"""When clear equal advance, all set""" | ||
# ------------------ Advance -------------------------- | ||
self.advance.action_submit_sheet() | ||
self.advance.approve_expense_sheets() | ||
self.advance.action_approve_expense_sheets() | ||
self.advance.action_sheet_move_create() | ||
self.assertEqual(self.advance.clearing_residual, 1000.0) | ||
self._register_payment(self.advance.account_move_id, 1000.0) | ||
self._register_payment(self.advance.account_move_ids, 1000.0) | ||
self.assertEqual(self.advance.state, "done") | ||
# ------------------ Clearing -------------------------- | ||
# Clear this with previous advance | ||
|
@@ -201,15 +203,15 @@ def test_1_clear_equal_advance(self): | |
self.clearing_equal.advance_sheet_id = self.advance | ||
self.assertEqual(self.clearing_equal.advance_sheet_residual, 1000.0) | ||
self.clearing_equal.action_submit_sheet() | ||
self.clearing_equal.approve_expense_sheets() | ||
self.clearing_equal.action_approve_expense_sheets() | ||
self.clearing_equal.action_sheet_move_create() | ||
# Equal amount, state change to Paid and advance is cleared | ||
self.assertEqual(self.clearing_equal.state, "done") | ||
self.assertEqual(self.clearing_equal.advance_sheet_residual, 0.0) | ||
# Clear this with previous advance is done | ||
self.clearing_more.advance_sheet_id = self.advance | ||
self.clearing_more.action_submit_sheet() | ||
self.clearing_more.approve_expense_sheets() | ||
self.clearing_more.action_approve_expense_sheets() | ||
with self.assertRaises(ValidationError): | ||
self.clearing_more.action_sheet_move_create() | ||
# There are 2 clearing in advance | ||
|
@@ -227,55 +229,55 @@ def test_1_clear_equal_advance(self): | |
) | ||
# Check back state move in advance after create clearing | ||
with self.assertRaises(UserError): | ||
self.advance.account_move_id.button_draft() | ||
self.advance.account_move_ids.button_draft() | ||
with self.assertRaises(UserError): | ||
self.advance.account_move_id.button_cancel() | ||
self.advance.account_move_ids.button_cancel() | ||
with self.assertRaises(UserError): | ||
self.advance.account_move_id._reverse_moves() | ||
self.advance.account_move_ids._reverse_moves() | ||
|
||
def test_2_clear_more_than_advance(self): | ||
"""When clear more than advance, do pay more""" | ||
# ------------------ Advance -------------------------- | ||
self.advance.action_submit_sheet() | ||
self.advance.approve_expense_sheets() | ||
self.advance.action_approve_expense_sheets() | ||
self.advance.action_sheet_move_create() | ||
self.assertEqual(self.advance.clearing_residual, 1000.0) | ||
self._register_payment(self.advance.account_move_id, 1000.0) | ||
self._register_payment(self.advance.account_move_ids, 1000.0) | ||
self.assertEqual(self.advance.state, "done") | ||
# ------------------ Clearing -------------------------- | ||
# Clear this with previous advance | ||
self.clearing_more.advance_sheet_id = self.advance | ||
self.assertEqual(self.clearing_more.advance_sheet_residual, 1000.0) | ||
self.clearing_more.action_submit_sheet() | ||
self.clearing_more.approve_expense_sheets() | ||
self.clearing_more.action_approve_expense_sheets() | ||
self.clearing_more.action_sheet_move_create() | ||
# More amount, state not changed to paid, and has to pay 200 more | ||
self.assertEqual(self.clearing_more.state, "post") | ||
self.assertEqual(self.clearing_more.amount_payable, 200.0) | ||
self._register_payment(self.clearing_more.account_move_id, 200.0) | ||
self._register_payment(self.clearing_more.account_move_ids, 200.0) | ||
self.assertEqual(self.clearing_more.state, "done") | ||
|
||
def test_3_clear_less_than_advance(self): | ||
"""When clear less than advance, do return advance""" | ||
# ------------------ Advance -------------------------- | ||
self.advance.action_submit_sheet() | ||
self.advance.approve_expense_sheets() | ||
self.advance.action_approve_expense_sheets() | ||
self.advance.action_sheet_move_create() | ||
# Test return advance register payment with move state draft | ||
with self.assertRaises(UserError): | ||
self.advance.account_move_id.button_draft() | ||
self.advance.account_move_ids.button_draft() | ||
self._register_payment( | ||
self.advance.account_move_id, 200.0, hr_return_advance=True | ||
self.advance.account_move_ids, 200.0, hr_return_advance=True | ||
) | ||
self.assertEqual(self.advance.clearing_residual, 1000.0) | ||
self._register_payment(self.advance.account_move_id, 1000.0) | ||
self._register_payment(self.advance.account_move_ids, 1000.0) | ||
self.assertEqual(self.advance.state, "done") | ||
# ------------------ Clearing, Return Advance -------------------------- | ||
# Clear this with previous advance | ||
self.clearing_less.advance_sheet_id = self.advance | ||
self.assertEqual(self.clearing_less.advance_sheet_residual, 1000.0) | ||
self.clearing_less.action_submit_sheet() | ||
self.clearing_less.approve_expense_sheets() | ||
self.clearing_less.action_approve_expense_sheets() | ||
register_payment = self.advance.with_context( | ||
hr_return_advance=True | ||
).action_register_payment() | ||
|
@@ -287,7 +289,7 @@ def test_3_clear_less_than_advance(self): | |
# Test return advance over residual | ||
with self.assertRaises(UserError): | ||
self._register_payment( | ||
self.advance.account_move_id, | ||
self.advance.account_move_ids, | ||
300.0, | ||
ctx=register_payment["context"], | ||
hr_return_advance=True, | ||
|
@@ -298,7 +300,7 @@ def test_3_clear_less_than_advance(self): | |
self.assertEqual(self.clearing_less.advance_sheet_residual, 200.0) | ||
# Back to advance and do return advance, clearing residual become 0.0 | ||
self._register_payment( | ||
self.advance.account_move_id, | ||
self.advance.account_move_ids, | ||
200.0, | ||
ctx=register_payment["context"], | ||
hr_return_advance=True, | ||
|
@@ -315,10 +317,10 @@ def test_4_clearing_product_advance(self): | |
# ------------------ Advance -------------------------- | ||
self.advance.expense_line_ids.clearing_product_id = self.product | ||
self.advance.action_submit_sheet() | ||
self.advance.approve_expense_sheets() | ||
self.advance.action_approve_expense_sheets() | ||
self.advance.action_sheet_move_create() | ||
self.assertEqual(self.advance.clearing_residual, 1000.0) | ||
self._register_payment(self.advance.account_move_id, 1000.0) | ||
self._register_payment(self.advance.account_move_ids, 1000.0) | ||
self.assertEqual(self.advance.state, "done") | ||
# ------------------ Clearing -------------------------- | ||
with Form(self.env["hr.expense.sheet"]) as sheet: | ||
|
@@ -329,10 +331,10 @@ def test_4_clearing_product_advance(self): | |
self.assertEqual(len(ex_sheet.expense_line_ids), 0) | ||
ex_sheet._onchange_advance_sheet_id() | ||
self.assertEqual(len(ex_sheet.expense_line_ids), 1) | ||
reverse_move = self.advance.account_move_id._reverse_moves( | ||
reverse_move = self.advance.account_move_ids._reverse_moves( | ||
default_values_list=[ | ||
{"invoice_date": self.advance.account_move_id.date, "ref": False} | ||
{"invoice_date": self.advance.account_move_ids.date, "ref": False} | ||
], | ||
cancel=True, | ||
) | ||
self.assertNotEqual(reverse_move, self.advance.account_move_id) | ||
self.assertNotEqual(reverse_move, self.advance.account_move_ids) |
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
Oops, something went wrong.