-
-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
product_image_filestore: when updating module it throws error. #265
Comments
I guess, @jrial, as a author of that updates could assist on fixing this, please? Probably, we need to use alternative check before renaming the column. Current check is:
|
I no longer work with Odoo, but I'll give it a shot. First some explanation on how the product_image_filestore auto-upgrade works:
From this, I can already guess what went wrong: every time you upgrade everything, you reinstate the "image" column when the "product" module where it's defined gets updated. The timeline is as follows:
@yelizariev : The code fix: there is no reason to rename image_old to image_bkp if all went well during image conversion. After the for-loop, check if image_old contains data. If it does, rename to _bkp so the data doesn't get lost. But if it doesn't, simply drop image_old instead of renaming it. Needs to be done for both models. @aaltinisik : The fix for your database: check if there's anything in the image_bkp and image_old columns. If not, simply drop them. And word of advice: "-u all" is a recipe for disaster, although that doesn't excuse my code for breaking, of course. ;) I could create a pull request if you prefer me to do it, but it'll take a while as I'm currently rather busy. |
@jrial : "-u all" is for update and module should cope with that. |
I know; I'm just informing you it's a recipe for disaster. Worked with Odoo for 4 years, of which 3.5 at the company itself, and I can no longer count the number of development databases that went broken beyond repair due to weird interactions between modules when updating all. I'll fix my code because I don't want to contribute to the problem. But I'm advising you it's a better idea to update only the modules that have changed whenever possible. |
@jrial thank you for explanation. |
Here you go. Tested on a fresh DB by repeatedly restarting with -u all. Verified that it preserves the state of the images that were altered/dropped before installing the module. When the upgrade fails, the old columns are preserved with the _bkp suffix in order to preserve the unconverted data. When the upgrade succeeds, these old image columns are simply discarded and won't get in the way during subsequent updates of the product module. |
@aaltinisik I hope the issue is resolved for you |
will test and report |
@aaltinisik : if you still have lingering _old and _bkp fields in your DB, make sure they're empty and toss them out before testing. The fix will prevent similar issues from cropping up in the future, but it won't fix your current DB. In fact, I should probably add another check in the __auto_begin method to see if there's a _bkp column, and abort the upgrade in such a case. @yelizariev : I'll probably do another PR soon adding this check as well. |
Hello,
Great module, my DB dump size changed from 1.2 GB to 340MB.
After module install if we do a database update with
odoo.py -u all ...
following error happens
File "/opt/odoo/custom/addons/product_image_filestore/product_image_filestore_models.py", line 20, in _auto_init
cr.execute("ALTER TABLE product_template RENAME COLUMN image TO image_old")
File "/opt/odoo/odoo-server/openerp/sql_db.py", line 158, in wrapper
return f(self, _args, *_kwargs)
File "/opt/odoo/odoo-server/openerp/sql_db.py", line 234, in execute
res = self._obj.execute(query, params)
ProgrammingError: column "image_old" of relation "product_template" already exists
The text was updated successfully, but these errors were encountered: