跳至内容
菜单
此问题已终结
    <group string="Filter Options">

<field name="vendor_id" options="{'no_create':True, 'no_edit':True}"
attrs="{'readonly': [('state', '=', 'done')]}"/>
<field name="date_from" options="{'no_create':True, 'no_edit':True}"
readonly="state = 'done'"/>
<field name="date_to" options="{'no_create':True, 'no_edit':True}"
attrs="{'readonly': [('state', '=', 'done')]}"/>
</group>
</group>
<footer>
<button name="action_export_excel" string="Generate Excel report" type="object"
class="btn-primary" attrs="{'invisible': [('state', '=', 'done')]}"/>
<button name="action_reset"
string="Generate New Report"
type="object"
class="btn-secondary"
attrs="{'invisible': [('state', '=', 'draft')]}"/>
<button string="Close"
class="btn-secondary"
special="cancel"/>
</footer>

These are the same files separate parts of odoo18, when i run this , there has a error like"Invalid modifier 'readonly': “state = 'done'”"

invalid syntax (<unknown>, line 1)

And also I think this attibute placing way has a issue, Can Someone help me to solve this, I am a beginner, I think this way is not supported to odoo18

形象
丢弃
最佳答案

Hi,

In Odoo 18, the syntax of attributes has changed.


Try with the following code.


<group string="Filter Options">
<field name="vendor_id" options="{'no_create':True, 'no_edit':True}"
readonly="state == 'done'"/>
<field name="date_from" options="{'no_create':True, 'no_edit':True}"
readonly="state == 'done'"/>
<field name="date_to" options="{'no_create':True, 'no_edit':True}"
readonly="state == 'done'"/>
</group>



<footer>
<button name="action_export_excel" string="Generate Excel report" type="object"
class="btn-primary" readonly="state == 'done'"/>
<button name="action_reset"
string="Generate New Report"
type="object"
class="btn-secondary"
invisible="state == 'draft'"/>
<button string="Close"
class="btn-secondary"
special="cancel"/>
</footer>



Hope it helps.

形象
丢弃
相关帖文 回复 查看 活动
0
2月 16
3612
1
5月 15
6561
0
1月 25
1615
0
6月 21
5299
0
6月 21
14