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

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?

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

Nope.

NameError: name 'user_permission' is not defined

Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất


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.


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 2 25
8683
3
thg 1 19
7236
2
thg 6 15
8209
2
thg 7 18
8198
2
thg 2 18
3995