From 38bfd5282d7eb8c1f4db31a01aa17328d21611d8 Mon Sep 17 00:00:00 2001 From: Nidhi Patel Date: Fri, 9 Jul 2021 13:41:00 +0000 Subject: [PATCH] [IMP] hr_timesheet, sale_timesheet: improve portal view for timesheet The purpose of this is to improve the generic UX of portal for timesheet app. In this commit, done the below changes: - add a sort by employee, project, task, sales order item - rename 'sale order item' into 'sales order item' - In search, reorder the fields in the following order: Employee, Project, Task, Description, Sales Order, Sales Order Item, Invoice - In group by, switch the SO/SOL fields from place closes odoo/odoo#73699 Taskid: 2531322 Signed-off-by: LTU-Odoo --- addons/hr_timesheet/controllers/portal.py | 20 ++++++++++++------- addons/sale_timesheet/controllers/portal.py | 10 ++++++++-- .../views/sale_timesheet_portal_templates.xml | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/addons/hr_timesheet/controllers/portal.py b/addons/hr_timesheet/controllers/portal.py index 98109496d6c..dcd811816a5 100644 --- a/addons/hr_timesheet/controllers/portal.py +++ b/addons/hr_timesheet/controllers/portal.py @@ -27,10 +27,10 @@ class TimesheetCustomerPortal(CustomerPortal): def _get_searchbar_inputs(self): return { 'all': {'input': 'all', 'label': _('Search in All')}, - 'project': {'input': 'project', 'label': _('Search in Project')}, - 'name': {'input': 'name', 'label': _('Search in Description')}, 'employee': {'input': 'employee', 'label': _('Search in Employee')}, - 'task': {'input': 'task', 'label': _('Search in Task')} + 'project': {'input': 'project', 'label': _('Search in Project')}, + 'task': {'input': 'task', 'label': _('Search in Task')}, + 'name': {'input': 'name', 'label': _('Search in Description')}, } def _task_get_searchbar_sortings(self): @@ -67,6 +67,15 @@ class TimesheetCustomerPortal(CustomerPortal): 'date': 'date' } + def _get_searchbar_sortings(self): + return { + 'date': {'label': _('Newest'), 'order': 'date desc'}, + 'employee': {'label': _('Employee'), 'order': 'employee_id'}, + 'project': {'label': _('Project'), 'order': 'project_id'}, + 'task': {'label': _('Task'), 'order': 'task_id'}, + 'name': {'label': _('Description'), 'order': 'name'}, + } + @http.route(['/my/timesheets', '/my/timesheets/page/'], type='http', auth="user", website=True) def portal_my_timesheets(self, page=1, sortby=None, filterby=None, search=None, search_in='all', groupby='none', **kw): Timesheet = request.env['account.analytic.line'] @@ -76,10 +85,7 @@ class TimesheetCustomerPortal(CustomerPortal): values = self._prepare_portal_layout_values() _items_per_page = 100 - searchbar_sortings = { - 'date': {'label': _('Newest'), 'order': 'date desc'}, - 'name': {'label': _('Description'), 'order': 'name'}, - } + searchbar_sortings = self._get_searchbar_sortings() searchbar_inputs = self._get_searchbar_inputs() diff --git a/addons/sale_timesheet/controllers/portal.py b/addons/sale_timesheet/controllers/portal.py index cee2111da6e..9ba17a6aa02 100644 --- a/addons/sale_timesheet/controllers/portal.py +++ b/addons/sale_timesheet/controllers/portal.py @@ -31,16 +31,16 @@ class SaleTimesheetCustomerPortal(TimesheetCustomerPortal): def _get_searchbar_inputs(self): searchbar_inputs = super()._get_searchbar_inputs() searchbar_inputs.update( - sol={'input': 'sol', 'label': _('Search in Sales Order Item')}, so={'input': 'so', 'label': _('Search in Sales Order')}, + sol={'input': 'sol', 'label': _('Search in Sales Order Item')}, invoice={'input': 'invoice', 'label': _('Search in Invoice')}) return searchbar_inputs def _get_searchbar_groupby(self): searchbar_groupby = super()._get_searchbar_groupby() searchbar_groupby.update( - sol={'input': 'sol', 'label': _('Sales Order Item')}, so={'input': 'so', 'label': _('Sales Order')}, + sol={'input': 'sol', 'label': _('Sales Order Item')}, invoice={'input': 'invoice', 'label': _('Invoice')}) return searchbar_groupby @@ -64,6 +64,12 @@ class SaleTimesheetCustomerPortal(TimesheetCustomerPortal): invoice='timesheet_invoice_id') return groupby_mapping + def _get_searchbar_sortings(self): + searchbar_sortings = super()._get_searchbar_sortings() + searchbar_sortings.update( + sol={'label': _('Sales Order Item'), 'order': 'so_line'}) + return searchbar_sortings + def _task_get_page_view_values(self, task, access_token, **kwargs): values = super()._task_get_page_view_values(task, access_token, **kwargs) values['so_accessible'] = False diff --git a/addons/sale_timesheet/views/sale_timesheet_portal_templates.xml b/addons/sale_timesheet/views/sale_timesheet_portal_templates.xml index 4c22ab4f4ac..b494ada7c29 100644 --- a/addons/sale_timesheet/views/sale_timesheet_portal_templates.xml +++ b/addons/sale_timesheet/views/sale_timesheet_portal_templates.xml @@ -78,7 +78,7 @@ - Sale Order Item + Sales Order Item