-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TA#61910 [ADD][MIG] project_wip_timesheet : migration to 14.0
- Loading branch information
1 parent
de27b46
commit 6b0bdde
Showing
8 changed files
with
125 additions
and
56 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# © 2019 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import models |
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,23 +1,23 @@ | ||
# © 2019 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
'name': 'Project WIP Timesheet', | ||
'version': '1.0.0', | ||
'author': 'Numigi', | ||
'maintainer': 'Numigi', | ||
'website': 'https://bit.ly/numigi-com', | ||
'license': 'LGPL-3', | ||
'category': 'Project', | ||
'summary': 'Generate WIP journal entries from timesheets', | ||
'depends': [ | ||
'project_wip', | ||
'project_task_analytic_lines', | ||
'hr_timesheet', | ||
'sale_timesheet', | ||
"name": "Project WIP Timesheet", | ||
"version": "14.0.1.0.0", | ||
"author": "Numigi", | ||
"maintainer": "Numigi", | ||
"website": "https://bit.ly/numigi-com", | ||
"license": "LGPL-3", | ||
"category": "Project", | ||
"summary": "Generate WIP journal entries from timesheets", | ||
"depends": [ | ||
"project_wip", | ||
"project_task_analytic_lines", | ||
"hr_timesheet", | ||
"sale_timesheet", | ||
], | ||
'data': [ | ||
'views/project_type.xml', | ||
"data": [ | ||
"views/project_type.xml", | ||
], | ||
'installable': True, | ||
"installable": True, | ||
} |
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,4 +1,4 @@ | ||
# © 2019 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import account_analytic_line, project_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
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,2 @@ | ||
# © 2019 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
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,4 +1,4 @@ | ||
# © 2019 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# © 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
import pytest | ||
|
@@ -18,7 +18,10 @@ def setUpClass(cls): | |
"name": "Manager", | ||
"login": "manager", | ||
"email": "[email protected]", | ||
"groups_id": [(4, cls.env.ref("project.group_project_manager").id)], | ||
"groups_id": [ | ||
(4, cls.env.ref("project.group_project_manager").id), | ||
(4, cls.env.ref("project_wip.group_wip_to_cgs").id), | ||
], | ||
"company_id": cls.company.id, | ||
"company_ids": [(4, cls.company.id)], | ||
} | ||
|
@@ -58,7 +61,7 @@ def setUpClass(cls): | |
{ | ||
"name": "Work in Progress", | ||
"code": "WIP", | ||
"update_posted": True, | ||
# "update_posted": True, | ||
"type": "general", | ||
"company_id": cls.company.id, | ||
} | ||
|
@@ -114,7 +117,7 @@ def setUpClass(cls): | |
cls.project = cls.env["project.project"].create( | ||
{ | ||
"name": "Job 123", | ||
"project_type_id": cls.project_type.id, | ||
"type_id": cls.project_type.id, | ||
"company_id": cls.company.id, | ||
} | ||
) | ||
|
@@ -132,7 +135,7 @@ def _create_timesheet(cls, description="/", quantity=1, amount=50, date_=None): | |
cls.employee.timesheet_cost = amount | ||
line = ( | ||
cls.env["account.analytic.line"] | ||
.sudo(cls.timesheet_user) | ||
.with_user(cls.timesheet_user) | ||
.create( | ||
{ | ||
"company_id": cls.company.id, | ||
|
@@ -223,25 +226,25 @@ def test_salary_move_line_has_no_task(self): | |
def test_on_change_timesheet_amount__debit_amount_updated(self): | ||
timesheet_line = self._create_timesheet() | ||
expected_amount = 25 | ||
timesheet_line.sudo(self.timesheet_user).amount = -expected_amount | ||
timesheet_line.with_user(self.timesheet_user).amount = -expected_amount | ||
wip_line = self._get_wip_move_line(timesheet_line) | ||
assert wip_line.debit == expected_amount | ||
|
||
def test_on_change_timesheet_quantity__move_quantity_updated(self): | ||
timesheet_line = self._create_timesheet() | ||
expected_quantity = 5 | ||
timesheet_line.sudo(self.timesheet_user).unit_amount = expected_quantity | ||
timesheet_line.with_user(self.timesheet_user).unit_amount = expected_quantity | ||
wip_line = self._get_wip_move_line(timesheet_line) | ||
assert wip_line.quantity == expected_quantity | ||
|
||
def test_on_change_timesheet_a_date__account_move_date_updated(self): | ||
timesheet_line = self._create_timesheet() | ||
new_date = datetime.now().date() + timedelta(30) | ||
timesheet_line.sudo(self.timesheet_user).date = new_date | ||
timesheet_line.with_user(self.timesheet_user).date = new_date | ||
assert timesheet_line.salary_account_move_id.date == new_date | ||
|
||
def test_if_project_has_no_type__no_account_move_created(self): | ||
self.project.project_type_id = False | ||
self.project.type_id = False | ||
timesheet_line = self._create_timesheet() | ||
assert not timesheet_line.salary_account_move_id | ||
|
||
|
@@ -264,20 +267,20 @@ def test_reversal_move_wip_line_has_task(self): | |
|
||
def test_if_new_project_requires_no_timesheet__account_move_reversed(self): | ||
timesheet_line = self._create_timesheet() | ||
new_project = self.project.copy({"project_type_id": False}) | ||
new_project = self.project.copy({"type_id": False}) | ||
new_task = self.task.copy({"project_id": new_project.id}) | ||
|
||
wip_line = self._get_wip_move_line(timesheet_line) | ||
timesheet_line.sudo(self.timesheet_user).write( | ||
timesheet_line.with_user(self.timesheet_user).write( | ||
{"project_id": new_project.id, "task_id": new_task.id} | ||
) | ||
assert wip_line.reconciled | ||
|
||
def test_timesheet_amount_can_be_changed_twice(self): | ||
timesheet_line = self._create_timesheet() | ||
expected_amount = 25 | ||
timesheet_line.sudo(self.timesheet_user).amount = -20 | ||
timesheet_line.sudo(self.timesheet_user).amount = -expected_amount | ||
timesheet_line.with_user(self.timesheet_user).amount = -20 | ||
timesheet_line.with_user(self.timesheet_user).amount = -expected_amount | ||
wip_line = self._get_wip_move_line(timesheet_line) | ||
assert wip_line.debit == expected_amount | ||
|
||
|
@@ -288,7 +291,7 @@ def test_move_ref_contains_task_id(self): | |
def test_after_change_task_on_timesheet__move_ref_contains_task_id(self): | ||
timesheet_line = self._create_timesheet() | ||
new_task = self.task.copy() | ||
timesheet_line.sudo(self.timesheet_user).task_id = new_task | ||
timesheet_line.with_user(self.timesheet_user).task_id = new_task | ||
assert str(new_task.id) in timesheet_line.salary_account_move_id.ref | ||
|
||
def test_move_ref_contains_project_name(self): | ||
|
@@ -297,11 +300,13 @@ def test_move_ref_contains_project_name(self): | |
|
||
def test_after_change_project_on_timesheet__move_ref_contains_project_name(self): | ||
timesheet_line = self._create_timesheet() | ||
new_project = self.project.copy() | ||
self.assertIsNotNone(timesheet_line.salary_account_move_id.ref, msg=None) | ||
new_project = self.project.copy({}) | ||
new_task = self.task.copy({"project_id": new_project.id}) | ||
timesheet_line.sudo(self.timesheet_user).write( | ||
timesheet_line.with_user(self.timesheet_user).write( | ||
{"project_id": new_project.id, "task_id": new_task.id} | ||
) | ||
|
||
assert new_project.name in timesheet_line.salary_account_move_id.ref | ||
|
||
def test_if_zero_hour__no_entry_created(self): | ||
|
@@ -316,24 +321,25 @@ class TestTimesheetEntryTransferedToWip(WIPJournalEntriesCase): | |
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.timesheet_line = cls._create_timesheet() | ||
cls.project.sudo().action_wip_to_cgs() | ||
cls.project.with_user(cls.manager).action_wip_to_cgs() | ||
|
||
def test_timesheet_amount_can_not_be_changed(self): | ||
with pytest.raises(ValidationError): | ||
self.timesheet_line.sudo(self.timesheet_user).amount = -100 | ||
self.timesheet_line.with_user(self.timesheet_user).amount = -100 | ||
|
||
def test_timesheet_quantity_can_not_be_changed(self): | ||
with pytest.raises(ValidationError): | ||
self.timesheet_line.sudo(self.timesheet_user).unit_amount = 10 | ||
self.timesheet_line.with_user(self.timesheet_user).unit_amount = 10 | ||
|
||
def test_project_with_no_type_can_not_be_set(self): | ||
new_project = self.project.copy({"project_type_id": False}) | ||
new_project = self.project.with_user(self.manager).copy() | ||
new_project.type_id = False | ||
new_task = self.task.copy({"project_id": new_project.id}) | ||
with pytest.raises(ValidationError): | ||
self.timesheet_line.sudo(self.timesheet_user).write( | ||
self.timesheet_line.with_user(self.timesheet_user).write( | ||
{"project_id": new_project.id, "task_id": new_task.id} | ||
) | ||
|
||
def test_timesheet_can_not_be_deleted(self): | ||
with pytest.raises(ValidationError): | ||
self.timesheet_line.sudo(self.timesheet_user).unlink() | ||
self.timesheet_line.with_user(self.timesheet_user).unlink() |