Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3153 Vistas

​I have check in and check out button in portal header , my need is that, default hide the check out button, after  clicking the check in button it will show the check out button and hide the check in . Based on my code i get that when i click the check in button the page will reload again and the check in button remain the same . How i solve this, am using odoo 16 Community.Here is my code.

XML:




XML code in the comment box







Js:


odoo.define('check_in_out.checked', function (require) {
"use strict";

var ajax = require('web.ajax');

$(document).ready(function() {
$('.check-in-btn').click(function() {
$(this).hide();
$('.check-out-btn').show();
});

$('.check-out-btn').click(function() {
$(this).hide();
$('.check-in-btn').show();
});
});
});


Thanks

Avatar
Descartar
Autor

<template id="portal_layout" inherit_id="website.template_header_default"
name="Attendance Button">
<xpath expr="//t[@t-call='portal.user_dropdown']" position="after">
<a class="btn btn-primary check-in-btn" href="/attendance/checkin"
id="check_in">Check In
</a>
<a class="btn btn-primary check-out-btn" href="/attendance/checkout"
id="check_out" style="display: none;">Check Out
</a>
</xpath>
</template>

Mejor respuesta

You can achieve this without using js , please update your code like this, this may help you,

<template id="portal_layout" inherit_id="website.template_header_default"
          name="Attendance Button">
    <xpath expr="//t[@t-call='portal.user_dropdown']" position="after">
        <a class="btn btn-primary check-in-btn" href="/attendance/checkin"
           id="check_in" t-if="request.env['hr.employee'].search([('user_id', '=', request.env.user.id)]).attendance_state == 'checked_out'">Check In
        </a>
        <a class="btn btn-primary check-out-btn" href="/attendance/checkout"
           id="check_out" t-if="request.env['hr.employee'].search([('user_id', '=', request.env.user.id)]).attendance_state == 'checked_in'">Check Out
        </a>
    </xpath>
</template>


Hope it helps

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
abr 24
1735
0
feb 23
2196
1
may 25
1850
2
jun 24
2139
0
dic 23
2249