Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Add the Python function in odoo-9

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 684
    Comment on it

    Here is just one thing to do: create the Python function which is called by the automated action. The Python function process_demo_check_queue will automatically create and update the value called by automated action.
    So let us create this in the Python file that uses the model check.demo in own module in openerp-9

    class check_demo(models.Model):
        _name = 'check.demo'
        name = fields.Char(required=True)
        numberOfUpdates = fields.Integer('Number of updates', help='The number of times the check has run and updated this field')
        lastModified = fields.Date('Last updated')
    
        #This function is called when the check goes off
        def process_demo_check_queue(self, cr, uid, context=None):
           def process_demo_check_queue(self, cr, uid, context=None):
    check_line_obj = self.pool.get('check.demo')
    #Contains all ids for the model check.demo
       check_line_ids = self.pool.get('check.demo').search(cr, uid, [])   
    #Loops over every record in the model check.demo
            for check_line_id in check_line_ids :
        #Contains all details from the record in the variable check_line
                check_line =check_line_obj.browse(cr, uid,check_line_id ,context=context)
        numberOfUpdates = check_line.numberOfUpdates
        #Prints out the name of every record.
                _logger.info('line: ' + check_line.name)
        #Update the record
        check_line_obj.write(cr, uid, check_line_id, {'numberOfUpdates': (numberOfUpdates +1), 'lastModified': datetime.date.today()}, context=context)
    

 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: