SmartERP Documentation An Ashewa Technology Solutions Platform

Odoo 19 ORM Modeling and Database Field Types

Defining data models, relational fields (Many2one, One2many, Many2many), computed attributes, stored indexes, and SQL constraints.

1. Overview & Business Value#

This comprehensive operational guide details the architecture, business workflows, configuration parameters, and execution steps for Odoo 19 ORM Modeling and Database Field Types within SmartERP.

The Odoo 19 Object-Relational Mapping (ORM) engine abstracts PostgreSQL database tables into declarative Python classes with automated schema migrations.

Defining an ORM Model#

from odoo import models, fields, api
from odoo.exceptions import ValidationError

class EnterpriseAsset(models.Model):
    _name = 'smarterp.enterprise.asset'
    _description = 'Enterprise Capital Asset'
    _order = 'name asc'

    name = fields.Char(string='Asset Tag', required=True, index=True)
    cost = fields.Monetary(string='Acquisition Cost', required=True, currency_field='currency_id')
    currency_id = fields.Many2one('res.currency', string='Currency', default=lambda self: self.env.company.currency_id)
    company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.company, required=True)

{screenshot:orm-modeling-and-field-types-overview-dashboard}

2. Prerequisites & Security Access Groups#

  • Required Modules: base, web, smarterp_core
  • Security Groups:
    • Enterprise Developer (Technical ID: base.group_no_one)
    • System Administrator (Technical ID: base.group_system)
  • Master Data Dependencies: Established local development toolchain (Python 3.12+, PostgreSQL 16), cloned repository (smarterp-platform), and valid database configuration.

3. Step-by-Step Configuration & Execution#

Step 1: Navigating to the Module Interface#

  1. Open your terminal or development environment in the repository root (/Users/danielbekele/smarterp-platform).
  2. Activate your dedicated Python virtual environment.
  3. Verify Git branch status: git status.

{screenshot:orm-modeling-and-field-types-app-switcher-navigation}

Step 2: Creating and Parameterizing Records#

  1. Execute development commands or scaffolding templates.
  2. Define mandatory manifest parameters:
    • name (Mandatory): Descriptive module title.
    • version (Mandatory): Standard semantic versioning (e.g. 19.0.1.0.0).
    • depends (Mandatory): Explicit list of upstream module dependencies.
    • license (Mandatory): Open source or proprietary enterprise license identifier.
  3. Configure optional parameters: data files, security ACLs, and automated test cases.

{screenshot:orm-modeling-and-field-types-record-creation-form}

Step 3: Validating and Processing Transactions#

  • Execution & Testing: Run unit tests via odoo-bin -i <module_name> --test-enable --stop-after-init.
  • Quality Verification: Ensure test suite passes with zero errors and zero unhandled warnings.

{screenshot:orm-modeling-and-field-types-transaction-processing-state}

4. Advanced Configuration Points#

  • Automated Actions & Scheduled Tasks (Crons):
    • Developer: Module test runner trigger (base.ir_cron_run_tests)
    • System: Automated cache cleanup (base.ir_cron_cache_cleanup)
  • Custom Print Templates & Reports:
    • Technical Data Dictionary Specification
    • Code Quality & Test Coverage Dossier
  • Multi-Company Rules: Record-level security isolation under Company 1 (Ashewa Technology Solutions S.C.).

5. Comprehensive Troubleshooting Matrix#

Error Symptom / ExceptionProbable Root CauseCorrective Action / Resolution
ImportError: cannot import name from odooOutdated virtualenv or PYTHONPATH misconfiguration.Re-activate virtualenv and verify that Odoo 19 libraries are correctly installed.
ParseError: Element '<tree>' is deprecatedAttempting to use legacy Odoo tree view syntax in Odoo 19.Replace <tree> with <list> in the view XML definition.
ValidationError: External ID not foundManifest data list contains an item before its prerequisite is loaded.Re-order XML filenames in __manifest__.py so security and parent menus load first.
Last updated: 2026-10-30