Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use Computed fields in openERP/Odoo ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.02k
    Comment on it

    If you want to Computed fields in OpenERP(Odoo) follow the below mentioned code and paste it in your (Python).py file:

    upper = fields.Char(compute='_compute_upper',
                        inverse='_inverse_upper',
                        search='_search_upper')
    
    @api.depends('name')
    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 [('name', operator, value)]
    Note- Above code are compute, inverse and search are model methods.

    Hope this will help you :)

 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: