Skip to content

Commit

Permalink
Use limit 1 into a search() to avoid loading useless data
Browse files Browse the repository at this point in the history
  • Loading branch information
acsonefho committed Oct 19, 2017
1 parent da31f8c commit 6861f68
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions addons/hr_timesheet_sheet/models/account_analytic_line.py
Expand Up @@ -21,11 +21,11 @@ def _compute_sheet(self):
sheets = self.env['hr_timesheet_sheet.sheet'].search(
[('date_to', '>=', ts_line.date), ('date_from', '<=', ts_line.date),
('employee_id.user_id.id', '=', ts_line.user_id.id),
('state', 'in', ['draft', 'new'])])
('state', 'in', ['draft', 'new'])], limit=1)
if sheets:
# [0] because only one sheet possible for an employee between 2 dates
ts_line.sheet_id_computed = sheets[0]
ts_line.sheet_id = sheets[0]
ts_line.sheet_id_computed = sheets
ts_line.sheet_id = sheets

def _search_sheet(self, operator, value):
assert operator == 'in'
Expand Down

0 comments on commit 6861f68

Please sign in to comment.