跳至內容
選單
此問題已被標幟
2 回覆
3730 瀏覽次數

Hi guys I am having a problem with attrs tags not working.

I defined it this way:

pseudo code:

'readonly':[('many2one_field','=','function.field(type='integer')]'

real code:

<field name="product_id" attrs="{'readonly':[('warehouse_id','=','user_permission')]}"/>

Function field is right above this field so it is created and it returns {id:value}.

What am I doing wrong?

頭像
捨棄
作者 最佳答案

Nope.

NameError: name 'user_permission' is not defined

頭像
捨棄

For you additional functional field should be a solution. see my answer.

最佳答案


you can take another approach,


add one more field in your model:

_columns = {
    'is_editable': fields.function(_is_editable, type='boolean', string="Can Be Edited"),
    ...
}


implement _is_editable -function in your model that will calculate is_editable field according your requirements. 

then in xml, use is_editable field as follows:

<field name="is_editable" invisible="1"/>
<field name="product_id" attrs="{'readonly':[('is_editable','=',False)]}"/>


cheers.


頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
2月 25
8656
3
1月 19
7227
2
6月 15
8192
2
7月 18
8180
2
2月 18
3970