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

Override timesheet.js (v9)

By
Philipp Johne
on 1/31/16, 12:54 PM 705 views

I want to override some methods of the WeeklyTimesheet widget. Can someone please help me with the necessary javascript to override it from a custom module (v9)? 

The problem seems to be which object to inherit, since the error message is: "'undefined' is not an object".

Here is the relevant line from timesheet.js that creates a 'FormWidget':

./hr_timesheet_sheet/static/src/js/timesheet.js:15:var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidgetMixin, {

This, unfortunately, does not work:

instance.hr_timesheet_sheet.WeeklyTimesheet.include({

0

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 8/8/16, 5:42 AM

Phillipe,

Hope you have got the solution, but for those who are still seeking for it:.

use core.form_custom_registry to get the weekly_timesheet class

var timesheet = core.form_custom_registry.get('weekly_timesheet');

and then , override it using,

timesheet.include({

//Your code here...

});


0

Axel Mendoza

--Axel Mendoza--
10203
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 1/31/16, 2:33 PM

@Philipp Johne

The include method doesn't return anything so for change an existing class you could do it simply like:
instance.hr_timesheet_sheet.WeeklyTimesheet.include({
...

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: 1/31/16, 12:54 PM
Seen: 705 times
Last updated: 8/8/16, 5:42 AM