ProjoMania

Sample report on a purpose-built demo module

Sample Odoo Code Audit Report

A complete audit of sale_commission_tracker, an Odoo 17.0 module written with deliberately planted flaws: health score, 17 findings ranked by severity, upgrade notes for 18.0 and 19.0, and a remediation plan with effort. A test reproduces every finding.

Mohamed Magdy, Founder & Senior Odoo Engineer · November 22, 2026

Sample report on a purpose-built demo module. sale_commission_tracker is not client code. ProjoMania wrote it for this page, with flaws planted on purpose, so the full report can be published. The module, its fixed version and the tests are public on GitHub. A client report has the same structure, plus a fixed price for each finding.

What was audited?

One custom module for Odoo 17.0 that pays sales commissions. It stores a commission rate per salesperson, creates a commission line when a sale order is confirmed, shows the commission on the order, and publishes commission statistics at /commission/stats.

ItemValue
Modulesale_commission_tracker 17.0.1.0.0, depends on sale
Size11 files, 285 lines of Python, XML and CSV
Odoo17.0, installed from source on a new, empty database
UpgradeNotes for 18.0 and 19.0 (installed and tested on both)
MethodCode read line by line; every finding reproduced by an automated test on a throwaway database
SourceProjoMania/odoo-audit-demo on GitHub (LGPL-3)
ReviewerMohamed Magdy, Founder & Senior Odoo Engineer
Date22 November 2026

What is the module’s health score?

30 / 100. Not safe to run in production as it is. Two Critical findings can be reached by anyone on the internet without logging in, and four High findings put wrong numbers into commissions.

AreaPointsFindings
Security and access0 / 5F01, F02, F03, F04
Data integrity0 / 5F05, F06, F07, F08
Performance4 / 5F09
Upgrade safety (18, 19)0 / 5F10, F13, F14, F15, F16, F17
Code quality, dead code3.5 / 5F11, F12
Module health score30 / 1002 Critical, 10 High, 3 Medium, 2 Low

How the score works. Each area starts at 5 points. Every finding takes points off its area: Critical 5, High 2, Medium 1, Low 0.5, never below 0. The five areas add up to 25 and are multiplied by 4. Upgrade findings count at their severity on the target version.

Severity levels.

  • Critical: someone outside your company can exploit it, or it exposes or destroys data today.
  • High: wrong figures, access beyond a user’s role, or a blocker for the planned upgrade.
  • Medium: a cost in speed, or wrong behaviour that users can see.
  • Low: clean-up with no visible effect today.

Findings

Each finding lists where it is, what happens, the evidence, and the fix. Evidence names the reproduction test; all of them pass on the module as shipped and fail once the fix is in. Checklist numbers refer to the Odoo Custom Module Health Checklist.

F01 · Critical · Anonymous visitors can read every commission line

Where: controllers/main.py:6 and :19 · Checklist: item 1

The statistics route is auth="public" and reads commission lines with sudo(). Anyone with the URL gets every line: order, customer name, salesperson and amount.

@http.route("/commission/stats", type="http", auth="public", methods=["GET"], csrf=False)
def commission_stats(self, login=None, **kwargs):
    ...
    lines = request.env["commission.line"].sudo().search([])

Evidence: test_f01_public_route_returns_every_commission_line. An anonymous request returns HTTP 200 with both salespeople’s lines and the customer “Confidential Customer Ltd”.

Fix: auth="user", no sudo(), so access rights and record rules apply (F03, F04). Return only the fields the page needs.

F02 · Critical · SQL injection in the same public route

Where: controllers/main.py:14 · Checklist: item 2

The login parameter is formatted into the SQL text.

if login:
    query += " WHERE u.login = '%s'" % login

Evidence: test_f02_sql_injection_in_login_parameter. /commission/stats?login=nobody' OR '1'='1 returns every salesperson’s total, although no user is called “nobody”.

Fix: drop the raw SQL and use the ORM with a domain, [("user_id.login", "=", login)], and _read_group for the totals. If SQL stays, pass login as a parameter or use odoo.tools.SQL.

F03 · High · Every employee can change commission rates and mark commissions paid

Where: security/ir.model.access.csv:2–3 · Checklist: item 3

Both models give base.group_user read, write, create and delete. Every internal user, including people outside Sales, can edit any commission rule and line.

Evidence: test_f03_salesperson_can_raise_own_rate. A salesperson raises their own rate from 10% to 50%.

Fix: read-only for sales_team.group_sale_salesman, full access for sales_team.group_sale_manager.

F04 · High · Salespeople see each other’s commissions; the “hidden” total is readable

Where: no ir.rule in the module; views/sale_order_views.xml:16 · Checklist: items 5 and 6

With no record rules, every salesperson reads every colleague’s commission lines. The commission total on the order form is hidden from non-managers with invisible, but the field has no groups=, so the value still comes back over RPC and export.

Evidence: test_f04_salesperson_reads_colleagues_commissions. Alice’s search returns Bob’s lines, and Alice reads commission_total on her own order (100.0) although the form hides it from her.

Fix: record rules (own lines for salespeople, all for managers, plus a multi-company rule) and groups="sales_team.group_sale_manager" on commission_total and commission.line.amount.

F05 · High · The order’s commission total goes stale

Where: models/sale_order.py:13 · Checklist: item 9

The stored commission_total depends only on state, but it is computed from amount_untaxed, user_id and the rule.

@api.depends("state")
def _compute_commission_total(self):

Evidence: test_f05_commission_total_goes_stale. Quantity 1 → 3 makes the untaxed amount 3,000.00, and the commission stays at 100.00 instead of 300.00.

Fix: @api.depends("amount_untaxed", "user_id", "company_id"), then recompute the stored values once when the fix is deployed.

F06 · High · Confirming an order commits the transaction halfway

Where: models/sale_order.py:52 · Checklist: item 10

action_confirm() calls self.env.cr.commit(). If anything after it fails, such as another module’s override of action_confirm(), the confirmation and commission lines are already saved and can’t be rolled back.

Evidence: test_f06_action_confirm_commits_the_transaction. The cursor’s commit() is called during confirmation.

Fix: delete the line. Odoo commits once, at the end of the request.

F07 · High · A rule from another company sets the rate

Where: models/sale_order.py:35–38 · Checklist: item 12

The rates are read with search([]) into a dictionary keyed by salesperson only. When a salesperson has a rule in two companies, the last one read wins, whatever the order’s company.

rates = {
    rule.user_id.id: rule.rate
    for rule in self.env["commission.rule"].search([])
}

Evidence: test_f07_rule_from_another_company_sets_the_rate. Alice has 10% in company A and 20% in company B. A company A order of 1,000.00 gets a 20% line of 200.00.

Fix: key the rates by salesperson and company, and look up (order.user_id, order.company_id).

F08 · High · Errors are swallowed, so commissions go missing without a trace

Where: models/sale_order.py:50–51 · Checklist: item 11

Every exception while creating a commission line is caught and ignored.

except Exception:
    pass

Evidence: test_f08_missing_rule_is_silently_skipped. An order by a salesperson with no rule is confirmed with no commission line, no message on the order and no log line. On 19.0 the same except also hides F10: no order gets a commission line at all (upgrade probe, test_f08_f10_confirmation_silently_creates_no_commission_on_19).

Fix: no try. Skip salespeople without a rule explicitly, and post a note on the order so someone can act on it.

F09 · Medium · One query per order to count commissions

Where: models/sale_order.py:21–25, also :15–18 · Checklist: item 15

commission_count runs search_count() once per order, and commission_total runs one rule search per order. Any code that reads the count for 80 orders at once, such as an export, runs 80 queries for it.

Evidence: test_f09_commission_count_is_one_query_per_order. Computing the count for 20 orders runs at least 10 more queries than for 10 orders.

Fix: one _read_group([("order_id", "in", self.ids)], ["order_id"], ["__count"]) for the batch, and one rule search for all the salespeople and companies involved.

F10 · High on 19.0, Medium on 17.0 · create() handles one record at a time

Where: models/commission_line.py:19–20 · Checklist: item 16

@api.model
def create(self, vals):

On 17.0, Odoo logs The model odoo.addons.sale_commission_tracker.models.commission_line is not overriding the create method in batch at startup and calls the method once per record. On 19.0, @api.model on create is treated as @api.model_create_multi, so vals is a list and the first vals.get(...) raises AttributeError: 'list' object has no attribute 'get'.

Evidence: test_f10_create_runs_once_per_record (17.0, two records → two calls) and test_f10_single_record_create (19.0, AttributeError).

Fix: @api.model_create_multi and def create(self, vals_list), with the rate lookup done once for the whole list.

F11 · Medium · The override that hides the Amount column never runs

Where: models/commission_line.py:34–46 · Checklist: item 27

The module overrides fields_view_get() to hide the commission amount column from non-managers. BaseModel has no fields_view_get() in 17.0, so nothing calls the override: every user sees the amounts.

Evidence: test_f11_fields_view_get_override_is_dead_code. Loading the list view as a salesperson never calls the override, and the view still contains amount.

Fix: delete the override and put groups="sales_team.group_sale_manager" on amount (F04).

F12 · Low · name_get() is ignored; lines show as “commission.line,7”

Where: models/commission_line.py:28–32 · Checklist: item 20

17.0 computes display_name without calling name_get(), and commission.line has no name field, so breadcrumbs and many2one fields show the model name and ID.

Evidence: test_f12_name_get_is_ignored_since_17. Called directly, name_get() returns the order number followed by ”/ Alice Sales”; display_name is commission.line, plus the record ID.

Fix: _compute_display_name() with @api.depends("order_id.name", "user_id.name").

F13 · High (upgrade) · The module doesn’t install on 18.0 or 19.0

Where: views/commission_views.xml:7, 19, 26, 64 · Checklist: item 18

The list views use <tree> and the actions view_mode tree.

Evidence: run_upgrade_probe.sh. With only the manifest version changed, 18.0 stops with ValueError: Wrong value for ir.ui.view.type: 'tree' and 19.0 with Invalid view type: 'tree'.

Fix: <list> and list in the 18.0 and 19.0 branches.

F14 · High (upgrade) · No one can open a sale order on 18.0 or 19.0

Where: models/sale_order.py:29 · Checklist: item 21

can_edit_commission is computed with self.user_has_groups(...), which 18.0 removed. The field is on the sale order form, so the form fails to load.

Evidence: test_f14_user_has_groups_breaks_the_sale_order_form (18.0 and 19.0): AttributeError: 'sale.order' object has no attribute 'user_has_groups'.

Fix: remove the field and use groups= (F04). Where a check is still needed, self.env.user.has_group(...).

F15 · Medium (upgrade) · The Commissions button fails on 18.0 and 19.0

Where: models/sale_order.py:60 · Checklist: item 18

action_view_commissions() returns "view_mode": "tree,form". 17.0 translated tree to list before sending the action to the browser; 18.0 no longer does.

Evidence: test_f15_tree_view_mode_from_python_breaks_the_smart_button. The action’s views come out as [False, "tree"], and loading them raises UserError: No default view of type 'tree' could be found!

Fix: "view_mode": "list,form" in the 18.0 and 19.0 branches.

F16 · High (upgrade) · On 19.0 the uniqueness rule disappears

Where: models/commission_rule.py:16 · Checklist: item 25

“One rule per salesperson per company” is declared with _sql_constraints, which 19.0 ignores with a warning in the log. A second rule for the same salesperson and company is accepted, and F07’s lookup then picks one of them.

Evidence: test_f16_sql_constraints_are_ignored_on_19. On 18.0 the constraint exists and a duplicate raises IntegrityError; on 19.0 the constraint is absent and the duplicate is saved.

Fix: models.Constraint("UNIQUE(user_id, company_id)", "...") in the 19.0 branch. Check the database for duplicates before the upgrade.

F17 · Low (upgrade) · group_operator is deprecated

Where: models/commission_rule.py:10 · Checklist: item 22

Evidence: test_f17_group_operator_is_converted_to_aggregator. 18.0 and 19.0 log DeprecationWarning: Since Odoo 18, 'group_operator' is deprecated, use 'aggregator' instead and still average the rate.

Fix: aggregator="avg" in the 18.0 and 19.0 branches.

What does the module need on 18.0 and 19.0?

Step18.019.0
Install as shipped (version number changed)Fails (F13)Fails (F13)
After <tree> → <list>Installs; sale order form fails (F14); button fails (F15)Same as 18.0, plus no commission lines at all (F08 + F10) and no uniqueness (F16)
Warnings in the logF10, F17F16, F17

The most dangerous result is on 19.0: the module installs, orders confirm, and no commission is ever created, with no error on screen or in the log. Only a test, or a salesperson asking about their commission, reveals it.

What is the remediation plan?

Fix in this order. Effort is the estimated engineering time per finding, tests included in the last row.

OrderFindingsWhy firstEffort
1F01, F02Exposed to the internet today1.5 h
2F03, F04Access beyond each user’s role2.5 h
3F05, F06, F07, F08Wrong or missing commission amounts4.25 h
4F09, F10, F11, F12Speed, batch create, dead code2.25 h
5F13, F14, F15, F16, F17With the move to 18.0 or 19.02 h
6Regression testsAccess, amounts and upgrade behaviour4 h
Total16.5 h

Per finding: F01 1 h, F02 0.5 h, F03 0.5 h, F04 2 h, F05 1.5 h (including a one-off recompute), F06 0.25 h, F07 1.5 h, F08 1 h, F09 1 h, F10 0.5 h, F11 0.5 h, F12 0.25 h, F13 0.25 h, F14 0.25 h, F15 0.25 h, F16 1 h (including the duplicate check), F17 0.25 h.

In a client report, each line also carries a fixed price. You decide what to fix and who fixes it.

How was this report verified?

Every finding above was reproduced, not inferred:

  • On 17.0: a test module with one test per finding. All 12 tests pass on the module as shipped.
  • After the fixes: a remediated version of the module passes its own 8 tests, and all 12 reproduction tests fail against it, which shows each fix removes its finding.
  • On 18.0 and 19.0: a script installs the module as shipped (F13), applies only the <tree> → <list> change, and runs 7 version-aware tests. All 7 pass on both versions.

Odoo 17.0, 18.0 and 19.0 were run from source on throwaway local databases. The version claims are traced to the Odoo source in the checklist, item by item. The demo module, the remediated version, the tests and the commands to run them are in the public repository ProjoMania/odoo-audit-demo (LGPL-3).

Want this for your own modules? Start with a free Module Health Check, or read what the Odoo Code Audit covers.

Get a free Module Health Check

One custom module, up to 2,000 lines (Python, XML and JavaScript). A short written report within 3 business days. Free for the first 5 companies, in exchange for permission to publish the findings anonymized.