Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Waht is a functional field and how to calculate it's value

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 528
    Comment on it

    A functional field is a field whose value is calculated by a function in openerp, hence in openerp functional fields values is calculated by the function and its process of function given below, Parameters:

    fnct, 
    arg=None, 
    fnct_inv=None, 
    fnct_search=None, obj=None, method=False, store=True 
    fnct_inv_arg=None, 
    type=%green%float%black%, 
    

    where
    Type is the field type name returned by the function. It can be any field type name except function.
    store- If you want to store field in database or not. Default is False.
    method whether the field is computed by a method (of an object) or a global function
    function is the function or method that will compute the field value. It must have been declared before declaring the functional field.

    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() 
    If we want to add a field that retrieves the function of an employee by looking its current contract, we use a functional 
    field. The object hr_employee is inherited this way: 
    class hr_employee(osv.osv): 
    _name = "hr.employee" 
    _description = "Employee" 
    _inherit = "hr. employee" 
    _columns = { contract_ids : fields.one2many(hr.contract, employee_id, Contracts), 
    function : fields.function(_get_cur_function_id, type=many2one, obj="res.partner.functio 
    method=True, string=Contract Function), 
    } 
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: