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

How to resolve "Integrity Error" on change.password.user when deleting a user after changing his/her password?

By
Keng Onn
on 8/5/15, 9:41 AM 1,392 views

The steps to replicate this issue are as follows:

  1. Create a new user (from Odoo "Users" menu)

  2. Set the new user's password (which can be anything, apparently)

  3. Delete that new user.

The error I got was 

Integrity Error

The operation cannot be completed, probably due to the following:

- deletion: you may be trying to delete a record while other records still reference it

- creation/update: a mandatory field is not correctly set

[object with reference: Change Password Wizard User - change.password.user]

From what I Googled, it seems that the reason is because the "change.password.user" table (the actual database table name is "change_password_user") still contains a reference to the user I'm trying to delete. But why is that so? And how to fix this problem? Should I manually delete the entry in change.password.user table?

1
PY
On 8/5/15, 10:22 AM

You could make a fix module, with this python code:


class ResPartner(models.Model):
_inherit = 'res.partner'

@api.multi
def unlink(self):
for record in self:
self.env.cr.execute("DELETE FROM change_password_user WHERE user_id=%s;",
(record.id,))
record.unlink

don't forget to accept the answer if this suits your needs

PY
on 8/7/15, 9:41 AM

How this works?

Dev12
on 10/5/15, 8:57 PM

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: 8/5/15, 9:41 AM
Seen: 1392 times
Last updated: 8/14/15, 12:36 AM