ERP: field code kategori & item_code produk (parent+child+id+name), migrasi existing data, update .gitignore untuk addons

This commit is contained in:
2026-09-07 15:45:17 +07:00
parent 3824b3b4b0
commit 83af01630c
13 changed files with 210 additions and 1 deletions

View 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}')