示例#1
0
    def execute(self, cr, uid, ids, context=None):
        """
        Sorts IDs by their sequence, then find an appropriate lx_data child class based on 
        the update.object_type, instantiate it and call process.
        Then set state to executed, or catch errors and set as failed.
        """
        updates = self.read(cr, uid, ids, ['sequence'], context=context)
        updates.sort(key=lambda update: int(update['sequence']))
        for update in updates:
            update = self.browse(cr, uid, update['id'], context=context)

            if update.state == 'executed':
                continue

            # do execution
            try:
                # find appropriate lx_data class, instantiate it, and trigger process
                cls = get_lx_data_subclass(update.object_type)
                data = cls(json.loads(update.data))
                data.process(self.pool, cr)

                # change state
                update.write({'state': 'executed'})

                # trigger update.file state check
                update.file_received_id.check_still_waiting()

            except Exception, e:
                result = 'Error while executing: %s' % unicode(e)
                update.write({'state': 'failed', 'result': result})
示例#2
0
 def execute(self, cr, uid, ids, context=None):
     """
     Sorts IDs by their sequence, then find an appropriate lx_data child class based on 
     the update.object_type, instantiate it and call process.
     Then set state to executed, or catch errors and set as failed.
     """
     updates = self.read(cr, uid, ids, ['sequence'], context=context)
     updates.sort(key=lambda update: int(update['sequence']))
     for update in updates:
         update = self.browse(cr, uid, update['id'], context=context)
         
         if update.state == 'executed':
             continue
         
         # do execution
         try:
             # find appropriate lx_data class, instantiate it, and trigger process
             data = json.loads(update.data)
             lx_cls = get_lx_data_subclass(update.object_type)
             cls = lx_cls(data)
             cls.process(self.pool, cr, data)
         
             # change state
             update.write({'state': 'executed'})
             
             # trigger update.file state check
             update.file_incoming_id.check_still_waiting()
             
         except Exception, e:
             result = 'Error while executing: %s' % unicode(e)
             update.write({'state': 'failed', 'result': result})
示例#3
0
 def reorganise_data(self, cr, uid, data, header, namespace, object_type, context=None):
     """ Calls reorganise_data on the appropriate lx_data subclass """
     cls = get_lx_data_subclass(object_type)
     return cls.reorganise_data(data, header, namespace)
示例#4
0
 def get_data_for_updates(self, cr, uid, data, header, namespace, object_type, context=None):
     """ Calls get_data_for_updates on the appropriate lx_data subclass """
     cls = get_lx_data_subclass(object_type)
     return cls.get_data_for_updates(data, header, namespace)