From a7b6462de8b31a567178ed4ecbe0cb18366a21c6 Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Mon, 30 Apr 2018 15:26:09 +0200 Subject: [PATCH] [FIX] sale_timesheet: timesheet from SO From the stat button of SO form view, we want to see all the timesheet with the employee on the list view. So the action used should be "all timesheet" and not "my timesheet". After that, we simply remove the defautl filters to avoid confusion for the current user. And for performance issue, the domain of the action does not include timesheet ids, but the SO lines ids (should be less numerous). --- addons/sale_timesheet/models/sale_order.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/addons/sale_timesheet/models/sale_order.py b/addons/sale_timesheet/models/sale_order.py index ffe78b9dd41..3e6077fbd66 100644 --- a/addons/sale_timesheet/models/sale_order.py +++ b/addons/sale_timesheet/models/sale_order.py @@ -106,24 +106,14 @@ class SaleOrder(models.Model): @api.multi def action_view_timesheet(self): self.ensure_one() - action = self.env.ref('hr_timesheet.act_hr_timesheet_line') - list_view_id = self.env.ref('hr_timesheet.hr_timesheet_line_tree').id - form_view_id = self.env.ref('hr_timesheet.hr_timesheet_line_form').id + action = self.env.ref('hr_timesheet.timesheet_action_all').read()[0] + action['context'] = self.env.context # erase default filters - result = { - 'name': action.name, - 'help': action.help, - 'type': action.type, - 'views': [[list_view_id, 'tree'], [form_view_id, 'form']], - 'target': action.target, - 'context': action.context, - 'res_model': action.res_model, - } if self.timesheet_count > 0: - result['domain'] = "[('id','in',%s)]" % self.timesheet_ids.ids + action['domain'] = [('so_line', 'in', self.order_line.ids)] else: - result = {'type': 'ir.actions.act_window_close'} - return result + action = {'type': 'ir.actions.act_window_close'} + return action class SaleOrderLine(models.Model):