1

In sale.order form view, there are two buttons Send by Email. One for draft state and another for sent, sale. I need to hide both buttons. I tried below code:

   <xpath expr="//button[@name='action_quotation_send']" position="attributes">
      <attribute name="invisible">1</attribute>
   </xpath>

The result is: The button in draft state become invisible, another button is still visible.

How can I hide that button too?

KbiR
  • 4,047
  • 6
  • 37
  • 103

3 Answers3

0

Use below code how it is, to hide both buttons by replacing with nothing.

<xpath expr="//button[@name='action_quotation_send']" position="replace"/>
<xpath expr="//button[@name='action_quotation_send']" position="replace"/>

I know it looks weird cause its exactly the same code twice but it worked for me.

  • I don't think so it will work. Your code will always apply to first button. It will never goes to another/second button. – Bhavesh Odedra Aug 01 '17 at 15:17
  • It does, im using this to hide exactly those two buttons. As soon as i replace the first button with nothing, the second xpath will call the second button because the first one is not available any longer. –  Aug 02 '17 at 06:12
0

We have to set attribute for both buttons.

Try with following code:

<xpath expr="//button[@name='action_quotation_send' and @states='sent']" position="attributes">
    <attribute name="states" /> <!-- delete states attribute, it's influencing invisible behaviour -->
    <attribute name="invisible">1</attribute>
</xpath
<xpath expr="//button[@name='action_quotation_send' and @states='draft']" position="attributes">
    <attribute name="states" /> <!-- delete states attribute, it's influencing invisible behaviour -->
    <attribute name="invisible">1</attribute>
</xpath>
Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58
0

I know it's late, but might help someone in future.

<xpath expr="(//button[@name='action_quotation_send'])[1]" position="attributes">
...
</xpath>
<xpath expr="(//button[@name='action_quotation_send'])[2]" position="attributes">
...
</xpath>

Refer How can you identify multiple elements with the same name in XPath?

art
  • 1,358
  • 1
  • 10
  • 24