Odoo Help

Welcome!

This community 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.

0

Odoo 9 sale_service -> overwrite def

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

2

Prakash Sharma

--Prakash Sharma--
815
| 2 1 4
Delhi, India
--Prakash Sharma--

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.

Prakash Sharma
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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