Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Is it possible hide "Edit" button on form view by extending base.xml?

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
viewseditpython2.7odooodoo-v9
5 Respuestas
16566 Vistas
Avatar
Ugne Sinkeviciene

Hello,

I am trying to hide "Edit" button in specific view by specific record state. Now I extended base.xml and can hide "Edit" button in specific view by view name like this:

<templates>

<t t-extend="FormView.buttons">

    <t t-jquery="button.oe_form_button_create" t-operation="replace">

        <t t-if="widget.fields_view.name == 'purchase.request.form'">

            <button t-if="widget.is_action_enabled('edit')"

                    type="button"

                    class="oe_form_button_edit btn btn-default btn-sm" accesskey="E">

                Edit

            </button>

        </t>

</templates>

But is it possible to hide "Edit" button depend on specific record state in specific view. I tired to add <t t-if="widget.datarecord.state !== 'to_approve_first'"></t> to my extended xml:


<templates>

<t t-extend="FormView.buttons">

    <t t-jquery="button.oe_form_button_create" t-operation="replace">

        <t t-if="widget.fields_view.name == 'purchase.request.form'">

           <t t-if="widget.datarecord.state !== 'to_approve_first'">

            <button t-if="widget.is_action_enabled('edit')"

                    type="button"

                    class="oe_form_button_edit btn btn-default btn-sm" accesskey="E">

                Edit

            </button>

          </t>

        </t>

</templates>

But nothing happens. Is it something wrong with my code or I can't do that by changing base.xml view?

How else can I solve this problem? By changing javascript code?

1
Avatar
Descartar
Asmita Chavan

I haven't tried it through xml , but through Jquery it's possible.

you want to hide that button for specific model only right?

Avatar
Asmita Chavan
Mejor respuesta

Try this way, hope this will work for you..

I have kept button hidden on sale.order form, when it's state=='sale'

odoo.define('custom_web_changes.custom_form_view', function (require) {
"use strict";

var core = require('web.core');
var FormView = require('web.FormView');

var _t = core._t;
var QWeb = core.qweb;

FormView.include({
	load_record: function(record) {
		this._super.apply(this, arguments);
		if (this.model=='sale.order'){
			if (this.get_fields_values().state=='sale'){
	        	this.$buttons.find('.o_form_button_edit').css({"display":"none"});
	        }
	        else{
	        	this.$buttons.find('.o_form_button_edit').css({"display":""});
	        }
		}
        
	}
	
});

});
4
Avatar
Descartar
Ugne Sinkeviciene
Autor

Hello, thank you for your help. I created mymodule.js file with your suggested code, just changed model name to mine - 'purchase.request' and state to - 'create_order'. Also created mymodule.xml file with code:

<?xml version="1.0" encoding="UTF-8"?>

<odoo>

<template id="assets_backend" inherit_id="web.assets_backend">

<xpath expr="." position="inside">

<script src="/purchase_request/static/src/js/mymodule.js" type="text/javascript" />

</xpath>

</template>

</odoo>

Added mymodule.js and mymodule.xml files to manifest but nothing happens. When the purchase model state is create_order "Edit" button still not hidden. What can be wrong? Also I want to ask about "custom_web_changes.custom_form_view". What does these means? Module name and what else? Thank you in advance.

Asmita Chavan

hey hi,

custom_web_changes is module name and custom_form_view is unique id assigned to custom web module we are defining.

Once module is installed, please check whether your custom code is working or not,

please check browser console for that.

put some console.log() statements in load_record function defined in mymodule.js file.

Asmita Chavan

in place of "custom_web_changes.custom_form_view", you can put "purchase_request.custom_form_view".

Please try installing module i have created, and let me know whether it's working or not. i hope that will be helpful for you.

get code from : https://github.com/chavanasmita/odoo-hide_edit_button.git

Ugne Sinkeviciene
Autor

Thank you so much!!! I checked your github code. The problem was that I am using odoo v9 and "Edit" button class is oe_form_button_edit instead of o_form_button_edit. One more question is it a possibility with the same javascript hide button depend on user group role?

wizardz

how to remove the bounce effect? when you click on the form. the edit button shows up again?

Avatar
Rafiul
Mejor respuesta

Hi...

There is another solution to achieve that using java script. I've done this on odoo14 and works smoothly. Here is some code sample -

odoo.define('your_module_name.hide_form_view_edit_button', function (require) {
"use strict";

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

FormController.include({
updateButtons: function () {
if (!this.$buttons) {
return;
}
console.log("-----------buttons")
if (this.footerToButtons) {
var $footer = this.renderer.$el && this.renderer.$('footer');
if
($footer && $footer.length) {
this.$buttons.empty().append($footer);
}
}
            //specify the model where you want to hide the edit
            //button based on field value
if (this.modelName === "your.model.name") { 
          
                console.log(this);
                // It will print a Json Object with all available
                //data regarding your current view
                //In my case I had to check the sate field and
                //I found the value of sate field in
                //this.renderer.state.data.state
            

if (this.renderer.state.data.state !== "draft") {
this.$buttons.find('.o_form_button_edit')
                            .toggleClass('o_hidden', true);
} else {
this.$buttons.find('.o_form_button_edit')
                            .toggleClass('o_hidden', false);
}
} else {
this.$buttons.find('.o_form_button_edit')
                        .toggleClass('o_hidden', false);
}
var edit_mode = (this.mode === 'edit');
this
.$buttons.find('.o_form_buttons_edit')
.toggleClass('o_hidden', !edit_mode);
this
.$buttons.find('.o_form_buttons_view')
.toggleClass('o_hidden', edit_mode);

},
});

Don't forget to add the js file to your template.xml file and the template.xml file to your manifest file.

Best of luck.


0
Avatar
Descartar
Avatar
XFanis
Mejor respuesta

Hi, you can use this module

https://apps.odoo.com/apps/modules/10.0/hide_action_buttons/

It is for ODOO v 10, but you can see how it can work.

0
Avatar
Descartar
Avatar
Praveen Kumar
Mejor respuesta

Hi Asmita Chavan, thanks for your answer.

I'm not expert in JS. I'm using Odoo version 14 and used your solution. I'm not sure what I'm doing wrong, the Edit button is not getting hidden.

Please let me know if we need to follow a different syntax for V14.

Thanks in advance!

0
Avatar
Descartar
Avatar
wizardz
Mejor respuesta

the only problem with this, is that the form_view.js has a bouncing function for the edit button. So when you click on the form in the sale.order, the edit button displays...

any fix for that?

0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Filter many2one values
python2.7 odoo odoo-v9 odoo9 odoo9.0
Avatar
0
oct 17
3691
How does line item display as kanban mode on mobile device Resuelto
views odoo
Avatar
Avatar
Avatar
2
jul 22
7832
How to hide bugs and error message for users in odoo
python2.7 odoo-v9
Avatar
Avatar
1
mar 22
8377
how to do for many2one domain filter?
python2.7 odoo
Avatar
5
sept 20
8483
How to add a list of product in a view?
python2.7 odoo
Avatar
Avatar
1
oct 19
6624
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

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