Skip to main content

Per-Branch Sequences

Each Panville branch needs its own document numbering so SO and invoice numbers don't overlap across stations. shell18 ships with per-branch sequences for sale orders; per-branch invoice numbering is handled by Odoo's per-journal sequence (which is naturally per-branch since journals are per-branch).

Sale Order sequences

Defined in shell18/data/ir_sequence_branch_data.xml:

BranchCodePrefix
TPLE-Rosariosale.orderSO/ROS/%(range_year)s/
Baguio-Abanaosale.orderSO/ABA/%(range_year)s/
Baguio-Baguiliansale.orderSO/BGL/%(range_year)s/
Baguio-Marcos Highwaysale.orderSO/MAR/%(range_year)s/
Balili-La Trinidadsale.orderSO/LTR/%(range_year)s/
Pangasinan-San Fabiansale.orderSO/SF/%(range_year)s/

All have padding = 5 and use_date_range = True so each year resets to 00001.

How Odoo picks the right sequence

ir.sequence.next_by_code('sale.order') matches the company-scoped record over the global default. When a SO is created with company_id = ROS branch, the call resolves to the ROS sequence and produces e.g. SO/ROS/2026/00001.

Invoice / move sequences

account.move numbering in Odoo 18 comes from the journal's code (a 5-character field on account.journal). Since each branch has its own journal (e.g. each branch's "Customer Invoices" is a distinct account.journal row), invoice numbers are naturally branch-scoped:

INV/2026/00001 ← parent's journal
ROSCI/2026/00001 ← TPLE-Rosario "Customer Invoices" journal (if code = ROSCI)

Adjust the journal code on each branch via Settings > Accounting > Journals to match your prefix preference.

Verifying the setup

-- Per-branch SO sequences
SELECT s.name, s.code, s.prefix, c.name AS branch
FROM ir_sequence s
JOIN res_company c ON s.company_id = c.id
WHERE s.code = 'sale.order'
ORDER BY c.name;
-- Per-branch journals (will determine invoice prefixes)
SELECT j.code, j.type, c.name AS branch
FROM account_journal j
JOIN res_company c ON j.company_id = c.id
ORDER BY c.name, j.type;

When to add more sequences

Per-branch sequences for additional models (purchase orders, stock pickings, etc.) follow the same pattern: add an ir.sequence with code = the relevant model code and company_id = the branch.