コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    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
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

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

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
viewseditpython2.7odooodoo-v9
5 返信
16576 ビュー
アバター
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
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
Filter many2one values
python2.7 odoo odoo-v9 odoo9 odoo9.0
アバター
0
10月 17
3693
How does line item display as kanban mode on mobile device 解決済
views odoo
アバター
アバター
アバター
2
7月 22
7838
How to hide bugs and error message for users in odoo
python2.7 odoo-v9
アバター
アバター
1
3月 22
8384
how to do for many2one domain filter?
python2.7 odoo
アバター
5
9月 20
8487
How to add a list of product in a view?
python2.7 odoo
アバター
アバター
1
10月 19
6630
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • 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、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

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