Skip to content
Permalink
Browse files

⚡️ hex option in base.config.settings

  • Loading branch information...
KolushovAlexandr committed Mar 14, 2019
1 parent ca583ca commit 4cd758beb92a03531f1dcb9cf003e91ec7692428
@@ -2,7 +2,7 @@
-------

- **New:** Autocheckout option - closes shifts after defined time
- **New:** HEX barcode scanners support for **Kiosk Mode**
- **New:** Option to suppert HEX barcode scanners in **Kiosk Mode**
- **Fix:** Error related to incorrect attribute name

`1.0.0`
@@ -15,10 +15,13 @@ class BaseConfigSettings(models.TransientModel):
help='Enable or disable partner PIN identification at check in',
implied_group="base_attendance.group_hr_attendance_use_pin")
shift_autocheckout = fields.Integer('Autocheckout ', help="Maximum Shift Time in Minutes")
hex_scanner_is_used = fields.Boolean('HEX Scanner', default=False,
help='Some devices scan regular barcodes as hexadecimal. '
'This option decode those types of barcodes')

@api.multi
def set_shift_autocheckout(self):
self.env["ir.config_parameter"].set_param("base_attendance.shift_autocheckout", self.shift_autocheckout)
self.env["ir.config_parameter"].set_param("base_attendance.shift_autocheckout", self.shift_autocheckout or '0')
self.checkout_shifts()

@api.multi
@@ -37,3 +40,13 @@ def checkout_shifts(self):
cron_record.write({
'active': True,
})

@api.multi
def set_hex_scanner_is_used(self):
self.env["ir.config_parameter"].set_param("base_attendance.hex_scanner_is_used", self.hex_scanner_is_used)

@api.multi
def get_default_hex_scanner_is_used(self, fields):
hex_scanner_is_used = self.env["ir.config_parameter"].get_param("base_attendance.hex_scanner_is_used",
default=False)
return {'hex_scanner_is_used': hex_scanner_is_used}
@@ -8,6 +8,7 @@ var core = require('web.core');
var Model = require('web.Model');
var Widget = require('web.Widget');
var Session = require('web.session');
var local_storage = require('web.local_storage');
var BarcodeHandlerMixin = require('barcodes.BarcodeHandlerMixin');

var QWeb = core.qweb;
@@ -27,9 +28,27 @@ var KioskMode = Widget.extend(BarcodeHandlerMixin, {
// We added a local variable for this._super in order to fix the nextLINT error
//"Expected an assignment or function call and instead saw an expression. [Error/no-unused-expressions]"
var init_super = this._super;

action.target = 'fullscreen'
var hex_scanner_is_used = action.context.hex_scanner_is_used;
if (typeof hex_scanner_is_used !== 'undefined') {
this.save_locally('hex_scanner_is_used', Boolean(hex_scanner_is_used));
} else {
hex_scanner_is_used = this.get_from_storage('hex_scanner_is_used') || false;
}
this.hex_scanner_is_used = hex_scanner_is_used;

BarcodeHandlerMixin.init.apply(this, arguments);
},

save_locally: function(key, value) {
local_storage.setItem('est.' + key, JSON.stringify(value));
},

get_from_storage: function(key) {
return JSON.parse(local_storage.getItem('est.' + key));
},

start: function () {
var self = this;
self.session = Session;
@@ -49,21 +68,18 @@ var KioskMode = Widget.extend(BarcodeHandlerMixin, {
on_barcode_scanned: function(barcode) {
var self = this;
var hr_employee = new Model('res.partner');
hr_employee.call('attendance_scan', [barcode, ]).then(function (result) {
var res_barcode = barcode;
if (this.hex_scanner_is_used) {
var res_barcode = parseInt(barcode, 16).toString();
if (res_barcode.length % 2) {
res_barcode = '0' + res_barcode;
}
}
hr_employee.call('attendance_scan', [res_barcode, ]).then(function (result) {
if (result.action) {
self.do_action(result.action);
} else if (result.warning) {
var unhexed_code = parseInt(barcode, 16).toString();
if (unhexed_code.length % 2) {
unhexed_code = '0' + unhexed_code;
}
hr_employee.call('attendance_scan', [unhexed_code, ]).then(function (res) {
if (res.action) {
self.do_action(res.action);
} else if (res.warning) {
self.do_warn(result.warning);
}
});
self.do_warn(result.warning);
}
});
},
@@ -113,10 +113,21 @@
<field name="view_id"></field> <!-- force empty -->
</record>

<record id="hr_attendance_action_kiosk_mode" model="ir.actions.client">
<field name="name">Attendances</field>
<field name="tag">base_attendance_kiosk_mode</field>
<field name="target">fullscreen</field>
<record model="ir.actions.server" id="hr_attendance_action_kiosk_mode">
<field name="name">Get to the Kiosk Mode</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_res_partner_attendance"/>
<field name="code">
hex_scanner_is_used = model.env["ir.config_parameter"].get_param("base_attendance.hex_scanner_is_used",default=False)
action = {
'type': 'ir.actions.client',
'tag': 'base_attendance_kiosk_mode',
'target': 'fullscreen',
'context': {
'hex_scanner_is_used': hex_scanner_is_used
},
}
</field>
</record>

<record id="hr_attendance_action_greeting_message" model="ir.actions.client">
@@ -14,6 +14,7 @@
<button string="Cancel" type="object" name="cancel" class="oe_link" special="cancel"/>
</header>
<group string="Settings">
<field name="hex_scanner_is_used"/>
<field name="group_attendance_use_pin" widget="radio"/>
<field name="shift_autocheckout"/>
</group>

0 comments on commit 4cd758b

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.