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

Hello Community , I  want to inherit timesheet.js of the hr_timesheet_sheet , i want to add some function ? how to inherit this file ?

Avatar
Discard
Best Answer


First, you define a template in your module to add your js assets located in static/src/js:

<template id="assets_backend" name="newmodule_hr_timesheet_sheet assets" inherit_id="web.assets_backend"> 
<xpath expr="." position="inside">
<script type="text/javascript" src="/newmodule_hr_timesheet_sheet/static/src/js/timesheet.js"></script>
</xpath>
</template>

Then, in your module's new js file, you extend the widget from hr_timesheet_sheet like this:

odoo.define('newmodule_hr_timesheet_sheet.sheet', function (require){
"use strict";
// require original module JS
var timesheet = require('hr_timesheet_sheet.sheet');

// Extend widget
timesheet.WeeklyTimesheet.include({
....
    your code to override here    
    ....
});

}



Avatar
Discard

would that completely override WeeklyTimesheet?

I'm trying to change a value in a js file without simply replacing the whole function. More specificaly, I'm trying to modify the calendar module so that "everybody's calendar" would be set to 'true'. I've only managed to do so by editing the source code, but this is rather ugly.