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
    • 846
    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.

     upper = fields.Char(compute='_compute_upper',
                        inverse='_inverse_upper',
                        search='_search_upper')
    
    @api.depends('Demo')
    def _compute_upper(self):
        for rec in self:
            rec.upper = rec.name.upper() if rec.name else False
    
    def _inverse_upper(self):
        for rec in self:
            rec.name = rec.upper.lower() if rec.upper else False
    
    def _search_upper(self, operator, value):
        if operator == 'like':
            operator = 'ilike'
        return [('Demo', operator, value)]
         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
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: