diff --git a/addons/hr_holidays/__manifest__.py b/addons/hr_holidays/__manifest__.py index 0e35143b2ee..d47d59e9118 100644 --- a/addons/hr_holidays/__manifest__.py +++ b/addons/hr_holidays/__manifest__.py @@ -73,6 +73,7 @@ A synchronization with an internal agenda (Meetings of the CRM module) is also p 'hr_holidays/static/src/dashboard/**/*.scss', 'hr_holidays/static/src/leave_stats/**/*.js', 'hr_holidays/static/src/scss/*.scss', + 'hr_holidays/static/src/tours/*.js', ], 'web.tests_assets': [ 'hr_holidays/static/tests/helpers/**/*', diff --git a/addons/hr_holidays/static/src/tours/hr_holidays_tour.js b/addons/hr_holidays/static/src/tours/hr_holidays_tour.js new file mode 100644 index 00000000000..540845250fd --- /dev/null +++ b/addons/hr_holidays/static/src/tours/hr_holidays_tour.js @@ -0,0 +1,107 @@ +/** @odoo-module **/ +import tour from 'web_tour.tour'; +import { _t } from 'web.core'; +import session from 'web.session'; + +const leaveType = "NotLimitedHR"; +const leaveDateFrom = "01/17/2022"; +const leaveDateTo = "01/17/2022"; +const description = 'Days off'; + +tour.register('hr_holidays_tour', { + url: '/web', + rainbowManMessage: _t("Congrats, we can see that your request has been validated."), + test: false +}, [ + tour.stepUtils.showAppsMenuItem(), + { + trigger: '.o_app[data-menu-xmlid="hr_holidays.menu_hr_holidays_root"]', + content: _t("Let's discover the Time Off application"), + position: 'bottom', + }, + { + trigger: 'button.btn-time-off', + content: _t("Click on any date or on this button to request a time-off"), + position: 'bottom', + }, + { + trigger: '.o_field_widget[name="holiday_status_id"]', + content: _t("Let's try to create a Sick Time Off, select it in the list"), + position: 'right', + run: function(actions) { + actions.text(leaveType, this.$anchor.find('input')); + } + }, + { + trigger: ".ui-menu-item > a", + auto: true, + in_modal: false + }, + { + trigger: 'input[name="request_date_from"]', + content: _t("You can select the period you need to take off, from start date to end date"), + position: 'right', + run: function(actions) { + this.$anchor.val(leaveDateFrom); + this.$anchor.trigger("change"); + } + }, + { + trigger: 'input[name="request_date_to"]', + content: _t("You can select the period you need to take off, from start date to end date"), + position: 'right', + run: function(actions) { + this.$anchor.val(leaveDateTo); + this.$anchor.trigger("change"); + }, + auto: true + }, + { + trigger: 'textarea[name="name"]', + content: _t("Add some description for the people that will validate it"), + run: `text ${description}`, + position: 'right' + }, + { + trigger: `button:contains(${_t('Save')})`, + content: _t("Submit your request"), + position: 'bottom', + }, + { + trigger: 'button[data-menu-xmlid="hr_holidays.menu_hr_holidays_approvals"]', + content: _t("Let's go validate it"), + position: 'bottom' + }, + { + trigger: 'a[data-menu-xmlid="hr_holidays.menu_open_department_leave_approve"]', + content: _t("Select Time Off"), + position: 'right' + }, + { + trigger: 'table.o_list_table', + content: _t("Select the request you just created"), + position: 'bottom', + run: function(actions) { + const rows = this.$anchor.find('tr.o_data_row'); + const createdRow = rows.filter((i, row) => { + const el = $(row); + return el.find(`div[name="all_employee_ids"]:contains("${session.name}")`).length && + el.find(`td[name="name"]:contains("${description}")`).length && + el.find(`td[name="holiday_status_id"]:contains("${leaveType}")`).length && + el.find(`td[name="date_from"]:contains("${leaveDateFrom}")`).length && + el.find(`td[name="date_to"]:contains("${leaveDateTo}")`).length; + }); + actions.click(createdRow); + } + }, + { + trigger: 'button[name="action_approve"]', + content: _t("Let's approve it"), + position: 'bottom' + }, + { + trigger: 'a[data-menu-xmlid="hr_holidays.menu_hr_holidays_root"]', + content: _t("State is now confirmed. We can go back to the calendar"), + position: 'bottom' + } +]); diff --git a/addons/hr_holidays/tests/__init__.py b/addons/hr_holidays/tests/__init__.py index 2928fee6bbd..f983d595fc5 100644 --- a/addons/hr_holidays/tests/__init__.py +++ b/addons/hr_holidays/tests/__init__.py @@ -6,6 +6,7 @@ from . import test_automatic_leave_dates from . import test_allocation_access_rights from . import test_holidays_flow from . import test_hr_holidays_cancel_leave +from . import test_hr_holidays_tour from . import test_hr_leave_type from . import test_accrual_allocations from . import test_change_department diff --git a/addons/hr_holidays/tests/test_hr_holidays_tour.py b/addons/hr_holidays/tests/test_hr_holidays_tour.py new file mode 100644 index 00000000000..5b9010d6120 --- /dev/null +++ b/addons/hr_holidays/tests/test_hr_holidays_tour.py @@ -0,0 +1,43 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.tests import HttpCase +from odoo.tests.common import tagged + +from datetime import date + + +@tagged('post_install', '-at_install') +class TestHrHolidaysTour(HttpCase): + def test_hr_holidays_tour(self): + admin_user = self.env.ref('base.user_admin') + admin_employee = admin_user.employee_id + HRLeave = self.env['hr.leave'] + date_from = date(2022, 1, 17) + date_to = date(2022, 1, 18) + leaves_on_freeze_date = HRLeave.search([ + ('date_from', '>=', date_from), + ('date_to', "<=", date_to), + ('employee_id', '=', admin_employee.id) + ]) + leaves_on_freeze_date.sudo().unlink() + + LeaveType = self.env['hr.leave.type'].with_user(admin_user) + + holidays_type_1 = LeaveType.create({ + 'name': 'NotLimitedHR', + 'requires_allocation': 'no', + 'leave_validation_type': 'hr', + }) + # add allocation + allocation = self.env['hr.leave.allocation'].create({ + 'name': 'Expired Allocation', + 'employee_id': admin_employee.id, + 'holiday_status_id': holidays_type_1.id, + 'number_of_days': 1, + 'state': 'confirm', + 'date_from': '2022-01-01', + 'date_to': '2022-12-31', + }) + allocation.action_validate() + + self.start_tour('/web', 'hr_holidays_tour', login="admin")