This question has been flagged
2 Replies
3769 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({

Avatar
Discard
Best Answer

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

});


Avatar
Discard
Best Answer

@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({
...

Avatar
Discard