跳至內容
選單
此問題已被標幟
1 回覆
1354 瀏覽次數

Hi , i'm blocked i need to make a verification based on the view id in my xml template to display a button 

there is the code : 

 



頭像
捨棄
最佳答案

which mean you only want your button to display in a specific view id (xml id) not all view ?. please be more specific what view ?

頭像
捨棄
作者

yes exactly , i want to define a context and inside it a value to 'view_id' so in my xml template i can display the button in a specefic view and not all views , and that with t-if condition , exemple : <button class="btn btn-primary" t-on-click="display_archives" t-if="view_id == 1234">Archives</button>

Ok, so currently you want to display which kind of button in which view because i haven't seen a view_id in a normal xml qweb for form, list, etc view before ?
And is your problem like you add button in a product view example, but you only the button to be display on a specific product.product view because we all know product.product form view has several

作者

I

作者

Hi , so with an xml template i inherited tree view header and added a button , and i added to it a javascript function with return an action with a different domain wich allow to see archived record , the problem is that this button appears in all views of the module , but me i want that the button appears in one specefic view

A button can add directly in the tree view, you do not need js code like <button name="your action" string="Archive" invisible="1"/>
You can use condition to hidden that button

作者

No because in this case you need to select records to see the button, if you do not select record you can't see the button , what i want is a button that is always visible like "create" button

Try use res_model condition in you xml template for the button i guest

作者

yes but the model hasmany tree views and i want that the button be displayed in only specific one of them

use js_class attribute, search for odoo code to see
Normally, we will define a js class in js and in xml we will add js class in a tree view so that tree view will have the js code and xml template only

相關帖文 回覆 瀏覽次數 活動
2
4月 23
8501
3
9月 20
4441
2
4月 20
6192
2
3月 19
13095
0
1月 25
1129