원클릭으로
creating-models
Step-by-step guide to create a new Odoo model with fields, constraints, and methods.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Step-by-step guide to create a new Odoo model with fields, constraints, and methods.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Create automated actions (base.automation) and server actions in Odoo.
Create HTTP controllers and API endpoints in Odoo.
Create custom OWL (Odoo Web Library) frontend components.
Create QWeb PDF reports and report actions in Odoo.
Set up access rights (ACLs) and record rules for Odoo models.
Write Python and JavaScript tests for Odoo modules.
| name | Creating Models |
| description | Step-by-step guide to create a new Odoo model with fields, constraints, and methods. |
| globs | ["models/**/*.py","__manifest__.py"] |
Create the Python file in models/ directory (e.g. models/my_model.py).
Define the model class:
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class MyModel(models.Model):
_name = 'my.model'
_description = 'My Model'
_order = 'sequence, name'
name = fields.Char(string='Name', required=True)
sequence = fields.Integer(default=10)
active = fields.Boolean(default=True)
state = fields.Selection([
('draft', 'Draft'),
('confirmed', 'Confirmed'),
('done', 'Done'),
], default='draft', string='Status', tracking=True)
partner_id = fields.Many2one('res.partner', string='Partner')
line_ids = fields.One2many('my.model.line', 'model_id', string='Lines')
tag_ids = fields.Many2many('my.model.tag', string='Tags')
total = fields.Float(compute='_compute_total', store=True)
@api.depends('line_ids.amount')
def _compute_total(self):
for record in self:
record.total = sum(record.line_ids.mapped('amount'))
@api.constrains('name')
def _check_name(self):
for record in self:
if record.name and len(record.name) < 3:
raise ValidationError(_("Name must be at least 3 characters."))
def action_confirm(self):
self.write({'state': 'confirmed'})
Register in __init__.py: Add from . import my_model in models/__init__.py.
Add to manifest: Ensure models/ is imported in the module's root __init__.py.
Add security: Create ACL in security/ir.model.access.csv.
Create views: Add form and list views in views/my_model_views.xml.
_name and _description set@api.depends@api.constrains__init__.py chainir.model.access.csv__manifest__.py data list