Browse Source

[ADD] b_shift : attendance sheets barcode scanner support

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
6b4f4b1495
  1. 3
      beesdoo_shift/__openerp__.py
  2. 7
      beesdoo_shift/models/attendance_sheet.py
  3. 35
      beesdoo_shift/static/src/js/barcode_scanner_focus.js
  4. 13
      beesdoo_shift/views/attendance_sheet.xml
  5. 10
      beesdoo_shift/views/beesdoo_shift_assets.xml

3
beesdoo_shift/__openerp__.py

@ -15,7 +15,7 @@
'category': 'Cooperative management',
'version': '9.0.1.3.0',
'depends': ['beesdoo_base'],
'depends': ['beesdoo_base', 'barcodes'],
'data': [
"data/system_parameter.xml",
@ -23,6 +23,7 @@
"data/mail_template.xml",
"security/group.xml",
"security/ir.model.access.csv",
"views/beesdoo_shift_assets.xml",
"views/task_template.xml",
"views/res_config_view.xml",
"views/task.xml",

7
beesdoo_shift/models/attendance_sheet.py

@ -154,7 +154,7 @@ class AttendanceSheetShiftAdded(models.Model):
class AttendanceSheet(models.Model):
_name = "beesdoo.shift.sheet"
_inherit = ["mail.thread", "ir.needaction_mixin"]
_inherit = ["mail.thread", "ir.needaction_mixin", "barcodes.barcode_events_mixin"]
_description = "Attendance sheets with all the shifts in one time range."
_order = "start_time"
@ -481,3 +481,8 @@ class AttendanceSheet(models.Model):
"view_mode": "form",
"target": "new",
}
def on_barcode_scanned(self, barcode):
import pdb; pdb.set_trace()
worker = self.env["res.partner"].search([("barcode","=",barcode)])
self.name = barcode

35
beesdoo_shift/static/src/js/barcode_scanner_focus.js

@ -0,0 +1,35 @@
odoo.define('beesdoo_shift.barcode_scanner_focus', function (require) {
"use strict";
var core = require('web.core');
var FormViewBarcodeHandler = require('barcodes.FormViewBarcodeHandler');
var BarcodeHandlerUnfocus = FormViewBarcodeHandler.extend({
_set_quantity_listener: function(event) {
console.log("TEST");
this.super();
},
// Method is not called when a field is focus.
on_barcode_scanned: function(barcode) {
console.log("method called");
this._super(barcode);
}
});
core.form_widget_registry.add('barcode_handler_unfocus', BarcodeHandlerUnfocus);
return BarcodeHandlerUnfocus;
/*
var Widget = require('web.Widget');
var BarcodeHandlerUnfocus = Widget.extend({
events: {
'click .oe_stat_button': 'function_test',
}
function_test: function (){
console.log("test handler")
});
});
core.form_widget_registry.add('barcode_handler_unfocus', BarcodeHandlerUnfocus);
return BarcodeHandlerUnfocus;*/
});

13
beesdoo_shift/views/attendance_sheet.xml

@ -68,6 +68,7 @@
<field name="model">beesdoo.shift.sheet</field>
<field name="arch" type="xml">
<form create="false" delete="false">
<header>
<field name="state" widget="statusbar" readonly="True" />
<button type="object"
@ -91,7 +92,7 @@
</button>
</div>
<div class="oe_title">
<h1><field name="name" /></h1>
<h1><field name="name"/></h1>
</div>
<group>
<field name="max_worker_nb" />
@ -100,19 +101,19 @@
<group>
<field name="expected_worker_nb" />
</group>
<field name="expected_shift_ids" />
<field name="expected_shift_ids"/>
<h2> Added workers </h2>
<group>
<field name="added_worker_nb" />
</group>
<field name="added_shift_ids" />
<h4> Additional important informations </h4>
<field name="annotation" />
<field name="annotation" barcode_events="true"/>
<h4> General feedback </h4>
<field name="feedback" />
<group>
<field name="worker_nb_feedback"/>
</group>
<field name="worker_nb_feedback" >
<field name="_barcode_scanned" widget="barcode_handler"/>
</field>
<group>
<field name="validated_by" readonly="True" />
</group>

10
beesdoo_shift/views/beesdoo_shift_assets.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="assets_backend" name="account assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/beesdoo_shift/static/src/js/barcode_scanner_focus.js"></script>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save