[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).
This commit is contained in:
jem-odoo
2018-05-04 13:22:17 +02:00
parent 37dab1bc07
commit a7b6462de8
+5 -15
View File
@@ -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):