diff --git a/website_sale_extra_fields/__init__.py b/website_sale_extra_fields/__init__.py index 0650744f6..6d58305f5 100644 --- a/website_sale_extra_fields/__init__.py +++ b/website_sale_extra_fields/__init__.py @@ -1 +1,2 @@ from . import models +from .hooks import pre_init_hook diff --git a/website_sale_extra_fields/__manifest__.py b/website_sale_extra_fields/__manifest__.py index 630a1358d..2ec2efca3 100644 --- a/website_sale_extra_fields/__manifest__.py +++ b/website_sale_extra_fields/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Website Sale Extra Fields", - "version": "14.0.0.1.0", + "version": "14.0.0.1.1", "author": "NuoBiT Solutions, S.L.", "license": "AGPL-3", "category": "Website", @@ -16,4 +16,5 @@ "views/product_template.xml", "views/product_product.xml", ], + "pre_init_hook": "pre_init_hook", } diff --git a/website_sale_extra_fields/hooks.py b/website_sale_extra_fields/hooks.py new file mode 100644 index 000000000..cfe07a521 --- /dev/null +++ b/website_sale_extra_fields/hooks.py @@ -0,0 +1,20 @@ +# Copyright NuoBiT Solutions - Eric Antones +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) + +import logging + +_logger = logging.getLogger(__name__) + + +def pre_init_hook(cr): + _logger.info( + "Pre-creating slug_name column on product_public_category" + " to avoid NOT NULL constraint failure" + ) + cr.execute( + "ALTER TABLE product_public_category" + " ADD COLUMN IF NOT EXISTS slug_name varchar" + ) + cr.execute( + "UPDATE product_public_category SET slug_name = '/' WHERE slug_name IS NULL" + )