Comments (9)
I guess, image
column is restored after updating product
module, which leads to error.
@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:
cr.execute("select COUNT(*) from information_schema.columns where table_name='product_template' AND column_name='image';")
res = cr.dictfetchone()
if res.get('count'):
_logger.info('Starting conversion for product_template: saving data for further processing.')
# Rename image column so we don't lose images upon module install
cr.execute("ALTER TABLE product_template RENAME COLUMN image TO image_old")
cr.commit()
else:
_logger.info('No image field found in product_template; no data to save.')
from misc-addons.
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:
- The image column, if present, gets renamed to image_old. This happens in _auto_init, before the new fields are added.
- The module installs normally and updates its columns/fields.
- The image_old column, if present, is rewritten to the filestore. The field then gets overwritten with null in the DB to free up the space. This happens in _auto_end.
- Afterwards, still in _auto_end, the column image_old gets renamed to image_bkp so that subsequent upgrades of this module don't bother with trying to rewrite its contents to the filestore.
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:
- The first installation of product_image_filestore removes image, and replaces it with image_bkp.
- The -u all reinstates image, which gets renamed to image_old. But when image_old should get renamed to image_bkp, it fails because that column already exists. At that point, image has disappeared, image_old was added, and image_bkp is still there from the previous upgrade.
- All upgrades after this will encounter an image_old column, and fail to rename image. This is the error you pasted, but it's not the first error you encountered.
@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.
from misc-addons.
@jrial : "-u all" is for update and module should cope with that.
I think code that moves pictures from DB to filestore should be seperate and run with a wizard or from cron job and should convert just a limited number of images (to cope with timeout)
from misc-addons.
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.
from misc-addons.
@jrial thank you for explanation.
Currently, I am focused on 9.0 version, so your help are very welcome
from misc-addons.
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.
from misc-addons.
@aaltinisik I hope the issue is resolved for you
from misc-addons.
will test and report
from misc-addons.
@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.
from misc-addons.
Related Issues (20)
- [13.0] ir_attachment_s3: error in case when bucket is not created in AWS HOT 1
- [13.0] odoo_backup_sh: Error QWeb2: Template 'odoo_backup_sh.BackupDashboardMain' not found HOT 2
- Please open branch 14.0 HOT 1
- [11.0 ir_attachment_url: Maximum recursion depth exceeded HOT 2
- DINAR-PORT 13.0 ir_attachment_url HOT 4
- DINAR-PORT 13.0 ir_attachment_url HOT 2
- DINAR-PORT 14.0 ir_attachment_url HOT 1
- DINAR-PORT 14.0 ir_attachment_s3 HOT 2
- DINAR-PORT 13.0 res_partner_country_code HOT 2
- DINAR-PORT 13.0 attachment_large_object HOT 2
- DINAR-PORT 13.0 project_timelog HOT 1
- Issue in v12 HOT 3
- DINAR-PORT 12.0 web_multi_attachment_base HOT 1
- [13.0-14.0] odoo_backup_sh: get Access denied when list_db=False HOT 5
- DINAR-PORT 14.0 web_website HOT 1
- web_website: migrate changes from 12.0 to 13.0
- ir_attachment_s3: using with binary fields
- [REQUEST]odoo_backup_sh endpoint config
- Unable to upload binary and ir_attachment to s3
- attachment large object and ir attachment force storage version 10 very slow when reverting to filestore HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from misc-addons.