ERP: field code kategori & item_code produk (parent+child+id+name), migrasi existing data, update .gitignore untuk addons
This commit is contained in:
19
scripts/migrate_item_code.py
Normal file
19
scripts/migrate_item_code.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import re
|
||||
|
||||
# Migration: isi code kategori & item_code produk untuk data existing
|
||||
cats = env['product.category'].search([])
|
||||
for c in cats:
|
||||
if not c.code:
|
||||
c.code = f'{c.id:02d}'
|
||||
env.cr.commit()
|
||||
print(f'Kategori di-update: {len(cats)}')
|
||||
|
||||
prods = env['product.template'].search([])
|
||||
for p in prods:
|
||||
p._generate_item_code()
|
||||
env.cr.commit()
|
||||
print(f'Produk di-update: {len(prods)}')
|
||||
|
||||
# Verifikasi contoh
|
||||
for p in prods[:5]:
|
||||
print(f' {p.name!r} -> {p.item_code!r}')
|
||||
Reference in New Issue
Block a user