- Add mypy.ini configuration to exclude migration scripts - Rename migration files to proper snake_case (post-migration.py → post_migration.py) - Add __init__.py to migration directories for proper Python package structure - Add new portal access tests for website_sale_aplicoop - Code formatting improvements (black, isort) - Update copilot instructions and project configuration Related to previous code quality refactoring work.
34 lines
944 B
Python
34 lines
944 B
Python
# Copyright 2025 Criptomart
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
|
|
|
import logging
|
|
|
|
from odoo import SUPERUSER_ID
|
|
from odoo import api
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
def migrate(cr, version):
|
|
"""Migración para agregar soporte multicompañía.
|
|
|
|
- Asignar company_id a los registros existentes de group.order
|
|
- Usar la compañía por defecto del sistema
|
|
"""
|
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
|
|
|
# Obtener la compañía por defecto
|
|
default_company = env["res.company"].search([], limit=1)
|
|
|
|
if default_company:
|
|
# Actualizar todos los registros de group.order que no tengan company_id
|
|
cr.execute(
|
|
"""
|
|
UPDATE group_order
|
|
SET company_id = %s
|
|
WHERE company_id IS NULL
|
|
""",
|
|
(default_company.id,),
|
|
)
|
|
|
|
_logger.info("Asignado company_id=%d a group.order", default_company.id)
|