Search code examples
pythonodooodoo-8odoo-9

ODOO : How to get current state of record object?


There are multiple states added like this:

'state':fields.selection([('new', 'New'), ('assigned','Assigneed'), ('in_progress', 'In Progress'),('resolved','Resolved'),('rejected','Rejected'),('closed','Closed')], 'Status')

I need to compare the current state of a record object to take appropriate actions.

Is there a method to get the current state of the record object?


Solution

  • An environment wraps data for ORM records:

    • 'cr', the current database cursor.

    • 'uid', the current user id.

    • 'context', the current context dictionary.

    In new API, self will represent/store current/class level information.

    self.state will give you current state of record. You can use in any ORM method or function/computed fields as well.

    For more about ORM reference