Skip to Content
Menu
This question has been flagged
1 Reply
2401 Views

I added a fields.Selection 'company_origin' with 3 keys in the signup form ('/web/signup'), the value is correctly store on backend. 

When user go to user profile '/my/account' I want to set 'country_id' readonly if 'company_origin' has key1 OR key2.

When i write the following code I see the field shown as if it's readonly (color changes), but it will not actually be readonly. 

What do I miss to make this work on qweb? Or, if it has to be done in javascript, could you please provide some advice on how to do it ? (how to check selection fields values or keys on js framework?) - Edit: Forgot to say, im working on Odoo14

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="portal_data_extend" inherit_id="portal.portal_my_details"
name="Profile data extend">
<xpath expr="//form//select[@name='country_id']" position="attributes">
<attribute name="readonly">'readonly' if (partner.company_origin == 'key1' or partner.company_origin == 'key2') else None</attribute>
</xpath>
</template>
</odoo>

Avatar
Discard
Author Best Answer

I just realized this problem is not Odoo related, it's about select html elements which don't use readonly, but 'disabled'. I used the following and it correctly make the selection field readonly. 

<attribute name="t-att-disabled">'disabled' if (partner.company_origin == 'key1' or partner.company_origin == 'key2') else None</attribute>


Avatar
Discard
Related Posts Replies Views Activity
1
Oct 24
244
1
Aug 22
5316
9
Jul 21
60620
0
Jul 20
2137
8
Nov 19
6235