Skip to content

Commit

Permalink
[IMP] Make use of batch create
Browse files Browse the repository at this point in the history
  • Loading branch information
astirpe committed Mar 21, 2019
1 parent 7997109 commit 3bb749c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions hr_timesheet_sheet/models/hr_timesheet_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,16 @@ def _compute_line_ids(self):

def _create_data_matrix_lines(self, data_matrix):
self.ensure_one()
lines = self.env['hr_timesheet.sheet.line']
vals_list = []
for item in data_matrix:
lines |= self.env['hr_timesheet.sheet.line'].create(
self._get_default_sheet_line(
date=item[0],
project=item[1],
task=item[2],
unit_amount=data_matrix[item]['unit_amount']
))
vals_list += [self._get_default_sheet_line(
date=item[0],
project=item[1],
task=item[2],
unit_amount=data_matrix[item]['unit_amount']
)]
self.clean_timesheets(data_matrix[item]['timesheets'])
return lines
return self.env['hr_timesheet.sheet.line'].create(vals_list)

@api.onchange('date_start', 'date_end', 'employee_id')
def _onchange_dates(self):
Expand Down

0 comments on commit 3bb749c

Please sign in to comment.