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

I have a custom module where user has to enter password(s) for external services. Password field is named password and shown in password field like this:

<field name="password" password="True"/>

The problem is Chrome autofill that always tries to fill the field with user password to the Odoo itself. And this happens always, when a form is opened to edit mode. Is there any mechanism to prevent browser autofill mechanism with fields?

Avatar
Discard
Best Answer

Hi,

IMHO, I think there is no direct clean way to prevent the browser to autofill password field.

Actually now the browsers ignoring the autocomplete="off" attribute. 

So I think the only workaround 'that I can come up with' is to add another fake password field; and just add it above your original password field. The browser will be confused when there is two password fields in the same block; so it will left them empty along with the name or email field .. 

I know we need to make the fake password some how invisible but actually the Odoo's invisible='1', will not achieve the desired result [it also equivalent to style="display:none"] the browser will still assume there is only one password. 

So I think we need to use style="visibility: hidden", but this one will make the label of the field still visible so you can make string = " " [space].

So your code will looks like:

<field name="fake_password" password="True" string = " " style="visibility: hidden"/>
<field name="password" password="True"/>


Still there may be another solution rather than this workaround ..


Hope this could helps ...

Avatar
Discard