Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
6 Trả lời
6496 Lượt xem

```

<?xml version="1.0" encoding="utf-8"?>

<odoo> 

 <data

<record model='ir.ui.view' id='view_print_button_sale_form'>

<field name='name'>print.button.sale.form</field> 

 <field name='model'>sale.order</field>

 <field name='inherit_id' ref='sale.view_order_form'/> 

 <field name='arch' type='xml'>
    <xpath expr="//button[@name='print_quotation']" position="attributes"> 

 <attribute name="states">[('state','=','sale')]</attribute>

</xpath> 

 </field>

 </record> 

 </data>

</odoo>

```

its giving me no error during installing but condition is not appear 

which point i'm missing ? 


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Usman,

You are almost doing it right way but you did just a small mistake. In the states attribute, you need to pass the one or more states separated by comma (,) and not the domain.

Ex:

<attribute name="states">sale,done</attribute>
The button will be visible only in sale and done state and will be hidden for other states.

Or you can use attrs as well instead of states attribute.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
Examples of possible solutions:

1. Only state = cancel

a) <attribute name="states">cancel</attribute>
b) <attribute name="attrs">{'invisible': [('state', '!=', 'cancel')]}</attribute>
c) <attribute name="attrs">{'invisible': [('state', 'not in', ('cancel',))]}</attribute>

2. state = cancel or state = done

a) <attribute name="states">cancel,done</attribute>
b) ---
c) <attribute name="attrs">{'invisible': [('state', 'not in', ('cancel','done'))]}</attribute>
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello @Usman,

Kindly use the below code.

<xpath expr="//button[@name='print_quotation']" position="attributes">

<attribute name="attrs">{'invisible': [('state', 'not in', [ 'cancel'])]}</attribute>

</xpath>

Regards,





Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

HI,

You can user below in your code:
    <attribute name="attrs">{'invisible': [('state', 'not in', [ 'cancel'])]}</attribute>​

 Thank you.

Ảnh đại diện
Huỷ bỏ
Tác giả

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

<!-- <attribute name="attrs">{'invisible': [('state', 'not in', 'done')]}</attribute> -->

<attribute name="attrs">{'invisible': [('state', 'not in', [ 'sale'])]}</attribute>

</xpath>

</field>

i put this query but i still not getting my require result ....

i just want to show print button only in sale state

It is not working because that button already has states attribute added in the core module.

States always reflected as attrs when it is parsed. So better to change its states attribute as shown in my answer.

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 23
4638
2
thg 9 22
4394
1
thg 6 22
3257
2
thg 7 23
784
4
thg 8 24
10562