Opening duplicate POS

version 13: the user can open more than one POS Opening Entry.

I want the user can’t open a POS Opening Entry because has POS is Open.
I’m a beginner, and you want the best solution.

doesn’t work:
frappe.ui.form.on(‘POS Opening Entry’, {
validate: function(frm) {
if (frappe.db.exists(‘POS Opening Entry’, {‘status’: ‘Open’,‘cashier’: doc.cashier})){
msgprint(‘POS is Opening’);
validated = false;