user1120753
user1120753

Reputation: 639

Hash a password that is entered in a xml form view

I have created an OpenERP model that needs to store a password.

In the view I add the password="True" attribute so the password is not visible.

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

But the value in the database is offcourse still a readable string.

What would be the openERP way to hash the value that I enter in the view so the hashed value is saved?

Can I use a function.field for this?

Upvotes: 3

Views: 555

Answers (1)

user1120753
user1120753

Reputation: 639

I can use the on_change event to change the value of the field:

<field name="password" password="True" on_change="password_change(password, context)"/>


def password_change(self, cr, uid, ids, password, context = None):
    return {'value': {'password':hash_password_value(password)},}

Upvotes: 3

Related Questions