What I look for when I audit AI-generated Odoo modules
AI-generated Odoo modules usually install and pass a demo. The problems are in who can reach the data, whether the numbers stay right, how the code behaves at real volumes, and whether it survives the next Odoo version.
On this page
An audit of an AI-generated Odoo module looks first at four questions the demo never answers. Who can reach the data? Do the numbers stay right after the first edit? What happens with 10,000 records instead of 10? Does the module survive the next Odoo version? The code that fails these questions usually reads well, installs cleanly and does what was asked in the happy path.
This post walks through what gets checked under each question, with code from a sample audit report on a purpose-built demo module. Every pattern below is an item in the public Odoo Custom Module Health Checklist, with the Odoo source file that backs it.
Why does AI-generated Odoo code need its own review?
Because it is fluent, and fluent code gets less scrutiny. AI tools learn from Odoo code written for many versions, so one module can combine an Odoo 15 habit, an Odoo 17 view and an API that Odoo 18 removed. Each line looks plausible. Together they install on one version and break on the next.
The other reason is that the prompt describes the feature, not the constraints around it. “Show commission statistics on a page” produces a page. It doesn’t produce the access rule that stops a salesperson, or a stranger, from reading everyone’s commissions.
Who can reach the data?
This is the first question because the damage is immediate. The checks:
- Routes. Every
@http.routewithauth="public"orauth="none", and everysudo()inside one.sudo()skips access rights and record rules, so a public route that reads withsudo()serves every record it finds to anyone with the URL. - SQL. Every
cr.execute()whose text is built with%,.format()or an f-string. In the sample report,?login=nobody' OR '1'='1returns every salesperson’s total to an anonymous visitor. - Access rights. Rows in
ir.model.access.csvthat givebase.group_userall four permissions. Every employee can then edit commission rates. - Record rules. Models with a
user_idorcompany_idand noir.rule. Every salesperson then reads every colleague’s records. - View-only hiding. Fields hidden with
invisible="not is_manager"but readable through the API and exports. Hiding is not restricting;groups=on the field is.
Here is the route from the sample report. It passed a functional review: the page showed the right statistics.
@http.route("/commission/stats", type="http", auth="public", methods=["GET"], csrf=False)
def commission_stats(self, login=None, **kwargs):
query = """
SELECT u.login, SUM(l.amount)
FROM commission_line l
JOIN res_users u ON u.id = l.user_id
"""
if login:
query += " WHERE u.login = '%s'" % login
query += " GROUP BY u.login"
request.env.cr.execute(query)
totals = dict(request.env.cr.fetchall())
lines = request.env["commission.line"].sudo().search([])
Two Critical findings in one short handler: data exposure and SQL injection, both reachable without logging in.
Do the numbers stay right?
Numbers that are right on the day of the demo and wrong a week later are the most expensive findings, because nobody notices until a payout or a stock count. The checks:
- Stored computed fields whose
@api.dependsmisses a field the method reads. In the sample report, the commission is stored with@api.depends("state"); change the quantity on the order and the commission stays at the old value. cr.commit()in business methods. Odoo commits once, at the end of the request. A commit in the middle saves half the work if anything later fails.except Exception: pass. Errors disappear, and so do the records they would have produced.- Multi-company reads.
search([])on a model with acompany_id, keyed by user only, so a rule from company B sets the rate on a company A order.
What happens at real volumes?
A module tested with ten records can run hundreds of queries on a real list. The checks:
- Queries inside loops: a
search()orsearch_count()per record in a compute method. One grouped query,_read_group(domain, groupby, aggregates), replaces them; it has the same signature in Odoo 17, 18 and 19. - Searched fields without an index. Odoo fields have no database index unless they declare
index=. create()overridden for one record at a time. On Odoo 17 the framework logsis not overriding the create method in batchand calls the method once per record.
These are the easiest findings to measure. In the sample report, a test counts the queries for 10 and for 20 orders and shows the count grows with the number of orders.
Will it survive the next Odoo version?
This is where mixed-version code pays its bill. An Odoo 17 module that uses <tree> views doesn’t install on 18 or 19. One that calls self.user_has_groups() installs on 18 and then fails when the method is called, because 18 removed it. Some changes fail without any error:
- Odoo 19 ignores
_sql_constraints, with only a warning in the log, so the uniqueness rule it used to enforce is gone. - Odoo 19 treats
@api.model def create(self, vals)as a batch method, sovalsarrives as a list andvals.get(...)raisesAttributeError.
In the sample report those two meet an except Exception: pass. On Odoo 19 the module installs, orders confirm, and no commission line is ever created. There is no error on screen and nothing in the log. The 17 to 19 upgrade guide covers the full list, with the reason each one breaks.
What can a tool check, and what needs a person?
A lot can be checked mechanically. Odoo itself logs models without access rules, every t-raw it compiles, non-batch create() overrides and deprecated parameters such as group_operator. A search finds sudo(), cr.commit(), except Exception and formatted SQL in seconds. AI-assisted review is good at listing candidates like these.
Three things still need an engineer:
- Intent. Whether a
sudo()is justified depends on what the route is for and who calls it. Some are correct. - Reproduction. A finding that can’t be reproduced is a guess. Every finding in the sample report has a test that fails once the fix is in.
- Business correctness. Whether a commission should follow the order’s company or the salesperson’s is a business rule, not a code smell. Only someone who reads the code with the process in mind catches the mismatch.
That is why the Odoo Code Audit starts with automated checks and ends with a signed report. Standard audits use Anthropic’s Claude to flag candidate issues, with model training disabled on the account. A senior engineer reproduces every finding. Clients who need contractual data-processing guarantees should choose Sovereign Review, where no external AI service touches the code or data.
Where to start
Run the checklist against your own modules: most items include the grep command or log line that finds them. Start with the security items, then anything that writes money or stock. If an upgrade is planned, check the version items before the project starts, and see how Odoo upgrades are handled from source to target.
If you’d rather have someone else read the code, the first five companies get a free Module Health Check: one module of up to 2,000 lines, a written report within 3 business days.