Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

[v7] Attrs readonly on comparing m2o and func field

By
HateCamel
on 5/18/15, 11:32 AM 482 views

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?

0
HateCamel
On 5/18/15, 5:18 PM

Nope.

NameError: name 'user_permission' is not defined

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

Temur
on 5/19/15, 6:55 AM
0

Temur

--Temur--
2896
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 5/18/15, 12:47 PM


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.


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/18/15, 11:32 AM
Seen: 482 times
Last updated: 5/19/15, 5:04 AM