[go: up one dir, main page]

0% found this document useful (0 votes)
20 views3 pages

Odooupgradelib_HowTo_StackOverflow

The document discusses the possibility of upgrading an Odoo.sh staging database while managing compatibility issues with custom modules. It suggests using the Odoo.sh upgrade service and addressing issues step-by-step through logs, utilizing the OpenUpgrade library for necessary adaptations. The author provides guidance on how to implement fixes using migration scripts and offers links to relevant resources for further assistance.

Uploaded by

syb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

Odooupgradelib_HowTo_StackOverflow

The document discusses the possibility of upgrading an Odoo.sh staging database while managing compatibility issues with custom modules. It suggests using the Odoo.sh upgrade service and addressing issues step-by-step through logs, utilizing the OpenUpgrade library for necessary adaptations. The author provides guidance on how to implement fixes using migration scripts and offers links to relevant resources for further assistance.

Uploaded by

syb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Is it possible to upgrade Odoo.

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

Odoo.sh upgrade service details

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?

The compatibility problems are related to deprecated models and such.

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

odoo upgrade odoo-14 odoo-16 odoo.sh

Share Edit Follow Flag asked 1 hour ago


SallySalty
1

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 install it in your project, append openupgradelib in your requirements.txt file and


then run a bash command:

pip3 install -r requirements.txt

Documentation on this library: https://oca.github.io/openupgradelib/installation.html

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

from openupgradelib import openupgrade

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

You might also like