Beispiel #1
0
    def edit_user(self, device):
        """
                Function uses to get attendances
                """
        ip_address = self.device_id.ip_address
        port = self.device_id.port
        device_password = self.device_id.device_password

        if self.device_id.id is False:
            raise exceptions.Warning("No ha seleccionado Lector Biometrico")

        with c.ConnectToDevice(ip_address, port, device_password) as conn:

            try:
                conn.set_user(uid=self.device_user_id,
                              name=self.name,
                              privilege=const.USER_DEFAULT,
                              user_id=str(self.device_user_id))
                return {
                    "type": "ir.actions.act_window",
                    "res_model": "device.users",
                    "views": [[False, "form"]],
                    "res_id": self.id,
                    "target": "main",
                    "context": {
                        'show_message3': True
                    },
                }

            except Exception as e:
                raise exceptions.Warning(
                    "El usuario no existe en el Lector Biometrico")
Beispiel #2
0
    def create_user(self, device):
        """
                Function uses to get attendances
                """
        ip_address = self.device_id.ip_address
        port = self.device_id.port
        device_password = self.device_id.device_password
        user_id = str(self.device_user_id)

        with c.ConnectToDevice(ip_address, port, device_password) as conn:

            device_users = conn.get_users()
            device_user_ids = [int(x.user_id) for x in device_users]
            if self.device_user_id not in device_user_ids:
                conn.set_user(uid=self.device_user_id, name=self.name, privilege=const.USER_DEFAULT, user_id=user_id)
                self.device_uid = self.device_user_id
                return {
                    "type": "ir.actions.act_window",
                    "res_model": "device.users",
                    "views": [[False, "form"]],
                    "res_id": self.id,
                    "target": "main",
                    "context": {'show_message1': True},
                }

            else:
                return {
                    "type": "ir.actions.act_window",
                    "res_model": "device.users",
                    "views": [[False, "form"]],
                    "res_id": self.id,
                    "target": "main",
                    "context": {'show_message2': True},
                }
Beispiel #3
0
 def test_connection(self):
     with c.ConnectToDevice(self.ip_address, self.port,
                            self.device_password) as conn:
         if conn:
             return {
                 "type": "ir.actions.act_window",
                 "res_model": "devices",
                 "views": [[False, "form"]],
                 "res_id": self.id,
                 "target": "main",
                 "context": {
                     'show_message1': True
                 },
             }
Beispiel #4
0
    def delete_attendance(self):

        with c.ConnectToDevice(self.device_id.ip_address, self.device_id.port,
                               self.device_id.device_password) as conn:
            conn.clear_attendance()
            raise exceptions.Warning('Attendances deleted successfully')