Skip to Content
Odoo Меню
  • Увійти
  • Спробуйте це безкоштовно
  • Додатки
    Фінанси
    • Бухоблік
    • Виставлення рахунку
    • Витрати
    • Електронні таблиці (BI)
    • Документи
    • Підпис
    Продажі
    • CRM
    • Продажі
    • POS Магазин
    • POS Ресторан
    • Підписки
    • Оренда
    Веб-сайти
    • Конструктор веб-сайту
    • Електронна комерція
    • Блог
    • Форум
    • Живий чат
    • Електронне навчання
    Ланцюг поставок
    • Склад
    • Виробництво
    • PLM
    • Купівлі
    • Технічне обслуговування
    • Якість
    Кадри
    • Співробітники
    • Рекрутинг
    • Відпустки
    • Оцінювання
    • Рекомендації
    • Автотранспорт
    Маркетинг
    • Маркетинг соцмереж
    • Email-маркетинг
    • SMS-маркетинг
    • Події
    • Автом. маркетингу
    • Опитування
    Послуги
    • Проект
    • Табелі
    • Виїзне обслуговування
    • Служба підтримки
    • Планування
    • Призначення
    Продуктивність
    • Обговорення
    • Схвалення
    • IoT
    • IP-телефонія
    • База знань
    • WhatsApp
    Сторонні модулі Odoo Studio Платформа Odoo Cloud
  • Сфери
    Роздрібна торгівля
    • Книжковий магазин
    • Магазин одягу
    • Магазин меблів
    • Продуктовий магазин
    • Магазин будівельних матеріалів
    • Магазин іграшок
    Food & Hospitality
    • Бар та паб
    • Ресторан
    • Фастфуд
    • Guest House
    • Дистриб'ютор напоїв
    • Hotel
    Real Estate
    • Real Estate Agency
    • Архітектурна фірма
    • Будівництво
    • Управління нерухомістю
    • Садівництво
    • Асоціація власників нерухомості
    Consulting
    • Accounting Firm
    • Партнер Odoo
    • Marketing Agency
    • Юридична фірма
    • Придбання Талантів
    • Аудит та сертифікація
    Виробництво
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Корпоративні подарунки
    Здоров'я & Фітнес
    • Спортивний клуб
    • Оптика
    • Фітнес-центр
    • Практики здоров'я
    • Аптека
    • Салон краси
    Trades
    • Ремонтник
    • IT-обладнання та Підтримка
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Екологічна агенція
    • Оренда білбордів
    • Фотографія
    • Лізинг велосипедів
    • Реселлер програмного забезпечення
    Browse all Industries
  • Спільнота
    Навчання
    • Навчальний посібник
    • Документація
    • Сертифікації
    • Тренування
    • Блог
    • Подкаст
    Сприяйте Освіті
    • Програма навчання
    • Бізнес гра Scale Up!
    • Відвідайте Odoo
    Отримайте програмне забезпечення
    • Завантаження
    • Порівняйте версії
    • Релізи
    Співпрацюйте
    • Github
    • Форум
    • Події
    • Переклади
    • Стати партнером
    • Services for Partners
    • Зареєструйте вашу бухгалтерську фірму
    Отримайте послуги
    • Знайдіть партнера
    • Знайдіть бухгалтера
    • Зустріньтеся з консультантом
    • Послуги з впровадження
    • Референси клієнтів
    • Підтримка
    • Оновлення
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Отримати демо
  • Ціни
  • Допомога

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

  • CRM
  • e-Commerce
  • Бухоблік
  • Склад
  • PoS
  • Проект
  • MRP
All apps
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Допомога

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

Підписатися

Отримуйте сповіщення про активність щодо цієї публікації

Це запитання позначене
viewseditpython2.7odooodoo-v9
5 Відповіді
16512 Переглядів
Аватар
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
Аватар
Відмінити
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?

Аватар
Asmita Chavan
Найкраща відповідь

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
Аватар
Відмінити
Ugne Sinkeviciene
Автор

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
Автор

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?

Аватар
Rafiul
Найкраща відповідь

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
Аватар
Відмінити
Аватар
XFanis
Найкраща відповідь

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
Аватар
Відмінити
Аватар
Praveen Kumar
Найкраща відповідь

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
Аватар
Відмінити
Аватар
wizardz
Найкраща відповідь

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
Аватар
Відмінити
Enjoying the discussion? Don't just read, join in!

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

Реєстрація
Related Posts Відповіді Переглядів Дія
Filter many2one values
python2.7 odoo odoo-v9 odoo9 odoo9.0
Аватар
0
жовт. 17
3641
How does line item display as kanban mode on mobile device Вирішено
views odoo
Аватар
Аватар
Аватар
2
лип. 22
7760
How to hide bugs and error message for users in odoo
python2.7 odoo-v9
Аватар
Аватар
1
бер. 22
8283
how to do for many2one domain filter?
python2.7 odoo
Аватар
5
вер. 20
8404
How to add a list of product in a view?
python2.7 odoo
Аватар
Аватар
1
жовт. 19
6554
Спільнота
  • Навчальний посібник
  • Документація
  • Форум
Open Source
  • Завантаження
  • Github
  • Runbot
  • Переклади
Послуги
  • Хостинг Odoo.sh
  • Підтримка
  • Оновлення
  • Кастомні доробки
  • Навчання
  • Знайдіть бухгалтера
  • Знайдіть партнера
  • Стати партнером
Про нас
  • Наша компанія
  • Торгові активи
  • Зв'яжіться з нами
  • Вакансії
  • Події
  • Подкаст
  • Блог
  • Клієнти
  • Юридичні документи • Конфіденційність
  • Безпека
الْعَرَبيّة 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 - це набір програм для роботи з відкритим кодом, які охоплюють всі ваші потреби компанії: CRM, електронна комерція, бухгалтерський облік, склад, точка продажу, управління проектами тощо.

Унікальна пропозиція Odoo - це одночасно дуже проста у використанні та повністю інтегрована.

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