From 82a13b2ce5f7c2558627a655a3c9f289d405ce4a Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Tue, 12 May 2026 20:21:43 -0400 Subject: [PATCH] feat(nexa_coa_setup): pc_tech_support category + fix Entech invoice 1127 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- nexa_coa_setup/data/07_product_category.xml | 6 +++ nexa_coa_setup/scripts/fix_invoice_1127.py | 46 +++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 nexa_coa_setup/scripts/fix_invoice_1127.py diff --git a/nexa_coa_setup/data/07_product_category.xml b/nexa_coa_setup/data/07_product_category.xml index 902fd017..52c83105 100644 --- a/nexa_coa_setup/data/07_product_category.xml +++ b/nexa_coa_setup/data/07_product_category.xml @@ -60,6 +60,12 @@ + + Technical Support — Hourly + + + + Training diff --git a/nexa_coa_setup/scripts/fix_invoice_1127.py b/nexa_coa_setup/scripts/fix_invoice_1127.py new file mode 100644 index 00000000..f553db24 --- /dev/null +++ b/nexa_coa_setup/scripts/fix_invoice_1127.py @@ -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 <<<")