Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
3706 Представления

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.


Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
февр. 25
8640
3
янв. 19
7222
2
июн. 15
8176
2
июл. 18
8172
2
февр. 18
3954