From 5ef8023169a88a83fa1ac5db3cb35118cb9b3adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Mon, 16 Jun 2025 13:41:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9migrate=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E6=9B=B4=E6=96=B0=E6=85=A2=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_warehouse/migrations/1.2/post-migrate.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sf_warehouse/migrations/1.2/post-migrate.py b/sf_warehouse/migrations/1.2/post-migrate.py index f4a0d9a4..b681f796 100644 --- a/sf_warehouse/migrations/1.2/post-migrate.py +++ b/sf_warehouse/migrations/1.2/post-migrate.py @@ -1,5 +1,8 @@ +import logging from odoo import api, SUPERUSER_ID +_logger = logging.getLogger(__name__) + def migrate(cr, version): env = api.Environment(cr, SUPERUSER_ID, {}) sf_shelf_model = env["sf.shelf"] @@ -9,7 +12,10 @@ def migrate(cr, version): shelf_barcode = shelf.barcode or "" if not shelf_barcode: continue - locations = sf_shelf_location_model.search([("shelf_id", "=", shelf.id)], order="id asc") + # locations = sf_shelf_location_model.search([("shelf_id", "=", shelf.id)], order="id asc") + locations = shelf.location_ids.sorted('id') for index, location in enumerate(locations, start=1): new_barcode = f"{shelf_barcode}-{index:03d}" - location.barcode = new_barcode \ No newline at end of file + location.barcode = new_barcode + cr.commit() + _logger.info('货架【%s】的%d个货位被更新' % (shelf.name, len(locations))) \ No newline at end of file