# -*- coding: utf-8 -*- # Copyright 2026 Nexa Systems Inc. # Backfill fp.box records for receivings that were counted BEFORE box-level # tracking shipped. Idempotent: skips any receiving that already has boxes. import logging _logger = logging.getLogger(__name__) def migrate(cr, version): from odoo import api, SUPERUSER_ID env = api.Environment(cr, SUPERUSER_ID, {}) recs = env['fp.receiving'].search([('box_count_in', '>', 0)]) done = 0 for rec in recs: if not rec.box_ids: rec._fp_sync_boxes() done += 1 _logger.info('fp.box backfill: created boxes for %s receiving(s)', done)