コンテンツへスキップ
メニュー
この質問にフラグが付けられました
7 返信
13651 ビュー

Hello,

I need to replace a button function which is a window action in sale.order form view, for making the button visible to a certain group of users.How to achieve that.

This is the button function to be replaced:

<button name="%(action_view_sale_advance_payment_inv)d" string="Create Invoice"        
    type="action" class="btn-primary"                      
    attrs="{'invisible': [('invoice_status', '!=', 'to invoice')]}"/> 

<button name="%(action_view_sale_advance_payment_inv)d" string="Create Invoice"
    type="action" context="{'default_advance_payment_method': 'percentage'}"
    attrs="{'invisible': ['|',('invoice_status', '!=', 'no'), ('state', '!=', 'sale')]}"/>                  
アバター
破棄
最善の回答

Hi,

You can use the following code to reach the button and update it:

<record id="view_order_form" model="ir.ui.view">
 <field name="name">sale.order.form</field>
  <field name="model">sale.order</field>
 <field name="inherit_id" ref="sale.view_order_form"/>
  <field name="arch" type="xml">
 <button name="%(sale.action_view_sale_advance_payment_inv)d" position="attributes">
 <attribute ... > ...</attribute>
 </button>
 </field>
 </record>


Hope this could helps ...

アバター
破棄
最善の回答

I wanted to limit the "Create Invoice" Button to the Billing group and I found that the code from Ahmed and Pravitha only removed the first instance of the button but I used the following code to remove both:

<xpath expr="//button[@name='%(sale.action_view_sale_advance_payment_inv)d'][1]" position="attributes">
    <attribute name="groups">account.group_account_invoice</attribute>
</xpath>
<xpath expr="//button[@name='%(sale.action_view_sale_advance_payment_inv)d'][2]" position="attributes">
    <attribute name="groups">account.group_account_invoice</attribute>
</xpath>

Hope this helps anyone trying to do the same thing. :)

アバター
破棄
著作者 最善の回答

The solution for the above query is:

inherit the sale_order view then add the below code

 <button name="%(sale.action_view_sale_advance_payment_inv)d" position="attributes">
    <attribute name="groups">sale.group_sale_manager,sale.group_sale_coo,sale.group_sale_ceo</attribute>
</button>
アバター
破棄
最善の回答

Hi Pravitha,you can check using the position for that button for example:

<xpath expr="//form/sheet/....button[num]" position="replace"/>

where, num = 0,1,2..

Or else you can check the id for that windows action and you can user that id as name at your xpath. like, I have assumed the id as 456.But this Id may be change once you upgrade or migrate the module.

<xpath expr="//form/sheet/header/button[@name='456']" position="replace"/>

I hope it will help you.

If avove 2 methods will not work then, you can go with redefining the view to achive the required functionality.

アバター
破棄
著作者

Thankyou , but it didnt work

Then may be you need to redefine the entire from view and there you can provide the required groups to buttons.

Also please let me know if you get any alternate and best solution for this.Thanks

著作者

@raaj Please see my updated answer

関連投稿 返信 ビュー 活動
3
4月 21
8307
2
6月 20
5587
1
10月 19
4552
1
9月 18
106
1
9月 17
6884