Add the service usage page behind a feature flag (#193) #730
No reviewers
Labels
No labels
API
Billing
UI/UX
dependencies
bug
change
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
servala/servala-portal!730
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/service-usage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
A member-facing Usage page for the current calendar month: accrued money so far and the expected total at month end, per instance.
Closes #193.
Design:
docs/plans/2026-10-19-service-usage-view-design.mdPlan:
docs/plans/2026-10-19-service-usage-view-plan.mdHow
get_instance_usage(sale_order_id, start, end)incore/odoo.pyreads the month'saccount.analytic.linerows whereinstance_event = true, plus theirsale.order.linerows.Many2one fields are unwrapped there, so no caller ever sees Odoo's
[id, name]pairs.Cache 300 s, failure cache 60 s, 15 s read budget. No Odoo write.
core/usage.pygroups the lines per instance and computesaccrued = quantity x priceandexpected = accrued + day_qty x price x billable days,where a day is
24 x instance_size / 730. Money isDecimal, rounded half up per line, and thetotals are sums of the rounded values.
coloured dot per item, and the accrued and expected money per row. CSS only, no chart library.
Feature.SERVICE_USAGE, default off, and the page is hidden for organizations on ashared sale order (one order carries several tenants).
Decisions worth reviewing
order_idwould show one customeranother's instances and money. The menu entry is hidden with the same gate.
end and the first billed day. A trial that covers the rest of the month says so instead.
formatted in
Europe/Zurichin the view, because thedatefilter would convert it back to UTC.Invoices, which now renders for members too.
Tests
just test-> 3159 passed, project coverage 94%.New coverage: the flag gates, the Odoo read and its cache and budget, the money and trial maths,
the join rules, the composition shares, the Swiss money format, the states, and the accessible
labels.
core/usage.pyis at 100%.Before switching the flag on
Task 0 of the plan has not run: there are no prod Odoo credentials here, and preprod has zero
usage analytic rows. Two assumptions need one read-only check on prod:
instance_id. If that UUID is not aServiceInstance.name,those rows render unlinked under the product name. That is acceptable, not a blocker.
instance_idinname, andunit_amountsums toqty_invoiced + qty_to_invoicefor the same window.Migration
core/0072_featureflag_service_usageis anAlterFieldonFeatureFlag.namefor the new choice.The
post_migratehandler creates the row.ac6ed2ccc535c9af681835c9af6818a37daa1217a37daa1217a1a2e388beView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.