Skip to content
Snippets Groups Projects
Commit 6e05eee8 authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[FIX] sale_service: create only one task

If a SO is confirmed, cancelled, set to draft then confrimed again, 2
tasks are created for the same SO line.

opw-686613
parent 2fda62eb
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,16 @@ class procurement_order(osv.osv):
def _run(self, cr, uid, procurement, context=None):
if self._is_procurement_task(cr, uid, procurement, context=context) and not procurement.task_id:
# If the SO was confirmed, cancelled, set to draft then confirmed, avoid creating a new
# task.
if procurement.sale_line_id:
existing_task = self.pool['project.task'].search(
cr, uid, [('sale_line_id', '=', procurement.sale_line_id.id)],
context=context
)
if existing_task:
return existing_task
#create a task for the procurement
return self._create_service_task(cr, uid, procurement, context=context)
return super(procurement_order, self)._run(cr, uid, procurement, context=context)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment