I'm trying to make changes to some javascript in a new module, but I can't for the life of me understand what I'm doing incorrectly.
https://github.com/odoo/odoo/blob/10.0/addons/hr_attendance/static/src/js/kiosk_confirm.js
This is the code I'm trying to change, specifically this snippet:
this.next_action = 'hr_attendance.hr_attendance_action_kiosk_mode';
And this is the code I've gotten so far, what I think is the closest iteration to what would be correct:
odoo.define('tko_hr_attendance.script', function(require) {
"use strict";
var core = require('web.core');
var Model = require('web.Model');
var Widget = require('web.Widget');
var QWeb = core.qweb;
var _t = core._t;
instance.web.WebClient.include({
init: function (parent, action) {
this._super.apply(this, arguments);
this.next_action = 'mail.mail_channel_action_client_chat';
return this._super();
},
});
});
And this is my xml:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend_custom_id" name="tko_hr_attendance assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/tko_hr_attendance/static/src/js/script.js"></script>
</xpath>
</template>
</odoo>
I've tried following examples from odoo 8, 9 and 10, but I don't think they apply to the specific change I'm trying to make, or I either don't understand fully how the changes are applied.
To override the init First you need to get the class and you see in last code they put here
core.action_registry.add('hr_attendance_kiosk_confirm', KioskConfirm);
They add it to action_registry you shoud get using the same key.
var KioskConfirm = core.action_registry.get('hr_attendance_kiosk_confirm');
Then use include to override the init method but you should always call super in most cases.
KioskConfirm.include({
init : function (){
this._super.applay(this, arguments)
//.your code here
}
});
To understand javascript well read odoo tutorial building extension interface after one day you will get a very good idea how to do it