Odoo Help


Odoo 9 sale_service -> overwrite def

Thomas van Oort
on 4/19/16, 10:05 AM 630 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):
        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,
        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.



| 3 1 7
Pune, India

I like to surround myself with brave, creative people.

My motivation for learning different technologies and algos drive me. I love challenges of a steep learning curve which I believe makes me a better learner. I have a strong desire to learn different technologies, which would enable me to become a full stack developer.

On 4/20/16, 5:59 AM

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 .

Thanks Prakash, Gonna work on that!

Thomas van Oort
on 4/20/16, 6:24 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/19/16, 10:05 AM
Seen: 630 times
Last updated: 4/20/16, 5:59 AM