-
  In order to test process to generate task automatic from procurement, I confirm sale order to sale service product.
-
  !workflow {model: sale.order, action: order_confirm, ref: sale.sale_order_3}
-
  I run the scheduler.
-
  !python {model: procurement.order}: |
    self.run_scheduler(cr, uid)
-
  Now I check that task details after run procurement
-
  !python {model: procurement.order}: |
    from datetime import datetime
    procurement_ids = self.search(cr, uid, [('sale_line_id', '=', ref('line_services'))])
    assert procurement_ids, "Procurement is not generated for Service Order Line."
    procurement = self.browse(cr, uid, procurement_ids[0], context=context)
    assert procurement.state != 'done' , "Procurement should not be closed."
    task = procurement.task_id
    assert task, "Task is not generated."
    # check whether task project either is the product's project, or corresponds to the analytic account of sale order
    project = task.project_id
    if procurement.product_id.project_id:
        assert project == procurement.product_id.project_id, "Project does not correspond."
    elif procurement.sale_line_id:
        account = procurement.sale_line_id.order_id.project_id
        assert (not project and not account) or project.analytic_account_id == account, "Project does not correspond."
    planned_hours = self._convert_qty_company_hours(cr, uid, procurement, context=context)
    assert task.planned_hours == planned_hours, 'Planned Hours do not correspond.'
    assert datetime.strptime(task.date_deadline, '%Y-%m-%d') == datetime.strptime(procurement.date_planned[:10], '%Y-%m-%d'), 'Deadline does not correspond.'
    if procurement.product_id.product_manager:
        assert task.user_id.id == procurement.product_id.product_manager.id, 'Allocated Person does not correspond with Service Product Manager.'
-
  I close that task.
-
  !python {model: project.task}: |
    task_ids = self.search(cr, uid, [('sale_line_id', '=', ref('line_services'))])
    assert task_ids, "Task is not generated for Service Order Line."
    self.do_close(cr, uid, task_ids, context=context)
-
  I check procurement of Service Order Line after closed task.
-
  !python {model: procurement.order}: |
    procurement_ids = self.search(cr, uid, [('sale_line_id', '=', ref('line_services'))])
    assert procurement_ids, "Procurement is not generated for Service Order Line."
    procurement = self.browse(cr, uid, procurement_ids[0], context=context)
    assert procurement.state == 'done' , "Procurement should be closed."
