Skip to content

Commit

Permalink
[FIX] sale_timesheet: recompute delivered qty
Browse files Browse the repository at this point in the history
- Create a product with 'Service Tracking' as 'Create a task in a new
  project'
- Create a SO with this product, validate
- In the created task, add a timesheet line

The delivered quantity is not updated on the SO.

In method `_analytic_compute_delivered_quantity`, the item is skipped if
the field `product_uom_id` is not set on the analytic line. However,
`product_uom_id` is set in method `_timesheet_postprocess`, which is
called after `_analytic_compute_delivered_quantity`.

Therefore, we move this part in `_timesheet_preprocess`.

opw-805533
  • Loading branch information
nim-odoo committed Jan 23, 2018
1 parent dec50fc commit b8f8012
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions addons/sale_timesheet/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ def _timesheet_preprocess(self, values):
if 'task_id' in values:
task = self.env['project.task'].sudo().browse(values['task_id'])
values['so_line'] = task.sale_line_id.id or values.get('so_line', False)

# Set product_uom_id now so delivered qty is computed in SO line
if not 'product_uom_id' in values and all([v in values for v in ['employee_id', 'project_id']]):
employee = self.env['hr.employee'].sudo().browse(values['employee_id'])
values['product_uom_id'] = employee.company_id.project_time_mode_id.id
return values

@api.multi
Expand Down

0 comments on commit b8f8012

Please sign in to comment.