Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
7 Odpowiedzi
13625 Widoki

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')]}"/>                  
Awatar
Odrzuć
Najlepsza odpowiedź

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 ...

Awatar
Odrzuć
Najlepsza odpowiedź

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. :)

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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>
Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

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

Autor

@raaj Please see my updated answer

Powiązane posty Odpowiedzi Widoki Czynność
3
kwi 21
8286
2
cze 20
5579
1
paź 19
4543
1
wrz 18
106
1
wrz 17
6876