Skip to Content
Menu
This question has been flagged
1 Reply
1732 Views

Hi everybody,


know it has been posted many times, but i fail to get the correct working version of an overwrite of a functionThe original function is def _create_service_task.

def _create_service_task(self, cr, uid, procurement, context=None):
        _logger.critical(procurement.product_id)
        project_task = self.pool.get('project.task')
        project = self._get_project(cr, uid, procurement, context=context)
        planned_hours = self._convert_qty_company_hours(cr, uid, procurement, context=context)
        task_id = project_task.create(cr, uid, {
            'name': '%s:%s' % (procurement.origin or '', procurement.product_id.name),
            'date_deadline': procurement.date_planned,
            'planned_hours': planned_hours,
            'remaining_hours': planned_hours,
            'partner_id': procurement.sale_line_id and procurement.sale_line_id.order_id.partner_id.id or procurement.partner_dest_id.id,
            'user_id': procurement.product_id.product_manager.id,
            'procurement_id': procurement.id,
            'description': procurement.name + '\n',
            'project_id': project and project.id or False,
            'company_id': procurement.company_id.id,
        },context=context)
        self.write(cr, uid, [procurement.id], {'task_id': task_id}, context=context)
        self.project_task_create_note(cr, uid, [procurement.id], context=context)
        return task_id


I want to add fields to the project_task.create function (which do work if i edit the core files.) using an override.
Could any of you give me some hint (or a complete answer) on how to do this? 
I have overwritten multiple other stuff but keep failing at this one.

Avatar
Discard
Best Answer

it's not possible to add a field in this  specific case  without completely redefine this method ,

logic of calling super (after/before the project_task.create )   can't work here because you want to do the task at the mid of method, so  redefine it completely .

Avatar
Discard
Author

Thanks Prakash, Gonna work on that!