Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

469
Visualizações
How to hide/invisible a button in odoo helpdesk using js

In Odoo version 15 I created a Js cod Based on the button Accept and Deny and I created a boolean field in res users model. The workflow is: if the user clicks the Accept button the boolean field makes True and clicks the Denay button it change to False state. The Functionality is working well. Currently, the issue am facing is both buttons are showing on page refresh time. How to solve this ... Actually I want to show only One button based on the user availability( based on the Boolean field)

IN XML SIDE:

<templates>
     <t t-extend="ListView.buttons" t-name="AttendenceMarkListView.buttons">
        <t t-jquery="button.o_list_button_add" t-operation="after">
<!--            <t t-if="widget.isAvailable()">-->


            <button t-if="widget.modelName == 'helpdesk.ticket'" type="button" class="btn btn-secondary btn-secondary-new o_button_accept_ticket">
                Accept
            </button>
            <button t-if="widget.modelName == 'helpdesk.ticket'" type="button" class="btn btn-secondary btn-secondary-new o_button_deny_ticket">
                Deny
            </button>
<!--                  </t>-->
        </t>
    </t>
</templates>

and in JS side:

odoo.define('attendance.button.tree', function (require) {
"use strict";
    var core = require('web.core');
    var ListController = require('web.ListController');
    var ListView = require('web.ListView');
    var viewRegistry = require('web.view_registry');
    var rpc = require('web.rpc')

    var includeDict = {
        buttons_template: 'AttendenceMarkListView.buttons',
        renderButtons: function ($node) {
            this._super.apply(this, arguments);
            var self = this;
            this.$buttons.on('click', '.o_button_accept_ticket', this._onAcceptAttendance.bind(this));
            this.$buttons.on('click', '.o_button_deny_ticket', this._onDeclineAttendance.bind(this));
        },
        _onAcceptAttendance: function(){
            var self = this;
            this.$('.o_button_accept_ticket').hide();
            this.$('.o_button_deny_ticket').show();
            rpc.query({
            model: 'helpdesk.ticket',
            method: 'user_accept_ticket',
            args: [],
        }, {
            shadow: true,
        }).then(function () {

        });
        },
         _onDeclineAttendance: function(){
            var self = this;
            this.$('.o_button_deny_ticket').hide();
            this.$('.o_button_accept_ticket').show();
            rpc.query({
            model: 'helpdesk.ticket',
            method: 'user_decline_ticket',
            args: [],
        }, {
            shadow: true,
        }).then(function () {

        });
        },
    };

    ListController.include(includeDict);

});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Template :

<templates>
    <t t-extend="ListView.buttons" t-name="AttendenceMarkListView.buttons">
        <t t-jquery="button.o_list_button_add" t-operation="after">
                 <button id="button_accept" t-if="widget.modelName == 'helpdesk.ticket'" type="button" class="btn btn-secondary btn-secondary-new o_button_accept_ticket">
                    Accept
                </button>
                <button id="button_reject" t-if="widget.modelName == 'helpdesk.ticket'" type="button" class="btn btn-secondary btn-secondary-new o_button_deny_ticket">
                    Deny
                </button>

        </t>
    </t>
</templates>

**Js Side:**
odoo.define('attendance.button.tree', function (require) {
"use strict";
    var core = require('web.core');
    var ListController = require('web.ListController');
    var ListView = require('web.ListView');
    var viewRegistry = require('web.view_registry');
    var rpc = require('web.rpc')

    var includeDict = {
        buttons_template: 'AttendenceMarkListView.buttons',
        renderButtons: function ($node) {
            this._super.apply(this, arguments);
            var self = this;
            this.$buttons.on('click', '.o_button_accept_ticket', this._onAcceptAttendance.bind(this));
            this.$buttons.on('click', '.o_button_deny_ticket', this._onDeclineAttendance.bind(this));

        },
        _onAcceptAttendance: function(){
            var self = this;
            this.$('.o_button_accept_ticket').hide();
            this.$('.o_button_deny_ticket').show();
            return self._rpc({
            model: 'helpdesk.ticket',
            method: 'user_accept_ticket',
            args: [],
            }).then(function (data) {

            });
        },

         _onDeclineAttendance: function(){
            var self = this;
            this.$('.o_button_deny_ticket').hide();
            this.$('.o_button_accept_ticket').show();
            return self._rpc({
                model: 'helpdesk.ticket',
                method: 'user_decline_ticket',
                args: [],
            }).then(function (data) {
                      

                });
        },



    };

    ListController.include(includeDict);

});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda