Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
7 Ответы
13632 Представления

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

Related Posts Ответы Просмотры Активность
3
апр. 21
8290
2
июн. 20
5583
1
окт. 19
4546
1
сент. 18
106
1
сент. 17
6879