Skip to main content

Phase 5 — Cutover & Production Install

The production deployment of the Phase 4 work plus the user-side handoff that flips Baywaters from shared parent journals to per-branch journals.

The install is additive: it creates 44 new account.journal rows (11 branches × 4 templates) and touches no existing data. Reversal is just archiving (active=false) the new journals.

:::caution Before running on production Always run the Phase 0 backup first. Take both the DB dump and the filestore. :::

1. Pre-flight

SSH into the production server:

ssh -p <port> <user>@<prod-host>

Verify addons_path in odoo.conf includes the YGC custom addons:

grep addons_path /path/to/odoo.conf
# Expected to include: /path/to/odoo17/custom/ygc17/common

Take a DB backup tagged with the operation:

pg_dump -U <db_user> -h localhost rts_baywaters \
-F c -f ~/backups/rts_baywaters_pre_branchjournals_$(date +%Y%m%d_%H%M).dump

Keep the dump for at least 30 days.

2. Pull the latest code

cd /path/to/odoo17/custom/ygc17
git pull origin main

After pull, confirm the new module is present:

ls common/baywaters_branch_journals/
# Expected: __init__.py __manifest__.py README.md hooks.py

3. Refresh Odoo's module list

Production Odoo doesn't auto-discover new modules from the filesystem — you must trigger a refresh:

cd /path/to/odoo17
python odoo-bin -c odoo.conf -d rts_baywaters \
--stop-after-init --update-list

Wait for Modules loaded. then exit.

4. Install the module

python odoo-bin -c odoo.conf -d rts_baywaters \
-i baywaters_branch_journals --stop-after-init

Watch the log for output from the post-install hook:

INFO baywaters_branch_journals.hooks: Creating branch journals for 11 branches under 'Baywaters Corp.' (parent id=1)
INFO baywaters_branch_journals.hooks: Branch Auntie Annes (Petron) (id=6, prefix=AA):
INFO baywaters_branch_journals.hooks: created AAINV (id=NN)
INFO baywaters_branch_journals.hooks: created AABIL (id=NN)
...
INFO baywaters_branch_journals.hooks: Branch journal creation complete.

Expect 44 created lines — 11 branches × 4 journal types.

5. Verify

Count check (SQL)

SELECT COUNT(*) AS branch_journals
FROM account_journal
WHERE code ~ '^[A-Z]{2}(INV|BIL|MSC|CSH)$';
-- Expect: 44

No duplicates per (company, code)

SELECT company_id, code, COUNT(*)
FROM account_journal
GROUP BY company_id, code
HAVING COUNT(*) > 1;
-- Expect: 0 rows

UI smoke test

For at least one branch, log into Odoo and:

  1. Switch active company to the branch (e.g. Potato Corner (Caltex))
  2. Open Accounting → Configuration → Journals
  3. Confirm PCINV, PCBIL, PCMSC, PCCSH appear with the correct types and default accounts
  4. Create a draft invoice — PCINV should be the default journal
  5. Save (don't post yet) and confirm the entry will be numbered PCINV/YYYY/MM/0001 on post

6. Rollback options

In order of preference:

A. Archive the new journals (preferred)

If problems surface but no entries have been posted on the new journals yet, archive them:

# Via odoo-bin shell
journals = env['account.journal'].search([
('code', '=like', '__INV'),
('code', 'in', ['AAINV','BJINV','JPINV','MIINV','SSINV','SEINV',
'BBINV','HNINV','JCINV','PCINV','SCINV',
'AABIL','BJBIL','JPBIL','MIBIL','SSBIL','SEBIL',
'BBBIL','HNBIL','JCBIL','PCBIL','SCBIL',
'AAMSC','BJMSC','JPMSC','MIMSC','SSMSC','SEMSC',
'BBMSC','HNMSC','JCMSC','PCMSC','SCMSC',
'AACSH','BJCSH','JPCSH','MICSH','SSCSH','SECSH',
'BBCSH','HNCSH','JCCSH','PCCSH','SCCSH']),
])
journals.write({'active': False})
env.cr.commit()

This hides them from users but preserves audit trail. To reactivate, set active=True.

B. Restore from backup (last resort)

# Drop and restore (loses any data committed since the dump)
dropdb -U <db_user> rts_baywaters
createdb -U <db_user> rts_baywaters
pg_restore -U <db_user> -d rts_baywaters \
~/backups/rts_baywaters_pre_branchjournals_*.dump

Only use if data corruption is suspected. Any work done in Odoo between the dump and the restore is lost.

7. Post-install — operational handoff

Once verified, the next steps are not technical:

  1. Cutover date — pick when branch users should switch from posting to parent journals to their own branch journals
  2. User defaults — for each branch user, set their default journal in Odoo preferences to the branch's <XX>INV and <XX>BIL
  3. Communicate — accounting team needs to know about the new code prefix and that move names will look different (PCINV/2026/05/0001 instead of INV/2026/05/0001)
  4. Monthly lock dates — see Lock Dates for the cadence

Adding a branch later

If a new child company is created in Baywaters Corp.:

  1. SSH to production server
  2. Edit common/baywaters_branch_journals/hooks.py — add the new (branch_name, prefix) to BRANCH_CODE_MAP (prefix must be 2 chars, unique)
  3. Commit and push from your laptop, pull on production
  4. Update the module:
    python odoo-bin -c odoo.conf -d rts_baywaters \
    -u baywaters_branch_journals --stop-after-init

Existing branches' journals are detected and skipped — only the new branch's 4 journals get created.