处理#6973任务:
1货位编码规则简化 2货位看板直观化展示
This commit is contained in:
15
sf_warehouse/migrations/1.2/post-migrate.py
Normal file
15
sf_warehouse/migrations/1.2/post-migrate.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
def migrate(cr, version):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
sf_shelf_model = env["sf.shelf"]
|
||||
sf_shelf_location_model = env["sf.shelf.location"]
|
||||
shelves = sf_shelf_model.search([])
|
||||
for shelf in shelves:
|
||||
shelf_barcode = shelf.barcode or ""
|
||||
if not shelf_barcode:
|
||||
continue
|
||||
locations = sf_shelf_location_model.search([("shelf_id", "=", shelf.id)], order="id asc")
|
||||
for index, location in enumerate(locations, start=1):
|
||||
new_barcode = f"{shelf_barcode}-{index:03d}"
|
||||
location.barcode = new_barcode
|
||||
Reference in New Issue
Block a user