This question has been flagged
1 Reply
7452 Views

I am getting an error in my server log that "wizard_id" violates "not null constraint" . When I look in more detail i see that this is related to the following bad query:

delete from portal_wizard where id IN (1,2,3,4,5)

Traceback (most recent call last): File"...openerp/server/openerp/sql)db.py", line 226, in execute res = self._obj.execute(query,params) IntegrityError: null value in column "wizard_id" violates not-null constraint CONTEXT: SQL statement "UPDATE ONLY "public"."portal_wizard_user" SET "wizard_id" = NULL WHRE $1 OPERATOR(pg_catalog.=) "wizard id"

Seems to be a Cron Related error, which is also causing OpenERP to possibly think I have too many users. Can I manually delete the few records I have in "portal_wizard_user" data table? How to rectify if not?

Avatar
Discard
Best Answer

This is actually a bug in the core portal module where ondelete='cascade' on the field wizard_id in the transient model portal.wizard.user is missing (one way to resolve) and throws an exception each time autovacuum tries to perform.

Until this is fixed you can actually add it directly in your_core_addons_path/portal/wizard/portal_wizard.py

or you make your own inherited wizard python file in your own module (so you do not have to touch the core) and redefine the related field.

You can find the code beneath (for the inheritance in your own module)...it is easier directly in the core...there you just need to add the ondelete to the field wizard_id (as you see it in the code below)

from osv import fields, orm

class portal_wizard(orm.TransientModel):
    _inherit = "portal.wizard.user"

    _columns = {
        'wizard_id': fields.many2one('portal.wizard', string='Wizard', required=True, ondelete='cascade'),
    }
Avatar
Discard
Author

Thank you Wolfgang. Do you see the bug bein repaired sometime. I very much am interested in making my own module, but not ready fo that just yet. I believe that you are saying to add the code you are posting here to the portal_wizard.py file. Will look at the file now and see if I can find the code or insertion point. Very much appreciate your post. This has been irritating me for some time.

Author

Well, I got an error telling me I needed to add a parent class: (I can't seem to paste the full error)... I tried to put the code near the beginning of the file just before similarly called: "from openerp.osv import fields, osv". Maybe I will make a Portal User again.. might fix it.

I have no idea what you have done, but revert it and just try to fix it in the core module by adding the ondelete="cascade" to the field wizard_id. You need to restart the server and upgrade the module portal after changing the code before it may take effect. I updated my answer to be more precise.

Author

I did revert, then got sidetracked long enough for your comment to come (and then some). Do I do this update in portal_wizard.py or do I need to do so somehow in the postgres database itself? I will assume in portal_wizard.py. I then assume the "upgrade" is in the settings for Module.. I get that part. Will try to report next

Author

In portal.wizard.py I found this line: _columns = { 'wizard_id': fields.many2one('portal.wizard', string='Wizard', required=True), (why no Carriage Returns in Comments here?) I will change to something like (??) : _columns = { 'wizard_id': fields.many2one('portal.wizard', string='Wizard', required=True,ondelete="cascade) (ondelete fixed, edited for parenthesis, rebooting now)

Author

Working so far. I have a few warnings re openerp.connector (magentoerpconnect) which seem unrelated. No Errors or Tracebacks through the whole reboot and upgrade cycle though. Thank you very much Wolfgang! Will do a full reboot now just to see that I can.

Great, nice to hear that you fixed it in your code and got it working. Please mark the answer as correct in order to help others too.