Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Computed fields in Odoo-9

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 898
    Comment on it

    The reason of computed fields is been used is because it defines a filed whose value is computed rather then simply being read from the database.
    Below are the attributes that are specific to computed fields. To define such a field, simply provide a value for the attribute compute and records value. For example you can seen the below code.

    1. upper = fields.Char(compute='_compute_upper',
    2. inverse='_inverse_upper',
    3. search='_search_upper')
    4.  
    5. @api.depends('Demo')
    6. def _compute_upper(self):
    7. for rec in self:
    8. rec.upper = rec.name.upper() if rec.name else False
    9.  
    10. def _inverse_upper(self):
    11. for rec in self:
    12. rec.name = rec.upper.lower() if rec.upper else False
    13.  
    14. def _search_upper(self, operator, value):
    15. if operator == 'like':
    16. operator = 'ilike'
    17. return [('Demo', operator, value)]
    18. self.pname = self.partner_id.name

    Note- Acomputed field is not stored to the database.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: