over 10 years ago
Openerp contain different types of fields and these Fields are divided into three different categories, they are simple fields, relation fields and functional fields.
So lets discuss this one by one-
1. Simple Fields- The simple types are integers, floats, booleans, strings, etc.
2. relation fields- The relations between different objects (i.e- one2one, one2many, many2one) are represented by relation field.
3. Functional fields- These fields are special fields because they are not stored in the database but calculated in real time by given other fields of the view.
- def __init__(self, string=unknown, required=False, readonly=False,
- domain=[], context="", states={}, priority=0, change_default=False, size=None,
- ondelete="setnull", translate=False, select=False, **args) :
def __init__(self, string=unknown, required=False, readonly=False, domain=[], context="", states={}, priority=0, change_default=False, size=None, ondelete="setnull", translate=False, select=False, **args) :
-> 1-Basic Types/ Simple Fields
boolean
Syntax:
integer
float
char
2-Relational Types
3-Functional Field
A functional field is a field whose value is calculated by a function or in other words we can say that it is the field which is called by function and attribute.
If method is True, the signature of the method must be:
def fnct(self, cr, uid, ids, field_name, arg, context)
Example Of Functional Field-
Suppose we create a contract object which is :
- class hr_contract(osv.osv):
- _name = hr.contract
- _description = Contract
- _columns = {
- name : fields.char(Contract Name, size=30, required=True),
- employee_id : fields.many2one(hr.employee, Employee, required=True),
- function : fields.many2one(res.partner.function, Function),
- }
- hr_contract()
class hr_contract(osv.osv): _name = hr.contract _description = Contract _columns = { name : fields.char(Contract Name, size=30, required=True), employee_id : fields.many2one(hr.employee, Employee, required=True), function : fields.many2one(res.partner.function, Function), } hr_contract()
0 Comment(s)