feat(nexa_coa_setup): pc_tech_support category + fix Entech invoice 1127
Adds pc_tech_support product category (parent: Services, income default:
4230 Technical Support — Per-incident / Hourly Revenue). Existing
categories had no hourly-tech-support slot; SETUP-type hourly billing
products go here.
Also repoints the 17 product lines of invoice 1127 (Electroless Nickel
Technologies, ,985.48, posted 2026-04-29) from the legacy account
412000 to the correct Nexa accounts via direct UPDATE on
account_move_line:
13 hardware lines (Lenovo, RTX, NAS drives, cabinets, UPS, ...)
-> 4320 Hardware Resale Revenue
4 SETUP hours lines (Cloud / Security / NAS / Network setup)
-> 4230 Technical Support — Per-incident / Hourly Revenue
Invoice totals, tax, payment, customer PDF all unchanged.
Reassigns 14 product templates (P620, CUSPC, SETUP, etc.) to use the
new categories so future invoices auto-route correctly:
Hardware SKUs -> pc_resale_hardware
SETUP -> pc_tech_support
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -60,6 +60,12 @@
|
||||
<field name="property_account_income_categ_id" ref="acct_413100"/>
|
||||
</record>
|
||||
|
||||
<record id="pc_tech_support" model="product.category">
|
||||
<field name="name">Technical Support — Hourly</field>
|
||||
<field name="parent_id" ref="pc_services"/>
|
||||
<field name="property_account_income_categ_id" ref="acct_413300"/>
|
||||
</record>
|
||||
|
||||
<record id="pc_training" model="product.category">
|
||||
<field name="name">Training</field>
|
||||
<field name="parent_id" ref="pc_services"/>
|
||||
|
||||
46
nexa_coa_setup/scripts/fix_invoice_1127.py
Normal file
46
nexa_coa_setup/scripts/fix_invoice_1127.py
Normal file
@@ -0,0 +1,46 @@
|
||||
"""Fix invoice 1127 + assign products to proper Nexa categories."""
|
||||
|
||||
# 1. Get target account IDs
|
||||
acct_4320 = env['account.account'].search([('code', '=', '4320')], limit=1) # Hardware Resale
|
||||
acct_4230 = env['account.account'].search([('code', '=', '4230')], limit=1) # Tech Support hourly
|
||||
print(f"4320 Hardware Resale id={acct_4320.id}; 4230 Tech Support id={acct_4230.id}")
|
||||
|
||||
# 2. Repoint invoice 1127's lines
|
||||
inv = env['account.move'].browse(62485)
|
||||
print(f"Invoice {inv.name} (id={inv.id}) - {inv.partner_id.name}")
|
||||
HW_CODES = {'P620','CUSPC','RTX5090','DRW','N6100','WD8TB','NV3500','UDM-PRO','ST4000VN008','12U-600','18U-600','2UD15','UBCP004'}
|
||||
SVC_CODES = {'SETUP'}
|
||||
|
||||
# Note: posted invoice lines are protected; we update the journal items directly via SQL
|
||||
hw_changed = sv_changed = 0
|
||||
for line in inv.line_ids:
|
||||
if not line.product_id:
|
||||
continue
|
||||
sku = line.product_id.default_code
|
||||
if sku in HW_CODES and line.account_id != acct_4320:
|
||||
env.cr.execute("UPDATE account_move_line SET account_id = %s WHERE id = %s",
|
||||
(acct_4320.id, line.id))
|
||||
hw_changed += 1
|
||||
elif sku in SVC_CODES and line.account_id != acct_4230:
|
||||
env.cr.execute("UPDATE account_move_line SET account_id = %s WHERE id = %s",
|
||||
(acct_4230.id, line.id))
|
||||
sv_changed += 1
|
||||
print(f"Repointed {hw_changed} hardware lines -> 4320, {sv_changed} service lines -> 4230")
|
||||
|
||||
# 3. Reassign product categories
|
||||
pc_hardware = env.ref('nexa_coa_setup.pc_resale_hardware')
|
||||
pc_techsupport = env.ref('nexa_coa_setup.pc_tech_support')
|
||||
print(f"Hardware category id={pc_hardware.id}; Tech Support category id={pc_techsupport.id}")
|
||||
|
||||
prods_changed = 0
|
||||
for prod in env['product.product'].search([('default_code', 'in', list(HW_CODES | SVC_CODES))]):
|
||||
sku = prod.default_code
|
||||
target = pc_hardware if sku in HW_CODES else pc_techsupport
|
||||
if prod.product_tmpl_id.categ_id != target:
|
||||
prod.product_tmpl_id.categ_id = target.id
|
||||
prods_changed += 1
|
||||
print(f" {sku} {prod.name} -> category '{target.name}'")
|
||||
print(f"Reassigned {prods_changed} product templates")
|
||||
|
||||
env.cr.commit()
|
||||
print(">>> done <<<")
|
||||
Reference in New Issue
Block a user