vbt
vbt

Reputation: 805

How to set readonly filed for a particular field which lies in a One2Many field

I want to set a field readonly based on a selection field. But the problem is that,the field lies under a One2Many field.So when I put readonly for that particular field,this error comes

Error

 Uncaught Error: QWeb2 - template['ListView.rows']: Runtime Error: Error: QWeb2 - template['ListView.row']: Runtime Error: Error: Unknown field od_confirm_state_line in domain [["od_confirm_state_line","=","confirmed"]]

Code

<page String="Landed Cost">
    <field name="cost_line">
    <tree editable="top">
       <field name="od_partner_id"/>
       <field name="od_product_id"/>
       <field name="od_label" attrs="{'readonly':[('od_confirm_state_line','=','confirmed')]}"/> 
    </tree>
    </field>
</page>

Here I want to make the field od_label readonly.

Upvotes: 3

Views: 1311

Answers (2)

Kenly
Kenly

Reputation: 26758

The fields used in domain must be defined in your view:

<tree editable="top">
   <field name="od_partner_id"/>
   <field name="od_product_id"/>
   <!-- Add od_confirm_state_line like the following-->
   <field name="od_confirm_state_line"/>
   <field name="od_label" attrs="{'readonly':[('od_confirm_state_line','=','confirmed')]}"/> 
</tree>

Upvotes: 1

Charif DZ
Charif DZ

Reputation: 14751

you cannot use a fields in attrs that don't exist in the view defination so if od_confirm_state_line is not on the view you will get the same erro.

because attrs is execute only on the client side so you need to provide all fields in the view

Upvotes: 1

Related Questions