Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

Caused by: TypeError: this is null in Odoo 18 Owl js which creating a scheduler dashboard

Dette spørgsmål er blevet anmeldt
Spørgsmålet er blevet lukket på grund af: Question / Code not indented
af Rakesh Patel (patr) på 07.11.2024 01:47:15
Cybrosys
2620 Visninger
Avatar
Mohammed Farhan k c
/** @odoo-module **/

import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
import { useService } from '@web/core/utils/hooks';
import { Component, onWillStart, useState } from "@odoo/owl";

const monthNames = [
"", "January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"
];

export class TrainingDashboard extends Component {
static template = "TrainingDashboardMain";
setup(){
super.setup();
this.state = useState({
month: 1,
monthName: monthNames[1],
instructor: null,
instructorName: "Not Selected",
instructorsData: [],
year: null,
yearsData: [],
schedulesData: [],
noOfDaysData: [],
totalHoursData: 0,
loading: true,
});
this.action = useService("action");

onWillStart(async () => {
await this.loadDatas();
});
}

// -------------- On Clicking Buttons ---------------

onClickAddSchedule = () => {
this.action.doAction({
name: _t("My Planning"),
type: 'ir.actions.act_window',
res_model: 'training.slot',
view_mode: 'tree,form,calendar',
views: [[false, 'form']],
target: 'new',
});
}

onClickPrintSchedule = () => {
this.action.doAction({
name: _t("Print Schedule"),
type: 'ir.actions.act_window',
res_model: 'customer.schedule.report',
view_mode: 'tree,form',
views: [[false, 'form']],
target: 'new',
});
}

onClickPrint = () => {
this.action.doAction({
name: _t("Month Schedule"),
type: 'ir.actions.act_window',
res_model: 'schedule.board.print',
view_mode: 'form',
views: [[false, 'form']],
target: 'new',
});
}

onClickSearch = async () => {
this.state.loading = true;
const month = this.state.month;
const year = this.state.year;
const instructor = this.state.instructor;
const response = await fetch(`/api/get_custom_training_dashboard_datas?month=${month}&year=${year}&instructor=${instructor}`);
const data = await response.json();
console.log("data", data);
if (response.ok) {
this.state.noOfDaysData = data.response.no_of_days;
this.state.schedulesData = data.response.schedules;
this.state.totalHoursData = data.response.total_hours;
}
this.state.loading = false;
}


// ------------- Load Datas From API -------------------

async loadDatas() {
this.state.loading = true;
const response = await fetch('/api/get_training_dashboard_datas');
const data = await response.json();
console.log("data", data);
if (response.ok) {
this.state.yearsData = data.response.years;
this.state.year = Math.max(...data.response.years);
this.state.instructorsData = data.response.instructors;
this.state.instructor = data.response.instructors ? data.response.instructors[0].id : null;
this.state.noOfDaysData = data.response.no_of_days;
this.state.schedulesData = data.response.schedules;
this.state.totalHoursData = data.response.total_hours;
// Set initial values for monthName and instructorName based on data
this.updateMonthName();
this.updateInstructorName();
}
this.state.year = 2024;
this.state.month = 11;
this.state.instructor = 23;
this.state.loading = false;
}

// --------- Updaters Function ------------

// Update the displayed month name based on the current month value
updateMonthName() {
this.state.monthName = monthNames[this.state.month];
}

// Update displayed instructor name or default to "Not Selected"
updateInstructorName() {
const instructorId = Number(this.state.instructor);
const instructor = this.state.instructorsData.find(inst => inst.id === instructorId);
this.state.instructorName = instructor ? instructor.name : "Not Selected";
}

}

registry.category("actions").add("training_dashboard", TrainingDashboard);


<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="TrainingDashboardMain">
<style>
table, th, td {
border: 1px solid black;
}
th, td {
text-align: center;
max-width: 50px;
word-wrap: break-word;
}
thead th {
background-color: #ABDD93;
position: sticky;
top: 0;
z-index: 1;
}
.dashboard-container {
padding: 15px;
position: relative;
}
.filter-container {
display: flex;
flex-wrap: wrap;
gap: 10px;
align-items: center;
}
/* Loader styling */
.loading-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background: rgba(255, 255, 255, 0.7);
z-index: 1000;
}
.spinner-border {
width: 3rem;
height: 3rem;
}
@media (max-width: 576px) {
.dashboard-buttons, .filter-container {
justify-content: center;
}
.filter-container .col {
width: 100%;
text-align: center;
}
}
</style>

<div class="dashboard-container">
<!-- Loader overlay -->
<t t-if="state.loading">
<div class="loading-overlay">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</t>
<!-- Dashboard Content -->
<div class="row">
<!-- Left side buttons -->
<div class="col-md-6 col-12 row gap-3 border-end">
<div class="col-12">
<div class="d-flex justify-content-between align-items-center">
<h5>Instructor: <span class="fw-bolder" t-esc="state.instructorName || 'Not Selected'"/></h5>
<h5>Month: <span class="fw-bolder" t-esc="state.monthName"/></h5>
<h5>Year: <span class="fw-bolder" t-esc="state.year"/></h5>
</div>
<h5>Total Hours: <span class="fw-bolder" t-esc="state.totalHoursData"/></h5>
</div>
<div class="col-12 d-flex justify-content-start align-items-end">
<button class="btn btn-warning btn-sm rounded-pill me-2 fw-bolder text-white "
type="button" t-on-click="() => onClickAddSchedule()">Add Schedule</button>
<button class="btn btn-success btn-sm rounded-pill me-2 fw-bolder"
type="button" t-on-click="() => onClickPrintSchedule()">Print Schedule</button>
<button class="btn btn-primary btn-sm rounded-pill fw-bolder" type="button"
t-on-click="() => onClickPrint()">Print</button>
</div>
</div>

<!-- Right side filters and search button -->
<div class="col-md-6 col-12 filter-container d-flex justify-content-center align-items-center">
<div class="col-auto">
<label for="inst" class="form-label">Instructor</label>
<select t-model="state.instructor" class="form-select form-select-sm"
t-on-change="updateInstructorName">
<t t-foreach="state.instructorsData" t-as="instructor" t-key="instructor.id">
<option t-att-value="instructor.id"><t t-esc="instructor.name"/></option>
</t>
</select>
</div>
<div class="col-auto">
<label for="month" class="form-label">Month</label>
<select t-model="state.month" class="form-select form-select-sm" t-on-change="updateMonthName">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
</div>
<div class="col-auto">
<label for="year" class="form-label">Year</label>
<select t-model="state.year" class="form-select form-select-sm">
<t t-foreach="state.yearsData" t-as="year" t-key="year">
<option t-att-value="year"><t t-esc="year"/></option>
</t>
</select>
</div>
<div class="col-auto">
<button class="btn btn-primary btn-sm rounded mt-md-4" type="button"
t-on-click="() => onClickSearch()">Search</button>
</div>
</div>
</div>
<hr class="my-2"/>
<!-- datas -->
<div class="row">
<div class="col-sm-12 col-lg-12 leave-manager">
<div style="overflow-y:auto; height: 500px;border: 1px solid black;border-radius: 7px;width:100%;">
<table style="border: 1px solid black;border-radius: 7px;width:100%;height:100%">
<thead>
<tr>
<th class="fw-bolder">Time/Date</th>
<t t-foreach="state.noOfDaysData" t-as="day" t-key="day">
<th class="fw-bolder"><t t-esc="day"/></th>
</t>
</tr>
</thead>
<tbody>
<t t-foreach="state.schedulesData" t-as="schedule" t-key="schedule">
<tr>
<t t-foreach="schedule" t-as="data" t-key="data">
<t t-if="data.code=='N'">
<td><t t-esc="data.value"/></td>
</t>
<t t-elif="data.code=='F'">
<td bgcolor="#F0F042"><t t-esc="data.value"/></td>
</t>
<t t-elif="data.code=='L'">
<td bgcolor="#ED8A49"><t t-esc="data.value"/></td>
</t>
<t t-elif="data.code=='P'">
<td style="color:#DB6262"><t t-esc="data.value"/></td>
</t>
<t t-elif="data.code=='R'">
<td><t t-esc="data.value"/></td>
</t>
<t t-elif="data.code=='FP'">
<td style="color:#DB6262;background-color: #F0F042;"><t t-esc="data.value"/></td>
</t>
<t t-elif="data.code=='FR'">
<td style="color:#0A0000;background-color: #F0F042;"><t t-esc="data.value"/></td>
</t>
</t>
</tr>
</t>
</tbody>
</table>
</div>
</div>
</div>
</div>
</t>

<t t-name="EmployeeWarning">
<div>
<p>Error : Could not find employee linked to user</p>
<p>Please contact system admin for the setup</p>
</div>
</t>

</templates>

Avatar
Kassér
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
Odoo 16 add custom button next to create button in tree view Løst
Cybrosys
Avatar
Avatar
Avatar
2
okt. 24
4949
odoo report downloading in doc/docx file
Cybrosys
Avatar
Avatar
1
maj 24
2509
Odoo 16 Migrations Error Løst
Cybrosys
Avatar
Avatar
1
okt. 23
3037
How to hide a menu from admin but not from normal user, is it possible or not ?
Cybrosys
Avatar
Avatar
1
dec. 22
3395
Api.autovacuum Not working
Cybrosys
Avatar
0
okt. 22
2166
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now