DEV Community

Cover image for How to Validate ERP Software Consultants' Field Mappings with Python
Sanya Mittal
Sanya Mittal

Posted on

How to Validate ERP Software Consultants' Field Mappings with Python

A migration job dies on a required field that never appeared in the mapping sheet. The sheet came from your ERP software consultants, it looked complete, and nobody compared it with the live schema. This happens during data migration and integration builds, when a spreadsheet becomes the contract between analysts and engineers. This post turns that spreadsheet into a testable artifact that a pipeline can reject. We cover how ERP software consultants hand off specs in custom ERP builds, then a short Python check against an Odoo sandbox, then CI gating so a bad spec fails the build before release.

Context and Setup

A field mapping spec is trustworthy only if a machine can verify it. Our scenario: consultants deliver a CSV with model, field, and source_type columns, and you hold a sandbox of the target ERP. You need Python 3.10 or newer and a read-only API key. Odoo's XML-RPC API exposes schema metadata through fields_get, and other platforms have equivalents, such as OData $metadata on Dynamics 365.

ERP software consultants Panorama Consulting Group's 2024 ERP Report found that 35 percent of respondents blamed budget overruns on data issues. A mapping error found in a sandbox costs minutes; mid-migration it costs a cutover window.
informatica

Auditing ERP Software Consultants' Mappings in Three Steps

Three steps: get a parseable spec, diff it against the live schema, and fail the build on gaps.

Step 1: Ask ERP Software Consultants for a Machine-Readable Spec

Ask for CSV, not prose, since labels change between versions while technical names stay stable. Require one row per target field:

model: the technical model name, such as res.partner
field: the technical field name, not the UI label
source_type: string, integer, decimal, or date

Step 2: Compare the Spec with the Live Schema

ERP software consultants check calls fields_get once per model and flags missing fields, read-only targets, and type mismatches.

python
import csv
import xmlrpc.client

URL, DB, USER, KEY = "https://erp-sandbox.example.com", "sandbox", "audit@example.com", "API_KEY"
uid = xmlrpc.client.ServerProxy(f"{URL}/xmlrpc/2/common").authenticate(DB, USER, KEY, {}) # Why: API keys avoid stored passwords
models = xmlrpc.client.ServerProxy(f"{URL}/xmlrpc/2/object")

Odoo field types that can accept each spec type

COMPAT = {"string": {"char", "text", "selection"}, "integer": {"integer", "many2one"},
"decimal": {"float", "monetary"}, "date": {"date", "datetime"}}

def live_schema(model):
# Why: fields_get returns the real schema, including custom fields added after install
return models.execute_kw(DB, uid, KEY, model, "fields_get", [],
{"attributes": ["type", "required", "readonly"]})

def audit(rows):
problems, schemas = [], {}
for r in rows:
m, name = r["model"], r["field"]
schemas.setdefault(m, live_schema(m)) # Why: one API call per model, not per row
spec = schemas[m].get(name)
if spec is None:
problems.append(f"MISSING {m}.{name}")
elif spec["readonly"]: # Why: read-only usually means computed, so loading it needs a design call
problems.append(f"READONLY {m}.{name}")
elif spec["type"] not in COMPAT[r["source_type"]]:
problems.append(f"TYPE {m}.{name}: {r['source_type']} vs {spec['type']}")
return problems, schemas

Step 3: Cover Required Fields and Gate the Build

Spreadsheets hide missing required fields best, so check in reverse: start from the schema.

python
def unmapped_required(rows, schemas):
mapped = {(r["model"], r["field"]) for r in rows}
gaps = []
for model, schema in schemas.items():
required = [n for n, s in schema.items() if s["required"] and not s["readonly"]]
defaults = models.execute_kw(DB, uid, KEY, model, "default_get", [required])
# Why: a field with a default value does not need a mapping row
gaps += [f"UNMAPPED {model}.{n}" for n in required
if n not in defaults and (model, n) not in mapped]
return gaps

rows = list(csv.DictReader(open("mapping.csv")))
problems, schemas = audit(rows)
problems += unmapped_required(rows, schemas)
print("\n".join(problems) or "mapping OK")
raise SystemExit(1 if problems else 0) # Why: a non-zero exit fails the CI job

Trade-offs: this check is structural and cannot validate values or relations. A dry-run import on seeded data catches those, but it needs fixtures and runs slower. Run the structural check on every spec change and nightly, because a new custom module can invalidate an approved spec.

Real-World Application

In one of our ERP projects at Oodles, a Shanghai-based logistics provider needed a single open-source ERP for inventory, order processing, and real-time tracking.

Key Takeaways
Call fields_get once per model and cache it to keep API calls low.
Map technical field names, never UI labels.
Audit both directions: spec to schema for typos, schema to spec for unmapped required fields.
Exit non-zero on any finding so the pipeline, not a reviewer, blocks a bad spec.

Questions about adapting this to another ERP? Drop them in the comments, or reach out to ERP software consultants at Oodles for a deeper review.

What do ERP software consultants deliver that developers should verify?
ERP software consultants typically deliver requirement documents, process maps, and field mapping sheets. Verify the mapping sheet first, because every migration job reads it. Parse it as CSV and compare it with the live schema before any build starts.

How do I get field metadata from Odoo?
Call fields_get on a model through XML-RPC or JSON-RPC. It returns each field's type, required flag, relation, and readonly status. Pass an attributes list to limit the payload, and cache results per model.

Does this work on ERPs other than Odoo?
The pattern works wherever the platform exposes schema metadata through an API. Dynamics 365 and Business Central publish OData $metadata. Only the schema-fetch function changes; the comparison logic stays the same across platforms.

Can a structural check replace a test migration?
No. A structural check catches missing fields, type mismatches, and unmapped required fields, but not bad values, duplicates, or broken relations. Pair it with a dry-run import on seeded data before cutover.

How often should I rerun the mapping audit?
Run it on every change to the mapping file and nightly against the sandbox. Nightly runs catch schema drift from new custom modules or upgrades, which can invalidate an approved spec.

Top comments (0)