Odooupgradelib_HowTo_StackOverflow
Odooupgradelib_HowTo_StackOverflow
sh from a staging
database?
Asked today Modified today Viewed 15 times
Does anyone know if it is possible to upgrade an odoo.sh staging database through the
upload form from here? https://upgrade.odoo.com/#odoosh
0
The Odoo.sh upgrade service says that the DB used to upgrade comes from the latest
production daily automatic backup, and in every commit in the process it is restored
from the same backup
The problem is that my team production branch has custom modules that present
compatibility issues with the new version (from Odoo 14 to Odoo 16), but we can't
delete them from production, cause they are working and are needed for now, so we
want to delete the modules from the staging, upgrade it and solve the compatibility
problems each module at a time... is that possible? Or is there a better way to solve this
problem?
I have tried uninstalling and deleting the modules from the staging branch, but the
production database still have them as "installed" in every upgrade try so the upgrade
fails everytime
New contributor
Sorted by:
1 Answer Reset to default
Date modified (newest first)
After having tried many alternatives, i can tell you that the best way is to use the
Upgrade inside Odoo.sh. And during this process, you can get the issue from the
0 Upgrade log and correct your custom modules accordingly step by step:
log-issue-1 -> fix-1 -> git push-> log-issue-2 -> fix-2 -> git push ...etc...
To fix the issues reported in the log, you can use migrations/pre-migrate.py , post-
migrate.py, end-migrate.py files to adapt accordingly: models and views of your custom
models, using the OpenUpgrade library: https://pypi.org/project/openupgradelib/
To learn how to use openupgradelib's functions, you can find good use-case examples
here (open-upgrade): https://github.com/OCA/OpenUpgrade/blob/15.0
/openupgrade_scripts/scripts/website_sale/15.0.1.1/post-migration.py
def update_xpath_for_product_custom_text(env):
"""Look for custom views website_sale.product_custom_text and update the
content hook"""
for view in env["ir.ui.view"].search(
[
("key", "=", "website_sale.product_custom_text"),
("website_id", "!=", False),
]
):
view.arch_db = view.arch_db.replace(
"expr=\"//div[@id='product_details']\"",
"expr=\"//div[@id='o_product_terms_and_share']\"",
)
def set_visibility_product_attribute(env):
# Check that website_sale_product_attribute_filter_visibility was installed
if not openupgrade.column_exists(env.cr, "product_attribute",
"is_published"):
return
openupgrade.logged_query(
env.cr,
"""
UPDATE product_attribute
SET visibility = CASE WHEN is_published is not true THEN 'hidden'
ELSE 'visible'
END
""",
)
def enable_price_filter_view(env):
"""If you had website_sale_attribute_filter_price module installed in
previous
version, replace it by the new core price filter.
"""
for website in env["website"].search([]):
view = env["ir.ui.view"].search(
[
("key", "=",
"website_sale_attribute_filter_price.pricefilter"),
("website_id", "=", website.id),
]
)
if view:
# It's important to set the context to create the new view related
to the
# current website. See write method of ir.ui.view in website module
website.with_context(website_id=website.id).viewref(
"website_sale.filter_products_price"
).active = True
view.unlink()
@openupgrade.migrate()
def migrate(env, version):
# Load noupdate changes
openupgrade.load_data(
env.cr,
"website_sale",
"15.0.1.1/noupdate_changes.xml",
)
openupgrade.delete_record_translations(
env.cr,
"website_sale",
[
"mail_template_sale_cart_recovery",
],
)
set_visibility_product_attribute(env)
enable_price_filter_view(env)
update_xpath_for_product_custom_text(env)
Share Edit Delete Flag edited 7 mins ago answered 28 mins ago
sylvain
865 1 7 20