def save_is_scanner(self, is_scanner): """Save the type of device. We need that in order to keep the selected type of device after a reboot. """ file_path = Path.home() / 'odoo-keyboard-is-scanner.conf' if file_path.exists(): data = json.loads(file_path.read_text()) else: data = {} data[self.device_identifier] = is_scanner helpers.write_file('odoo-keyboard-is-scanner.conf', json.dumps(data)) self._set_device_type('scanner') if is_scanner.get('is_scanner') else self._set_device_type()
def save_layout(self, layout): """Save the layout to a file on the box to read it when restarting it. We need that in order to keep the selected layout after a reboot. Args: new_layout (dict): A dict containing two keys: - layout (str): The layout code - variant (str): An optional key to represent the variant of the selected layout """ file_path = Path.home() / 'odoo-keyboard-layouts.conf' if file_path.exists(): data = json.loads(file_path.read_text()) else: data = {} data[self.device_identifier] = layout helpers.write_file('odoo-keyboard-layouts.conf', json.dumps(data))
def add_six_payment_terminal(self, terminal_id): helpers.write_file('odoo-six-payment-terminal.conf', terminal_id) subprocess.check_call(["sudo", "service", "odoo", "restart"]) return 'http://' + helpers.get_ip() + ':8069'