Skip to content
38 changes: 38 additions & 0 deletions src/l10n_do_banks/17.0.1.0.0/pre-fix-oca-stock-analytic-view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import logging

from odoo.addons.base.maintenance.migrations import util

_logger = logging.getLogger(__name__)


def _update_views(cr):
cr.execute(
"""
UPDATE ir_ui_view
SET arch_db = replace(
replace(
arch_db::text,
'analytic_account_id',
'analytic_distribution'
),
'analytic_tag_ids',
'analytic_distribution'
)::jsonb
WHERE model = 'stock.picking'
AND (
arch_db::text ILIKE '%%analytic_account_id%%'
OR arch_db::text ILIKE '%%analytic_tag_ids%%'
)
"""
)
_logger.info("Updated %s stock.picking views.", cr.rowcount)


def migrate(cr, version):
del version

if not util.module_installed(cr, "stock_analytic"):
_logger.info("stock_analytic not installed; skipping view fix.")
return

_update_views(cr)
5 changes: 3 additions & 2 deletions src/l10n_do_banks/17.0.1.0.0/pre-modules-uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,11 @@ def uninstall_modules(cr):
'stock_inventory_chatter',
'cecomsa_account_followup',
'odoo_document_invoice_report',
'purchase_discount'
]

_logger.info(f'Starting uninstall process for {len(modules_to_uninstall)} modules.')

uninstalled_count = 0
not_installed_count = 0
failed_count = 0
Expand All @@ -172,7 +173,7 @@ def uninstall_modules(cr):
f'Failed to uninstall module {module_name}: {str(e)}',
exc_info=True
)

_logger.info(
f'Uninstall process completed. '
f'Uninstalled: {uninstalled_count}, '
Expand Down
9 changes: 5 additions & 4 deletions src/l10n_do_banks/17.0.1.0.0/pre-view-delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def migrate(cr, version):
"""
Pre-migration script to delete specific views before upgrade.

Args:
cr (cursor): Database cursor
version (str): Module version
Expand All @@ -18,7 +18,7 @@ def migrate(cr, version):
'bi_warranty_registration.warranty_details_form_view'
'bi_warranty_registration.warranty_case_claims_form_view1',
'product_product_price_widget.product_product_tree_view_inherit_widget',
'sale_stock_product_price_widget.sale_price_widgets_view',
'sale_stock_product_price_widget.sale_price_widgets_view',
'sale_stock_qty_date_widgets.sale_stock_qty_date_widgets_view',
'product_stock_qty_date_widget.product_product_tree_view_inherit_widget_qty',
'warranty_registration_extra_features.warranty_case_claims_form_view1_inherit',
Expand All @@ -30,6 +30,7 @@ def migrate(cr, version):
'professional_templates.view_sale_order_inherit_customized',
'professional_templates.view_rfq_inherit_customized',
'professional_templates.purchase_order_inherited_customized',
'stock_analytic.view_picking_form',
]

for xml_id in views_to_delete:
Expand All @@ -47,12 +48,12 @@ def migrate(cr, version):
inherited.unlink()
except Exception as e:
_logger.warning(f'Error deleting inherited view: {e}')

# Check if this view inherits from another
if view.inherit_id:
_logger.info(f'View {xml_id} inherits from {view.inherit_id.xml_id}')
view.inherit_id = False

# Now delete the view itself
view.unlink()
_logger.info(f'Successfully deleted view: {xml_id}')
Expand Down