Usage
from peft import PeftModelfrom transformers import AutoModelForCausalLM, AutoTokenizer base = "Qwen/Qwen2.5-Coder-14B-Instruct"tok = AutoTokenizer.from_pretrained(base)model = AutoModelForCausalLM.from_pretrained(base, torch_dtype="auto", device_map="auto")model = PeftModel.from_pretrained(model, "parabol123654/odoo-coder-14b-lora") messages = [ {"role": "system", "content": "You are @Odoo-Dev, an expert Odoo developer. Answer for Odoo 18.0 " "(Community) and use only Odoo 18.0 syntax. Give the code first, then at most three short bullets."}, {"role": "user", "content": "Odoo 18.0: list view for res.partner with name, email, phone."},]ids = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)print(tok.decode(model.generate(ids, max_new_tokens=512)[0][ids.shape[1]:], skip_special_tokens=True))
Always state the target version (system prompt and/or "Odoo X.0:" in the question): it was trained
that way.
Training
Table | |
|---|
| Method | QLoRA (NF4 base unsloth/Qwen2.5-Coder-14B-Instruct-bnb-4bit), r=16, α=32, dropout 0.05, all 7 attention/MLP projections |
| Data | 5,254 synthetic chat examples (Vietnamese/English questions), 7 versions |
| Schedule | lr 1e-4 cosine, warmup 3 %, effective batch 16, max length 1024, completion-only loss |
| Checkpoint | step 100 of 319 (≈ 0.3 epoch, early stop; eval loss 0.030) |
| Hardware | 1 × RTX 5060 Ti 16 GB, ~20 min |
Data provenance. Every example is generated from facts extracted from the Odoo Community
source code (model names, fields, methods, stock views) for each version, then self-checked:
the answer must pass XML/Python/XPath graders, a per-version access-file check, and a forbidden-syntax
scan for that version (e.g. no <tree> in an 18.0 answer). No Odoo documentation text, no Odoo
Enterprise code (OEEL-1/OPL-1 modules are skipped) and no proprietary/company code was used.
Odoo Community is LGPL-3.
Task types: XPath view inheritance, view syntax (conditional invisible/readonly, list, kanban, state
buttons), ORM (method overrides, display name, aggregation, constraints, users by group), access rights
and record rules, cron, actions, QWeb, manifest, and view migration between versions.
Evaluation
The eval models (sale.order, res.partner, account.move, …, 9 in total) are excluded from training,
and no training question matches an eval question. Scores are 0–1 automatic grading (XML/Python/XPath
checks, version-specific forbidden syntax), same Q4_K_M quantisation for both models, --verify off.
Model alone (no retrieval):
Table with columns: Set, n, Qwen2.5-Coder-14B, + this LoRA| Set | n | Qwen2.5-Coder-14B | + this LoRA |
|---|
| Holdout, 14.0 | 30 | 0.864 | 0.963 |
| 15.0 | 30 | 0.850 | 0.975 |
| 16.0 | 31 | 0.754 | 0.960 |
| 17.0 | 60 | 0.776 | 0.833 |
| 18.0 | 63 | 0.774 | 0.842 |
| 19.0 | 41 | 0.794 | 0.951 |
| 20.0 | 36 | 0.799 | 0.936 |
| Hand-written, task types not in training data | 49 | 0.867 | 0.891 |
| All | 340 | 0.806 | 0.904 |
Inside a RAG system (version-filtered retrieval over Odoo source + a per-version rules prompt):
the LoRA gives no gain — 0.883 base vs 0.874 with LoRA over the same 340 items (hand-written 0.912
vs 0.898). The holdout is mostly generated and shares question shapes with the training data (different models and
fields), so its gains are an upper bound; the 49 hand-written items are the honest measure of
generalisation.
Limitations
- Answers are short and template-like (code + ≤ 3 bullets).
- Observed failure modes: occasionally swaps the anchor and the new field in
<field name="…" position="before"> blocks, or wraps an inheritance patch in a <tree> root,
especially when long retrieved context is in the prompt.
- Odoo 17.0/18.0 gains are the smallest; those were the most-covered versions in the base model.
- Not a substitute for testing the module in a real Odoo instance.
License
Apache-2.0, same as the base model Qwen2.5-Coder-14B-Instruct.
The training data was generated from facts (model, field and view names) in the Odoo Community
source code (LGPL-3); no Odoo source files are redistributed here.