Skip to content

Credit Note Allocation Wizard Documentation

Overview

The Credit Note Allocation Wizard model (account.alloc.wizard) provides an interface for allocating credit notes against outstanding invoices or payments. It finds available debit entries for the same contact and creates allocation journal entries.


Model Information

Model Name: account.alloc.wizard Display Name: Allocation Wizard Transient: Yes Key Fields: None (transient model)

Features

  • ✅ Transient model (temporary data)
  • ❌ Audit logging enabled (_audit_log)
  • ❌ Multi-company support (company_id)
  • ✅ Auto-populates available invoices to allocate
  • ✅ Creates allocation journal entries
  • ✅ Automatic line reconciliation

Key Fields Reference

Header Fields

Field Type Required Description
credit_id Many2One Credit note being allocated
type Char Credit note type (in/out)
lines One2Many Allocation lines

Computed Fields

Field Type Description
amount_credit Decimal Outstanding credit amount
amount_alloc Decimal Total amount being allocated
amount_remain Decimal Remaining credit after allocation

API Methods

1. Default Get

Method: default_get(field_names={}, context={}, **kw)

Populates wizard with available invoices for allocation.

Context: - credit_id: Credit note ID to allocate

Behavior: 1. Gets credit note details 2. Finds unreconciled move lines for same contact 3. Filters by receivable (for out) or payable (for in) 4. Calculates outstanding amounts


2. Allocate

Method: allocate(ids, context={})

Creates allocation journal entries and reconciles lines.

Process: 1. Validates credit note type 2. For each allocation line with amount: - Creates journal entry - Posts entry - Reconciles credit note line - Reconciles invoice line

Returns: Navigation to credit note view with flash message


3. On Change Amount

Method: onchange_amount(context={})

Recalculates totals when line amounts change.


Model Relationship Description
account.invoice Many2One (credit_id) Credit note
account.alloc.wizard.line One2Many (lines) Allocation lines
account.move Created Allocation entries

Common Use Cases

Use Case 1: Allocate Credit Note

# Open wizard with credit note
context = {"credit_id": credit_note_id}
vals = get_model("account.alloc.wizard").default_get(context=context)

# Create wizard
wiz_id = get_model("account.alloc.wizard").create(vals)

# Set allocation amounts on lines
for line in vals["lines"]:
    if line["amount_due"] > 0:
        line["amount"] = min(line["amount_due"], remaining_credit)

# Allocate
result = get_model("account.alloc.wizard").allocate([wiz_id])

Allocation Flow

1. Open allocation wizard for credit note
2. System finds unreconciled invoices for contact
3. User enters allocation amounts per invoice
4. System validates total <= available credit
5. Creates journal entries for each allocation
6. Reconciles credit note and invoice lines
7. Credit note updated with reduced balance

Version History

Last Updated: December 2024 Model Version: account_alloc_wizard.py Framework: Netforce


This documentation is generated for developer onboarding and reference purposes.