Here a way to develop OpenERP
class stock_incoterms(osv.osv):
_name = "stock.incoterms"
_description = "Incoterms"
_columns = {
'name': fields.char('Name', size=64, required=True),
'code': fields.char('Code', size=3, required=True),
'active': fields.boolean('Active'),
}
_defaults = {
'active': lambda *a: True,
}
stock_incoterms()
This is typical OpenERP model and map to table name stock_incoterms.
The columns property defines columns for the table
The default property defines default value for each column.
My questions are:
How to implement this in Python?
When running stock_incoterms(), OpenERP will read this model, generate the table with these defined columns.
After that, suppose I created a record in this table, then I ask give me the model of this class, ex
stock_incoterm = stock_incoterms.get(1) ( record id in db)
Now i can access
stock_incoterm.name
stock_incoterm.code
........
This way of defining model is kind of Meta Programming but I don't know how to write it in Python.
Could anyone guide me the details behind or some good links about meta programming in Python?