Ledger configuration models of the account addon
Source: addons/account/src/ledger/ (accounts) and addons/account/src/journal/ (journals). Spec:
docs/specs/accounting/ledger-config.md (ACCLED). Plain company accounting configuration lives in addons/account/src/company/.
The models
Section titled “The models”| Model | Table | What it is |
|---|---|---|
account.account | account_account | An account of the chart. Shared by the companies of company_ids. |
account.account.tag | account_account_tag | A reporting tag (accounts, taxes, products). Unique per name, applicability and country. |
account.root | account_root | The first two characters of a code, as a small tree (10 below 1). |
account.code.mapping | account_account_code | The code of an account in one root company. |
account.journal | account_journal | A journal of one company: type, code, default and special accounts, numbering declaration. |
account.journal.group | account_journal_group | A ledger: a named group of journals, one list for the database. |
Codes live in a table
Section titled “Codes live in a table”Odoo keeps the code in a company-dependent JSON column and checks uniqueness with a Python search. Here the code is a
row of account_account_code per account and root company (ADR 0048 D3):
UNIQUE (company_id, code): two accounts of one company tree cannot share a code, and the database says so (SPEC-ACCLED-017,Parity: divergent, ADR 0048 D3). Sibling company trees have different roots and may reuse a code.UNIQUE (account_id, company_id): one code per account and tree.- A branch company reads and writes its root’s code (SPEC-ACCLED-029, 030). A mapping row for a branch is refused.
account.account.code is a computed, writable field over that table in the environment’s company
(depends_context = ["company"]). Writing it stores the code for the root of the active company, or removes the row
when the value is empty. account.root rows are created when a code is stored and never removed; each missing prefix is
one insert-if-absent on the _name_uniq key (the ORM upsert with nothing to update), so two transactions that first use
the same prefix both succeed (the later one is retried by Orm::run after a serialization failure).
A code given at create is stored for the root of the active company when the account belongs to that tree, else for
the root of the account’s first company that is also a company of the caller (lowest company id), as the reference
creates under the caller’s allowed companies (odoo/addons/account/models/account_account.py:1023-1025, :1042-1043).
A caller with companies [A, C] creating an account of [B, C] stores the code in C’s tree, never B’s; when the account
belongs to none of the caller’s companies the create is a Validation error. Only superuser mode takes the lowest
company id of the account. An account created from company A with company_ids = [B] in superuser mode therefore reads
its code in B and uses no code of A’s tree. A code value that is neither absent,
null nor text is a Validation error. The account_id and company_id of an account.code.mapping row are set at
create only; account_id is readonly (the one2many sets it) but company_id is not, so the “Codes by company” list can
send it for a new row. A write that gives either a value other than the stored one is a Validation error; naming the
stored value passes. Only code is written.
// the code of an account as seen from a companylet in_company = tx.env().with_company(company)?.records("account.account")?;let account = in_company.browse([id])?;let code = account.cell(&mut tx, "code").await?;// written from a branch: changes the root's code for the whole treeaccount.write(&mut tx, RawVals::new().set_cell("code", Cell::Str("180002".into()))).await?;Reading code without an active company in the context is a Validation error, not an empty value.
A create may carry code_mapping_ids create commands. The x2many values of a create are written in field order, and the
company check of a row reads the account’s company_ids, so code_mapping_ids is declared after company_ids in the model;
keep that order in any extension that adds company-checked one2many fields to an account. A row for a company outside
company_ids is refused by the company check, never skipped.
Type rules
Section titled “Type rules”account_type has the 19 types of the reference. internal_group (the part before the first underscore) and
include_initial_balance are stored computed fields; reconcile is a stored computed field that the type forces for
receivable, payable, bank and cash, credit card, off-balance and the income, expense and equity groups, and leaves to
the user for the other asset and liability types. Constraints: receivable and payable must reconcile; off-balance must
not and cannot carry default taxes; a bank or cash account has one company; every account has at least one company; a code uses letters, digits, dots
and dashes. An account created without company_ids gets the active company.
Extending
Section titled “Extending”Another addon adds fields with #[extend(AccountAccount, addon = "...")] (or AccountJournal) as for any model (see
Extending other addons). The _check_* constraints compose through the usual override
chain. The move slice adds the journal item guards.
Journals
Section titled “Journals”account.journal has the six types of the reference (sale, purchase, cash, bank, credit, general), a
company (the active company when none is given, also for an empty value; a company id given as an integer is
accepted, any other value is refused; branches use their parent’s journals: company access ancestor, company match
parent_of) and a code unique per company (UNIQUE (company_id, code)).
| Rule | When | Message names |
|---|---|---|
A journal without code gets <prefix><n>, the first n free in the company and its parents (archived journals included) and in the same create call; outside superuser mode only in a company the caller may create journals in (an active company or a parent of one), else Access before any code is read | create | the code length setting when no code fits |
Two creates at the same time that propose the same code: the first wins, the second fails with a Conflict (when the call typed no code; a typed duplicate keeps the unique-key refusal) | create | “save again” |
The code has 1 to account.journal_code_max_length characters, without a space at its start or end | create, write of code | the setting |
| A default account the caller cannot read is refused before its type is read, with the same sentence whatever that type is | create, write of type or default_account_id; account type change | the account by its id and the journal type |
| A sale or purchase journal never defaults to a receivable or payable account | same | the reference’s two messages |
The default account’s type is in account.journal_account_types_<type> | same | the type and the setting |
| Journal and default account agree on the foreign currency (an account without currency fits) | journal create, journal write of currency_id or default_account_id, account write of currency_id | journal and account names |
| Writing a currency on a bank, cash or credit card journal copies it onto its default account | journal write | |
| A bank, cash or credit card journal has a default account (until the account is created for it) | create, write of type or default_account_id | the company accounting fields |
| An account keeps the companies of the journals using it as default, suspense, profit or loss account (the journal’s company or one of its parents) | account write of company_ids | account, field and journal (a journal the caller cannot read by its id) |
| An account used by a journal in one of those four fields cannot be deleted; a ledger used by a journal cannot be deleted | delete | the journal model |
check_currency_consistency(tx, env, journals, accounts), check_accounts_as_default(tx, env, accounts) and
check_journal_companies(tx, env, accounts) in erp_addon_account::journal are the shared checks; the account
constraints call them. A refusal names a journal or an account only when the caller may read it, otherwise by id, also when the caller may not read the model at all.
The numbering declaration
Section titled “The numbering declaration”The journal stores what the reference reads back from the previous entry name (ADR 0048 D2.2): sequence_reset
(never, year, month, year_range, year_range_month), sequence_padding (1 to 64 digits), refund_sequence
and payment_sequence. They default from the type (sales and liquidity journals: yearly, five digits; the others:
monthly, four digits; credit notes apart for sale and purchase, payments apart for bank, cash and credit card); values
given at create are kept. The restart rule and the digits are set only at create: a later type change keeps them,
while the two separate-chain flags follow the type. The database refuses digits outside 1 to 64. The numbering
service reads the declaration through JournalSequence, which only JournalSequence::of makes:
use erp_addon_account::journal::{AccountJournal, JournalSequence};
let journal = tx.env().model::<AccountJournal>()?.browse(vec![journal_id])?;let sequence = JournalSequence::of(tx, &journal).await?;// a refund without its own chain is numbered in the document chainlet (kind, pattern) = sequence.pattern("refund")?; // ("refund", RINV1/2026/00001 ...)A journal whose code and numbering cannot make a valid pattern is refused when it is saved, never at posting.
account.sequence.chain.journal_id is still an integer column; it becomes a many2one to account.journal with the
journal entry work, which also rewrites the numbering tests that use free journal ids.
Journal settings
Section titled “Journal settings”An administrator can change account.journal_code_max_length in Technical > System Parameters.
It is a database-wide integer with default 16 and bounds 1 to 32 characters. Account 1.10 carries
an existing global Journals setting into that parameter during upgrade.
Declared settings of the accounting app (database scope, block “Journals”; read: account.group_account_readonly,
write: account.group_account_manager):
| Setting | Default | Bounds |
|---|---|---|
account.journal_code_prefix_<type> | INV, BILL, CSH, BNK, CCD, MISC | one word, at most 16 bytes |
account.journal_account_types_<type> | the reference’s default-account domain per type | a comma list of known account types, at most 512 bytes |
JournalSettings::read(tx) reads the typed parameter and loads the remaining Settings keys together.
The service reports the key and its bounds for invalid values and refuses an empty account type list.
Changes apply when a journal or account is next created or written.
Journal dashboard card
Section titled “Journal dashboard card”account.journal.dashboard_card is a computed, non-stored text field holding the card contract v1 as JSON (buttons,
stats, chart; addons/account/src/journal/dashboard.rs). The kanban account.account_journal_dashboard_kanban_view
(action account.open_account_journal_dashboard_kanban, menu Accounting > Dashboard) shows it with the
dashboard_card widget for the journals with show_on_dashboard. Each card element and its reference counterpart:
docs/design/accounting-dashboard-matrix.md.
- One computation serves every requested journal with a fixed set of grouped reads (
_read_grouponaccount.moveandaccount.move.line), never one query per journal; the reads run with the reader’s rights, so record rules and the company scope apply. A reader without accounting access gets the access error. - Every stat and chart is always shown; one that counts nothing shows zero in the neutral tone (the reference hides such a row and draws sample bars on an empty journal).
- Sales and purchases: button New Invoice or New Bill; “Drafts”, “Unpaid” (sales) or “To pay” (purchases) and
“Late” (posted, due before today in the user’s time zone) from the lines on receivable and payable accounts
(balance, purchases shown positive,
date_maturity); a bar chart of the posted invoiced (billed) amount per month. Each figure opensaccount.action_move_out_documents(sales) oraccount.action_move_in_documents(purchases): the invoice list without a document-type domain, so it shows every document the figure counts. - Bank, cash and credit card: no button; “Balance”, the posted balance of the default account in the journal’s company, linking to its journal items; “Transactions”, the number of the journal’s plain entries, opening them (until statements exist); a line chart of the running balance per day.
- Miscellaneous: button New Entry; “Drafts”; no chart.
- Until reconciliation exists, “open” means posted: the residual replaces the balance when it arrives.
- Labels are in the source language (
dashboard::labels): the addon has no server-side code-text translation yet.
| Setting (database scope, block “Dashboard”) | Default | Bounds |
|---|---|---|
account.dashboard_graph_months | 13 (the current month and the twelve before) | 1 to 36 months |
account.dashboard_balance_days | 30 | 7 to 64 days (one chart point per day; a card shows at most 64) |
Journal groups
Section titled “Journal groups”account.journal.group (a “ledger”): name unique in the database (“Another ledger already has this name.”),
sequence (default 10) and included_journal_ids, the journals whose journal_group_id points to it, archived ones
included. Like the reference it has no company. A ledger that a journal uses, archived journals included, cannot be
deleted (journal_group_id is restrict): the reference empties the ledger of the journals of every company.
Data and security
Section titled “Data and security”- Default data: the three master tags (
account_tag_operating,account_tag_financing,account_tag_investing), which cannot be deleted. The reference ships no accounts, roots or code mappings: accounts come from a chart template (the chart-template slice) and roots follow the codes (SPEC-ACCLED-053; tested incrates/erp-cli/tests/account_install.rs). No journals or journal groups either: the reference creates the standard journals when a chart is loaded into a company, and that list belongs to the chart-loading slice (SPEC-ACCLED-102). - Groups (
security/account_security.xml):group_account_readonly,group_account_user,group_account_manager. the security-data slice extends them. - Company rule: generated from
company_access(accounts bycompany_idsand ancestors, code rows and journals bycompany_idand ancestors). Journal groups have no company. - Access: journals and journal groups are read by
group_account_readonlyand managed bygroup_account_manager. - Menus: Accounting > Configuration > Chart of Accounts, Account Tags, Journals (managers), Ledgers.
Company accounting configuration
Section titled “Company accounting configuration”The account addon extends res.company with ordinary account references for transfers, bank suspense,
cash differences, cash discounts, exchange differences, PoS receivables and accruals, and journal references
for exchange differences and automatic entries. References start unset, use restrictive foreign keys and
obey the framework’s company consistency rules. An account or journal of an unrelated company cannot be
assigned, including through elevated ORM operations; permitted parent-company targets remain usable by a branch.
Removing a selected account’s company membership or moving a selected journal is refused when it would strand
a configuration reference. The refusal names no hidden company. Failed native writes still require an enclosing
savepoint or transaction rollback, as other ORM writes do.
These fields are ordinary company columns, independent of the typed company-dependent account mappings.
Company fields also store bank, cash and transfer account-code prefixes (empty or up to 64 ASCII letters,
digits, dots and dashes), tax rounding (round_globally by default or round_per_line), Anglo-Saxon accounting
(false by default), and whether a chart is expected (true). Prefix and option writes configure future consumers;
they do not create or rename accounts or post entries. The chart identifier is read-only until chart activation
is available. The company form cannot activate or clear an installed chart.
Settings > Accounting > Company accounting opens the explicitly selected company’s configuration form. This is a scoped Settings link, not a second copy of the relational values in scalar settings storage. Existing company-management permissions apply; accounting-manager membership alone grants no company writes. Configuration writes check company scope before reading target details. Existing fiscal-year settings and lock-date policy remain separate; the form does not offer a generic lock-date editor.
Installation and upgrade
Section titled “Installation and upgrade”Upgrade account before serving a binary that declares the company configuration link: the upgrade installs
its action and form along with the new columns. A missing link target is refused during Settings publication.
Existing companies retain their tax, lock and accounting configuration on upgrade. No jurisdiction-specific
accounts or journals are seeded by this extension; references remain empty until configured from the company’s chart.
Not available yet: automatic journal account creation, use of company suspense/cash-difference defaults by journals, prefix-driven renumbering, chart activation, and effective company-dependent receivable/payable/income/ expense/valuation defaults. These limitations are independent of saving the plain configuration fields.
Not in this slice
Section titled “Not in this slice”| Case | Why | Slice |
|---|---|---|
| SPEC-ACCLED-007, 008, 019..026, 035, 038, 040, 041 | account type from the code, name_create, name search, copy, ordering by code, search with archived parents, placeholder code | follow-up slice of the ledger configuration models |
| SPEC-ACCLED-014, 016, 036 | need journal items | the journal items |
| SPEC-ACCLED-062, 063, 064 | journal company change and archive with entries | the journal items |
| SPEC-ACCLED-057, 067 | effective company and category account defaults | account mapping runtime |
| SPEC-ACCLED-058 | liquidity accounts created from prefixes; company suspense and cash-difference defaults consumed by journals | liquidity defaults and prefix lifecycle |
| SPEC-ACCLED-060, 066 | code from the name on import, payment reference from the code | import slice, invoices slice |
| SPEC-ACCLED-042..050 | balances, merge wizard | the account wizards slice, reports |
| mapped company defaults | typed company-dependent accounting mappings | account mapping runtime |
Journal fields of the reference left for their slices: mail alias, invoice reference type and model, invoice report (invoices); payment method lines, bank account and statement source (payments and bank statements); hash mode (locking); self-billing and the sequence override regex (numbering follow-up); dashboard computes (dashboard).
account.account is ordered by id until the ordering slice adds the code order of SPEC-ACCLED-038, so a list
cannot be sorted by the code yet.
A condition on code (=, !=, in, not in, like, ilike, =like, =ilike and their negations, = False)
matches the code of the active company’s tree, as reading the code does: a branch searches its root’s codes, and
an account shared by two trees is found by the code of each tree in that tree. A negative operator also matches
accounts without a code in the tree. Without an active company the condition is a Validation error. A name search
(a many2one field) matches the name or the code as contained text; the reference matches the code by prefix.
Internal users read account.code.mapping, so such a search works for anyone who may read accounts.
Account tax choices
Section titled “Account tax choices”tax_ids holds default taxes and enforces the account’s company applicability. A tax distribution’s
account_id restricts account deletion, including hidden/archived owners. The model-level refusal checks
unlink authority first and gives no unreadable account labels. Archiving is supported; there is no
deprecated field. See Tax definitions for company/product defaults.