update upgrade scripts and make file upgrade_module command
All checks were successful
Setup Native Action / native (3.12.7) (push) Has been skipped
Setup Native Action / docker (3.12.7) (push) Has been skipped

This commit is contained in:
KaySar12 2025-04-14 10:37:15 +07:00
parent 6c7d00e7d4
commit 716af73a0c
7 changed files with 43 additions and 13 deletions

View File

@ -34,6 +34,7 @@ VERSION := community
ADDONS=${PWD}/addons,${PWD}/odoo/addons,${PWD}/extra-addons
BACKUP=${CDN}/raw/branch/main/backup/${VERSION}/odoo18-main_2025-01-15_08-05-47.zip
AUTOMATION_PATH=${PWD}/automation
UPGRADE_SCRIPTS=$(shell cat upgrade_scripts | tr '\n' ',')
##### Virtual Environment #####
check-virtualenv:
@if [ "$(VENV)" = "missing" ]; then \
@ -69,7 +70,10 @@ scaffold_module:
install_modules:
${PYTHON} odoo-bin --config=${CONFIG} -d ${DATABASE} -i ${MODULES} --xmlrpc-port=${PORT}
upgrade_modules:
${PYTHON} odoo-bin upgrade_code --script ${SCRIPTS} --addons-path=${UPGRADE_DIR} || true
@for script in $$(cat upgrade_scripts); do \
echo "Running upgrade script: $$script"; \
${PYTHON} odoo-bin upgrade_code --script $$script --addons-path=${UPGRADE_DIR} || true; \
done
delete_records:
${PYTHON} ${SCRIPT_PATH}/delete_records.py ${DATABASE} ${BASE_MODEL} --force
drop_database:

@ -1 +1 @@
Subproject commit 1c5e4323ebe5831ab45cca8d2a82602453d0f43c
Subproject commit 026d565b5e97acf731a94851f04e522f893b7a9d

0
odoo/upgrade_code/17.5-01-tree-to-list.py Normal file → Executable file
View File

View File

@ -85,13 +85,22 @@ def upgrade(file_manager):
def get_new_attrs(attrs):
try:
# Use ast.literal_eval for safe evaluation of Python literals
# First check if this looks like a JavaScript expression
if any(js_indicator in attrs for js_indicator in ['=>', '?', ':', 'function', 'this.', 'get', 'set']):
# This is a JavaScript expression, preserve it as-is
return {'attrs': attrs.strip()}
# Try parsing as Python literal
attrs_dict = literal_eval(attrs.strip())
if not isinstance(attrs_dict, dict):
logger.warning(f"Invalid attrs format, expected dict, got {attrs_dict}")
return {}
return {attr: stringify_attr(attrs_dict[attr]) for attr in NEW_ATTRS if attr in attrs_dict}
except (ValueError, SyntaxError) as e:
# If parsing fails, check if it's a simple JavaScript object
if attrs.strip().startswith('{') and attrs.strip().endswith('}'):
# Preserve simple JavaScript object as-is
return {'attrs': attrs.strip()}
logger.error(f"Failed to parse attrs '{attrs}': {e}")
return {}
except Exception as e:
@ -123,9 +132,14 @@ def upgrade(file_manager):
for tag in tags_with_attrs:
new_attrs = get_new_attrs(tag['attrs'])
if new_attrs: # Only proceed if parsing succeeded
del tag['attrs']
for attr, value in new_attrs.items():
tag[attr] = value
if 'attrs' in new_attrs:
# This is a JavaScript expression, preserve it
tag['attrs'] = new_attrs['attrs']
else:
# This is a Python literal that was parsed
del tag['attrs']
for attr, value in new_attrs.items():
tag[attr] = value
else:
logger.warning(f"Skipping tag in {file.path} due to invalid attrs: {tag.get('attrs')}")
@ -133,11 +147,16 @@ def upgrade(file_manager):
for attr_tag in attr_tags:
new_attrs = get_new_attrs(attr_tag.text)
if new_attrs:
for attr, value in new_attrs.items():
new_tag = soup.new_tag('attribute', name=attr)
new_tag.string = value
attr_tag.insert_after(new_tag)
attr_tag.decompose()
if 'attrs' in new_attrs:
# This is a JavaScript expression, preserve it
attr_tag.string = new_attrs['attrs']
else:
# This is a Python literal that was parsed
for attr, value in new_attrs.items():
new_tag = soup.new_tag('attribute', name=attr)
new_tag.string = value
attr_tag.insert_after(new_tag)
attr_tag.decompose()
else:
logger.warning(f"Skipping attribute tag in {file.path} due to invalid attrs: {attr_tag.text}")

View File

@ -6,4 +6,6 @@ odoo/*
requirements.txt
Dockerfile
automation
*.yaml
*.yaml
FTACPA
FTACPA/*

5
upgrade_scripts Normal file
View File

@ -0,0 +1,5 @@
17.5-01-tree-to-list
17.5-02-replace-attrs
17.5-03-replace-chatter
17.5-04-ir-cron
17.5-05-jsonrpc-to-rpc

@ -1 +1 @@
Subproject commit e541836cfc777b5cfddd876b5df89bdce0d07562
Subproject commit 97bd3a1c88679d2c6d390f6f2f33cc6ecc57dfed