This is my odoo12 javascript code for timer widget i want to use that widget for odoo16 aswell but i am getting an that i am unable to run that code can anybody guide me that what should i do run this code in Odoo16 as well.
I have a float type field that i want to use that widget on that field.
odoo.define('employee_tracking.timer', function (require) {
"use strict";
var AbstractField = require('web.AbstractField');
var core = require('web.core');
var field_registry = require('web.field_registry');
var time = require('web.time');
var FieldManagerMixin = require('web.FieldManagerMixin');
var _t = core._t;
var TimeCounter = AbstractField.extend({
willStart: function () {
var self = this;
if(this.model=='emp_track.project'){
var my_domain = [['emp_task_id', '=', this.res_id]]
}
if(this.model=='qa_track.project'){
var my_domain = [['qa_task_id', '=', this.res_id]]
}
var def = this._rpc({
model: 'account.analytic.line',
method: 'search_read',
domain: my_domain,
}).then(function (result) {
if (self.mode === 'readonly') {
var currentDate = new Date();
self.duration = 0;
_.each(result, function (data) {
self.duration += data.date_end ?
self._getDateDifference(data.date_start, data.date_end) :
self._getDateDifference(time.auto_str_to_date(data.date_start), currentDate);
});
}
});
return $.when(this._super.apply(this, arguments), def);
},
destroy: function () {
this._super.apply(this, arguments);
clearInterval(this.timer);
},
isSet: function () {
return true;
},
_getDateDifference: function (dateStart, dateEnd) {
return moment(dateEnd).diff(moment(dateStart));
},
_render: function () {
this._startTimeCounter();
},
_startTimeCounter: function () {
var self = this;
clearInterval(this.timer);
if (this.record.data.is_user_working) {
this.timer = setTimeout(function () {
self.duration += 1000;
self._startTimeCounter();
}, 1000);
} else {
clearInterval(this.timer);
}
this.$el.html($('' + moment.utc(this.duration).format("HH:mm:ss") + ''));
},
});
field_registry.add('timesheet_uoms', TimeCounter);
});
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- Müşteri İlişkileri Yönetimi
- e-Commerce
- Muhasebe
- Envanter
- PoS
- Project
- MRP
Bu soru işaretlendi
1
Cevapla
1927
Görünümler
Hello ,
Please add
init: function () {
this._super.apply(this, arguments);
this.timer = this.record.data.timer;
},
and then check .
may be it work for you.
Thanks
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Üye Olİlgili Gönderiler | Cevaplar | Görünümler | Aktivite | |
---|---|---|---|---|
|
2
Tem 23
|
3926 | ||
|
2
Kas 22
|
7117 | ||
|
1
Kas 19
|
7400 | ||
|
0
Eyl 23
|
2181 | ||
|
1
Nis 24
|
2113 |