Home > front end >  Odoo 15 Inherit "product.product" get issue bad query: ALTER TABLE "product_product&q
Odoo 15 Inherit "product.product" get issue bad query: ALTER TABLE "product_product&q

Time:03-14

[RESOLVED - FOUNDED THE TRUE ISSUE]

I'm trying to inherit model "product.product", but with my first move, i got the issue, here's my code:

from odoo import models, fields

class ProductProduct(models.Model):
    _inherit = "product.product"

The issue:

bad query: ALTER TABLE "product_product" ALTER COLUMN "base_unit_count" DROP NOT NULL

canceling statement due to statement timeout

Any idea? Thanks.

EDIT 1: After a day without doing anything, and now it working just fine. I don't know why.

EDIT 2: After few hours, the issue is back when i'm trying to inherit model "product.product" one again, and this time i've tried to uninstall and reinstall my custom module, and the issue is gone again, everything is seem normal now.

How i uninstall and reinstall the module?
=> Run this command in postgresql (this command is to prevent the canceling statement due to statement timeout issue above):

set statement_timeout = '60 s'; -- 60 seconds

Then, remove the -u module_name in configuration in pycharm so it won't upgrade module automatically when you restart the server. enter image description here

Then, run the server and uninstall and reinstall the module manually.

I've fixed this issue by above WORK AROUND, but this is not the correct method to resolve this problem, so if anyone know anything about this issue, welcome.

CodePudding user response:

I've found the true issue here, but it's not related anything with "product.product". Turn out, it's because of my copied code from other modules which causing this issue.
The original copied code are:

status = fields.Integer(string='Status', size=4)

But in odoo 15, it should not have size, so it look like this:

status = fields.Integer(string='Status')

I thing that this code is causing the issue so that "product.product" code can't run normally.

Some time, it could be pycharm conflict issue, you can solved this problem easily by close and open the pycharm again and run server.

  • Related