Skip to content
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

[IMP] openupgrade_160, openupgrade_tools: BS4 to BS5 transformation yeahhhhh #338

Conversation

duong77476-viindoo
Copy link
Contributor

BS4 to BS5 transformation yeahhhhh


# These replacements are from standard Bootstrap 4 to 5
_BS5_REPLACEMENTS = (
# Grid stuff
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment i use here following the same order in https://getbootstrap.com/docs/5.1/migration

@duong77476-viindoo duong77476-viindoo force-pushed the master_imp_boostrap4_to_5_transformation branch 3 times, most recently from 33f9e1e to aa7482f Compare July 11, 2023 07:27
@pedrobaeza
Copy link
Member

Yeahhhhh!

@duong77476-viindoo
Copy link
Contributor Author

I have tested with PR OCA/OpenUpgrade#3949 , seem work fine, not sure i miss any thing or not :v

@duong77476-viindoo duong77476-viindoo force-pushed the master_imp_boostrap4_to_5_transformation branch 3 times, most recently from af4e05a to 3346708 Compare July 11, 2023 11:31
@@ -104,6 +104,7 @@ def convert_xml_node(
style_rm=frozenset(),
tag="",
wrap="",
attr_rp=None,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here i added anaother option to allow attribute replacement, put it in the last to avoid error

Comment on lines +262 to +267
def replace_html_replacement_attr_shortcut(attr_rp="", **kwargs):
"""Shortcut to replace an attribute spec.

:param dict attr_rp:
EX: {'data-toggle': 'data-bs-toggle'}
Where the 'key' is the attribute will be replaced by the 'value'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also define a shortcut for it

@duong77476-viindoo duong77476-viindoo force-pushed the master_imp_boostrap4_to_5_transformation branch from 3346708 to 011d131 Compare July 21, 2023 06:33
@duong77476-viindoo duong77476-viindoo force-pushed the master_imp_boostrap4_to_5_transformation branch from 011d131 to 529ba55 Compare August 8, 2023 05:01
@duong77476-viindoo duong77476-viindoo force-pushed the master_imp_boostrap4_to_5_transformation branch 3 times, most recently from 734ec28 to a1759d0 Compare August 25, 2023 07:52
@duong77476-viindoo duong77476-viindoo force-pushed the master_imp_boostrap4_to_5_transformation branch 7 times, most recently from 41799ce to 5269546 Compare August 26, 2023 03:39
Copy link
Member

@chienandalu chienandalu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in local running the scripts manually to validate qweb views 👍

Thanks!

@duong77476-viindoo
Copy link
Contributor Author

Tested in local running the scripts manually to validate qweb views 👍

Thanks!

Thank you, although i think i might lack some cases, anyway it fine by me as i have already tested on a production database

@pedrobaeza pedrobaeza merged commit 9b7dc0c into OCA:master Oct 30, 2023
3 checks passed
AsIs(field),
new_content,
id_,
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a bug in the cr.execute() call, assuming syntax is cr.execute(query, params)?
I got the below error during migration which lead me here.

2023-11-11 15:54:29,149 58099 CRITICAL test odoo.service.server: Failed to initialize database `test`.
Traceback (most recent call last):
  File "/Users/lijo/work/odoo16/odoo/service/server.py", line 1299, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "<decorator-gen-16>", line 2, in new
  File "/Users/lijo/work/odoo16/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/Users/lijo/work/odoo16/odoo/modules/registry.py", line 90, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/Users/lijo/work/odoo16/odoo/modules/loading.py", line 523, in load_modules
    migrations.migrate_module(package, 'end')
  File "/Users/lijo/work/oca/OpenUpgrade/openupgrade_framework/odoo_patch/odoo/modules/migration.py", line 18, in migrate_module
    MigrationManager.migrate_module._original_method(self, pkg, stage)
  File "/Users/lijo/work/odoo16/odoo/modules/migration.py", line 189, in migrate_module
    migrate(self.cr, installed_version)
  File "/Users/lijo/miniforge3/envs/odoo16/lib/python3.8/site-packages/openupgradelib/openupgrade.py", line 2277, in wrapped_function
    func(
  File "/Users/lijo/work/oca/OpenUpgrade/openupgrade_scripts/scripts/website/16.0.1.0/end-migration.py", line 81, in migrate
    convert_custom_qweb_templates_bootstrap_4to5(env)
  File "/Users/lijo/work/oca/OpenUpgrade/openupgrade_scripts/scripts/website/16.0.1.0/end-migration.py", line 26, in convert_custom_qweb_templates_bootstrap_4to5
    _convert_field_bootstrap_4to5_sql(env.cr, "ir_ui_view", "arch_db", ids=view_ids)
  File "/Users/lijo/miniforge3/envs/odoo16/lib/python3.8/site-packages/openupgradelib/openupgrade_160.py", line 397, in _convert_field_bootstrap_4to5_sql
    cr.execute(
TypeError: execute() takes from 2 to 4 positional arguments but 6 were given

Changing the execute call as below seems to fix it

cr.execute(
                "UPDATE %s SET %s = %s WHERE id = %s",
                (AsIs(table), AsIs(field), new_content, id_),
            )

Is my understanding wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants