From dc9ef81ab21cbbf232eca1771ab94dd5a54e9345 Mon Sep 17 00:00:00 2001 From: Nidhi Patel Date: Thu, 4 Feb 2021 07:03:39 +0000 Subject: [PATCH] [IMP] hr_timesheet, sale_timesheet: add a group by inv/so in portal view Currently, user cannot group the timesheet by inv/so in portal view. In this commit, add a group the timesheet by inv/so in portal view and move the `view timesheets` button next th each sol to the top left pannel. closes odoo/odoo#65932 Taskid: 2451359 Related: odoo/upgrade#2214 Signed-off-by: Yannick Tivisse (yti) --- addons/sale_timesheet/controllers/portal.py | 10 +++- addons/sale_timesheet/models/account.py | 2 + .../views/sale_timesheet_portal_templates.xml | 46 +++++++++++++++++-- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/addons/sale_timesheet/controllers/portal.py b/addons/sale_timesheet/controllers/portal.py index 94c96e1713a..df46e5c45fe 100644 --- a/addons/sale_timesheet/controllers/portal.py +++ b/addons/sale_timesheet/controllers/portal.py @@ -54,7 +54,10 @@ class SaleTimesheetCustomerPortal(TimesheetCustomerPortal): def _get_searchbar_groupby(self): searchbar_groupby = super()._get_searchbar_groupby() - searchbar_groupby.update(sol={'input': 'sol', 'label': _('Sales Order Item')}) + searchbar_groupby.update( + sol={'input': 'sol', 'label': _('Sales Order Item')}, + so={'input': 'so', 'label': _('Sales Order')}, + invoice={'input': 'invoice', 'label': _('Invoice')}) return searchbar_groupby def _get_search_domain(self, search_in, search): @@ -71,7 +74,10 @@ class SaleTimesheetCustomerPortal(TimesheetCustomerPortal): def _get_groupby_mapping(self): groupby_mapping = super()._get_groupby_mapping() - groupby_mapping.update(sol='so_line') + groupby_mapping.update( + sol='so_line', + so='order_id', + invoice='timesheet_invoice_id') return groupby_mapping @http.route(['/my/timesheets', '/my/timesheets/page/'], type='http', auth="user", website=True) diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py index f4634b0f838..852384d140d 100644 --- a/addons/sale_timesheet/models/account.py +++ b/addons/sale_timesheet/models/account.py @@ -21,6 +21,8 @@ class AccountAnalyticLine(models.Model): ('non_billable_project', 'No task found')], string="Billable Type", compute='_compute_timesheet_invoice_type', compute_sudo=True, store=True, readonly=True) timesheet_invoice_id = fields.Many2one('account.move', string="Invoice", readonly=True, copy=False, help="Invoice created from the timesheet") so_line = fields.Many2one(compute="_compute_so_line", store=True, readonly=False) + # we needed to store it only in order to be able to groupby in the portal + order_id = fields.Many2one(related='so_line.order_id', store=True, readonly=False) is_so_line_edited = fields.Boolean("Is Sales Order Item Manually Edited") # TODO: [XBO] Since the task_id is not required in this model, then it should more efficient to depends to pricing_type of project (See in master) diff --git a/addons/sale_timesheet/views/sale_timesheet_portal_templates.xml b/addons/sale_timesheet/views/sale_timesheet_portal_templates.xml index 4b69adf8566..3dee2b704ba 100644 --- a/addons/sale_timesheet/views/sale_timesheet_portal_templates.xml +++ b/addons/sale_timesheet/views/sale_timesheet_portal_templates.xml @@ -7,9 +7,15 @@ -