-
-
Notifications
You must be signed in to change notification settings - Fork 198
[18.0][MIG] maintenance_timesheet_time_control: Migration to 18.0 #487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[18.0][MIG] maintenance_timesheet_time_control: Migration to 18.0 #487
Conversation
8f0c59c to
606674d
Compare
606674d to
a07461b
Compare
victoralmau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the title to: [18.0][MIG] maintenance_timesheet_time_control: Migration to 18.0 and rebase so we can check it functionally.
|
|
TT40881 [UPD] Update maintenance_timesheet_time_control.pot [UPD] README.rst
…ree from maintenance request for view TT40881 [UPD] Update maintenance_timesheet_time_control.pot maintenance_timesheet_time_control 13.0.1.1.0 Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: maintenance-13.0/maintenance-13.0-maintenance_timesheet_time_control Translate-URL: https://translation.odoo-community.org/projects/maintenance-13-0/maintenance-13-0-maintenance_timesheet_time_control/
TT40942 [UPD] Update maintenance_timesheet_time_control.pot [UPD] README.rst
TT40942 maintenance_timesheet_time_control maintenance_timesheet_time_control [UPD] Update maintenance_timesheet_time_control.pot [UPD] README.rst Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: maintenance-15.0/maintenance-15.0-maintenance_timesheet_time_control Translate-URL: https://translation.odoo-community.org/projects/maintenance-15-0/maintenance-15-0-maintenance_timesheet_time_control/
Translated using Weblate (Italian) Currently translated at 100.0% (8 of 8 strings) Translation: maintenance-15.0/maintenance-15.0-maintenance_timesheet_time_control Translate-URL: https://translation.odoo-community.org/projects/maintenance-15-0/maintenance-15-0-maintenance_timesheet_time_control/it/
Currently translated at 100.0% (8 of 8 strings) Translation: maintenance-15.0/maintenance-15.0-maintenance_timesheet_time_control Translate-URL: https://translation.odoo-community.org/projects/maintenance-15-0/maintenance-15-0-maintenance_timesheet_time_control/it/
Currently translated at 100.0% (8 of 8 strings) Translation: maintenance-15.0/maintenance-15.0-maintenance_timesheet_time_control Translate-URL: https://translation.odoo-community.org/projects/maintenance-15-0/maintenance-15-0-maintenance_timesheet_time_control/es/ [UPD] README.rst
Currently translated at 100.0% (8 of 8 strings) Translation: maintenance-15.0/maintenance-15.0-maintenance_timesheet_time_control Translate-URL: https://translation.odoo-community.org/projects/maintenance-15-0/maintenance-15-0-maintenance_timesheet_time_control/it/
Currently translated at 100.0% (8 of 8 strings) Translation: maintenance-17.0/maintenance-17.0-maintenance_timesheet_time_control Translate-URL: https://translation.odoo-community.org/projects/maintenance-17-0/maintenance-17-0-maintenance_timesheet_time_control/it/
208da58 to
6490147
Compare
|
@victoralmau Done! |
|
Thanks, can you add similar changes to OCA/timesheet@6c2cf12 in the tests of this module? |
What do you mean? |
| <field | ||
| name="show_time_control" | ||
| groups="hr_timesheet.group_hr_timesheet_user" | ||
| invisible="1" | ||
| /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <field | |
| name="show_time_control" | |
| groups="hr_timesheet.group_hr_timesheet_user" | |
| invisible="1" | |
| /> |
It is not necessary to add the field, odoo will automatically add it to the view as invisible automatically.
Also, in list views, it should be column_invisible=1, but better to remove the field and reduce code.
| <field | ||
| name="show_time_control" | ||
| groups="hr_timesheet.group_hr_timesheet_user" | ||
| invisible="1" | ||
| /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <field | |
| name="show_time_control" | |
| groups="hr_timesheet.group_hr_timesheet_user" | |
| invisible="1" | |
| /> |
| <field | ||
| name="show_time_control" | ||
| groups="hr_timesheet.group_hr_timesheet_user" | ||
| invisible="1" | ||
| /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <field | |
| name="show_time_control" | |
| groups="hr_timesheet.group_hr_timesheet_user" | |
| invisible="1" | |
| /> |
| <field | ||
| name="show_time_control" | ||
| groups="hr_timesheet.group_hr_timesheet_user" | ||
| invisible="1" | ||
| /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <field | |
| name="show_time_control" | |
| groups="hr_timesheet.group_hr_timesheet_user" | |
| invisible="1" | |
| /> |
| from odoo.addons.base.tests.common import BaseCommon | ||
|
|
||
|
|
||
| class TestMaintenanceTimesheetTimeControl(BaseCommon): | ||
| @classmethod | ||
| def setUpClass(cls): | ||
| super().setUpClass() | ||
| cls.user = new_test_user( | ||
| cls.env, | ||
| login="test-maintenance-user", | ||
| groups="maintenance.group_equipment_manager," | ||
| "hr_timesheet.group_hr_timesheet_user", | ||
| ) | ||
| cls.user.action_create_employee() | ||
| cls.project = cls.env["project.project"].create( | ||
| {"name": "Test project", "allow_timesheets": True} | ||
| ) | ||
| cls.category = cls.env["maintenance.equipment.category"].create( | ||
| {"name": "Test category"} | ||
| ) | ||
| cls.team = cls.env["maintenance.team"].create({"name": "Test team"}) | ||
| cls.equipment = cls.env["maintenance.equipment"].create( | ||
| { | ||
| "name": "Test computer", | ||
| "category_id": cls.category.id, | ||
| "project_id": cls.project.id, | ||
| "maintenance_team_id": cls.team.id, | ||
| } | ||
| ) | ||
|
|
||
| def _create_analytic_line(self, request): | ||
| return self.env["account.analytic.line"].create( | ||
| { | ||
| "date_time": datetime.now() - timedelta(hours=1), | ||
| "maintenance_request_id": request.id, | ||
| "project_id": request.project_id.id, | ||
| "account_id": request.project_id.account_id.id, | ||
| "name": "Test Maintenance Request Timesheet line", | ||
| "user_id": self.env.user.id, | ||
| } | ||
| ) | ||
|
|
||
| def _create_wizard(self, action, active_record): | ||
| self.assertEqual(action["res_model"], "hr.timesheet.switch") | ||
| self.assertEqual(action["target"], "new") | ||
| self.assertEqual(action["type"], "ir.actions.act_window") | ||
| self.assertEqual(action["view_mode"], "form") | ||
| return ( | ||
| active_record.env[action["res_model"]] | ||
| .with_context( | ||
| active_id=active_record.id, | ||
| active_ids=active_record.ids, | ||
| active_model=active_record._name, | ||
| **action.get("context", {}), | ||
| ) | ||
| .create({}) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| from odoo.addons.base.tests.common import BaseCommon | |
| class TestMaintenanceTimesheetTimeControl(BaseCommon): | |
| @classmethod | |
| def setUpClass(cls): | |
| super().setUpClass() | |
| cls.user = new_test_user( | |
| cls.env, | |
| login="test-maintenance-user", | |
| groups="maintenance.group_equipment_manager," | |
| "hr_timesheet.group_hr_timesheet_user", | |
| ) | |
| cls.user.action_create_employee() | |
| cls.project = cls.env["project.project"].create( | |
| {"name": "Test project", "allow_timesheets": True} | |
| ) | |
| cls.category = cls.env["maintenance.equipment.category"].create( | |
| {"name": "Test category"} | |
| ) | |
| cls.team = cls.env["maintenance.team"].create({"name": "Test team"}) | |
| cls.equipment = cls.env["maintenance.equipment"].create( | |
| { | |
| "name": "Test computer", | |
| "category_id": cls.category.id, | |
| "project_id": cls.project.id, | |
| "maintenance_team_id": cls.team.id, | |
| } | |
| ) | |
| def _create_analytic_line(self, request): | |
| return self.env["account.analytic.line"].create( | |
| { | |
| "date_time": datetime.now() - timedelta(hours=1), | |
| "maintenance_request_id": request.id, | |
| "project_id": request.project_id.id, | |
| "account_id": request.project_id.account_id.id, | |
| "name": "Test Maintenance Request Timesheet line", | |
| "user_id": self.env.user.id, | |
| } | |
| ) | |
| def _create_wizard(self, action, active_record): | |
| self.assertEqual(action["res_model"], "hr.timesheet.switch") | |
| self.assertEqual(action["target"], "new") | |
| self.assertEqual(action["type"], "ir.actions.act_window") | |
| self.assertEqual(action["view_mode"], "form") | |
| return ( | |
| active_record.env[action["res_model"]] | |
| .with_context( | |
| active_id=active_record.id, | |
| active_ids=active_record.ids, | |
| active_model=active_record._name, | |
| **action.get("context", {}), | |
| ) | |
| .create({}) | |
| ) | |
| from odoo.addons.project_timesheet_time_control.tests import ( | |
| test_project_timesheet_time_control, | |
| ) | |
| class TestMaintenanceTimesheetTimeControl( | |
| test_project_timesheet_time_control.TestProjectTimesheetTimeControlBase | |
| ): | |
| @classmethod | |
| def setUpClass(cls): | |
| super().setUpClass() | |
| cls.user.groups_id |= cls.env.ref("maintenance.group_equipment_manager") | |
| cls.category = cls.env["maintenance.equipment.category"].create( | |
| {"name": "Test category"} | |
| ) | |
| cls.team = cls.env["maintenance.team"].create({"name": "Test team"}) | |
| cls.equipment = cls.env["maintenance.equipment"].create( | |
| { | |
| "name": "Test computer", | |
| "category_id": cls.category.id, | |
| "project_id": cls.project.id, | |
| "maintenance_team_id": cls.team.id, | |
| } | |
| ) | |
| cls.request = cls.env["maintenance.request"].create( | |
| {"name": "Test computer request", "equipment_id": self.equipment.id} | |
| ) | |
| cls.line.maintenance_request_id = cls.request |
| @users("test-maintenance-user") | ||
| def test_maintenance_request_time_control_flow(self): | ||
| request = self.env["maintenance.request"].create( | ||
| {"name": "Test computer request", "equipment_id": self.equipment.id} | ||
| ) | ||
| analytic_line = self._create_analytic_line(request) | ||
| # Running line found, stop the timer | ||
| self.assertEqual(request.show_time_control, "stop") | ||
| request.button_end_work() | ||
| # No more running lines, cannot stop again | ||
| with self.assertRaises(exceptions.UserError): | ||
| request.button_end_work() | ||
| # All lines stopped, start new one | ||
| self.assertEqual(request.show_time_control, "start") | ||
| start_action = request.button_start_work() | ||
| wizard = self._create_wizard(start_action, request) | ||
| self.assertLessEqual(wizard.date_time, datetime.now()) | ||
| self.assertEqual(wizard.name, analytic_line.name) | ||
| self.assertEqual(wizard.project_id, request.project_id) | ||
| self.assertEqual( | ||
| wizard.analytic_line_id.account_id, request.project_id.account_id | ||
| ) | ||
| self.assertEqual(wizard.analytic_line_id, analytic_line) | ||
| new_act = wizard.with_context(show_created_timer=True).action_switch() | ||
| new_line = self.env[new_act["res_model"]].browse(new_act["res_id"]) | ||
| self.assertEqual(new_line.employee_id, self.env.user.employee_id) | ||
| self.assertEqual(new_line.project_id, self.project) | ||
| self.assertEqual(new_line.maintenance_request_id, request) | ||
| self.assertEqual(new_line.unit_amount, 0) | ||
| self.assertTrue(analytic_line.unit_amount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @users("test-maintenance-user") | |
| def test_maintenance_request_time_control_flow(self): | |
| request = self.env["maintenance.request"].create( | |
| {"name": "Test computer request", "equipment_id": self.equipment.id} | |
| ) | |
| analytic_line = self._create_analytic_line(request) | |
| # Running line found, stop the timer | |
| self.assertEqual(request.show_time_control, "stop") | |
| request.button_end_work() | |
| # No more running lines, cannot stop again | |
| with self.assertRaises(exceptions.UserError): | |
| request.button_end_work() | |
| # All lines stopped, start new one | |
| self.assertEqual(request.show_time_control, "start") | |
| start_action = request.button_start_work() | |
| wizard = self._create_wizard(start_action, request) | |
| self.assertLessEqual(wizard.date_time, datetime.now()) | |
| self.assertEqual(wizard.name, analytic_line.name) | |
| self.assertEqual(wizard.project_id, request.project_id) | |
| self.assertEqual( | |
| wizard.analytic_line_id.account_id, request.project_id.account_id | |
| ) | |
| self.assertEqual(wizard.analytic_line_id, analytic_line) | |
| new_act = wizard.with_context(show_created_timer=True).action_switch() | |
| new_line = self.env[new_act["res_model"]].browse(new_act["res_id"]) | |
| self.assertEqual(new_line.employee_id, self.env.user.employee_id) | |
| self.assertEqual(new_line.project_id, self.project) | |
| self.assertEqual(new_line.maintenance_request_id, request) | |
| self.assertEqual(new_line.unit_amount, 0) | |
| self.assertTrue(analytic_line.unit_amount) | |
| @users("test-user") | |
| def test_maintenance_request_time_control_flow(self): | |
| # Running line found, stop the timer | |
| self.assertEqual(request.show_time_control, "stop") | |
| request.button_end_work() | |
| # No more running lines, cannot stop again | |
| with self.assertRaises(exceptions.UserError): | |
| request.button_end_work() | |
| # All lines stopped, start new one | |
| self.assertEqual(self.request.show_time_control, "start") | |
| start_action = self.request.button_start_work() | |
| wizard = self._create_wizard(start_action, self.request) | |
| self.assertLessEqual(wizard.date_time, fields.Datetime.now()) | |
| self.assertEqual(wizard.name, self.line.name) | |
| self.assertEqual(wizard.project_id, self.request.project_id) | |
| self.assertEqual( | |
| wizard.analytic_line_id.account_id, self.request.project_id.account_id | |
| ) | |
| self.assertEqual(wizard.analytic_line_id, self.line) | |
| new_act = wizard.with_context(show_created_timer=True).action_switch() | |
| new_line = self.env[new_act["res_model"]].browse(new_act["res_id"]) | |
| self.assertEqual(new_line.employee_id, self.env.user.employee_id) | |
| self.assertEqual(new_line.project_id, self.project) | |
| self.assertEqual(new_line.maintenance_request_id, self.request) | |
| self.assertEqual(new_line.unit_amount, 0) | |
| self.assertTrue(self.line.unit_amount) |
4c80d37 to
3b27f5d
Compare
|
@victoralmau Done! If you can review it. |
| expr="//field[@name='timesheet_ids']/list//field[@name='date']" | ||
| position="attributes" | ||
| > | ||
| <attribute name="invisible">1</attribute> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <attribute name="invisible">1</attribute> | |
| <attribute name="column_invisible">1</attribute> |
|
Superseded by #498 |
|
If there's only one last change to do, let's see if @Alexgars73 can do it. Anyway, the attribution is preserved in the other PR though. |
3b27f5d to
01d5c38
Compare
|
@victoralmau @pedrobaeza Done!. |
pedrobaeza
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ocabot migration maintenance_timesheet_time_control
/ocabot merge nobump
|
This PR looks fantastic, let's merge it! |
|
Congratulations, your PR was merged at cc57277. Thanks a lot for contributing to OCA. ❤️ |
No description provided.