diff --git a/src/l10n_do_banks/17.0.1.0.0/pre-fix-oca-stock-analytic-view.py b/src/l10n_do_banks/17.0.1.0.0/pre-fix-oca-stock-analytic-view.py new file mode 100644 index 000000000..8353c5dd6 --- /dev/null +++ b/src/l10n_do_banks/17.0.1.0.0/pre-fix-oca-stock-analytic-view.py @@ -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) diff --git a/src/l10n_do_banks/17.0.1.0.0/pre-modules-uninstall.py b/src/l10n_do_banks/17.0.1.0.0/pre-modules-uninstall.py index 4ab2d8cc2..be78fde09 100644 --- a/src/l10n_do_banks/17.0.1.0.0/pre-modules-uninstall.py +++ b/src/l10n_do_banks/17.0.1.0.0/pre-modules-uninstall.py @@ -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 @@ -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}, ' diff --git a/src/l10n_do_banks/17.0.1.0.0/pre-view-delete.py b/src/l10n_do_banks/17.0.1.0.0/pre-view-delete.py index 01bedfc36..69886dbb8 100644 --- a/src/l10n_do_banks/17.0.1.0.0/pre-view-delete.py +++ b/src/l10n_do_banks/17.0.1.0.0/pre-view-delete.py @@ -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 @@ -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', @@ -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: @@ -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}')