Skip to content

Commit 4cee446

Browse files
🎉1️⃣2️⃣ pos_clientlist_scan_button
1 parent e01d0bc commit 4cee446

File tree

10 files changed

+225
-12
lines changed

10 files changed

+225
-12
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.. image:: https://img.shields.io/badge/license-LGPL--3-blue.png
2+
:target: https://www.gnu.org/licenses/lgpl
3+
:alt: License: LGPL-3
4+
5+
============================
6+
Pos Clientlist Scan Button
7+
============================
8+
9+
Adds scan button for some fields on clientlist screen
10+
11+
Adds scan button for some fields on clientlist screen
12+
13+
Credits
14+
=======
15+
16+
Contributors
17+
------------
18+
* `Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>`__:
19+
20+
* :one::zero: init version of the module
21+
22+
Sponsors
23+
--------
24+
* `IT-Projects LLC <https://it-projects.info>`__
25+
26+
Maintainers
27+
-----------
28+
* `IT-Projects LLC <https://it-projects.info>`__
29+
30+
To get a guaranteed support
31+
you are kindly requested to purchase the module
32+
at `odoo apps store <https://apps.odoo.com/apps/modules/12.0/pos_clientlist_scan_button/>`__.
33+
34+
Thank you for understanding!
35+
36+
`IT-Projects Team <https://www.it-projects.info/team>`__
37+
38+
Further information
39+
===================
40+
41+
Demo: http://runbot.it-projects.info/demo/pos-addons/12.0
42+
43+
HTML Description: https://apps.odoo.com/apps/modules/12.0/pos_clientlist_scan_button/
44+
45+
Usage instructions: `<doc/index.rst>`_
46+
47+
Changelog: `<doc/changelog.rst>`_
48+
49+
Notifications on updates: `via Atom <https://github.com/it-projects-llc/pos-addons/commits/12.0/pos_clientlist_scan_button.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/pos-addons/commits/12.0/pos_clientlist_scan_button.atom>`_
50+
51+
Tested on Odoo 12.0 3d0f8d07a494997be96868dd609bf4cc2ccc750c

pos_clientlist_scan_button/__init__.py

Whitespace-only changes.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
3+
4+
{
5+
"name": """pos_clientlist_scan_button""",
6+
"summary": """Adds scan button for some fields on clientlist screen""",
7+
"category": "Point of Sale",
8+
# "live_test_url": "http://apps.it-projects.info/shop/product/DEMO-URL?version=12.0",
9+
"images": [],
10+
"version": "12.0.1.0.0",
11+
"application": False,
12+
13+
"author": "IT-Projects LLC, Kolushov Alexandr",
14+
"support": "[email protected]",
15+
"website": "https://apps.odoo.com/apps/modules/12.0/pos_clientlist_scan_button/",
16+
"license": "LGPL-3",
17+
# "price": 9.00,
18+
# "currency": "EUR",
19+
20+
"depends": [
21+
'pos_qr_scan',
22+
],
23+
"external_dependencies": {"python": [], "bin": []},
24+
"data": [
25+
'views/assets.xml',
26+
],
27+
"demo": [
28+
],
29+
"qweb": [
30+
'static/src/xml/clientlist.xml',
31+
],
32+
33+
"post_load": None,
34+
"pre_init_hook": None,
35+
"post_init_hook": None,
36+
"uninstall_hook": None,
37+
38+
"auto_install": False,
39+
"installable": True,
40+
41+
# "demo_title": "pos_clientlist_scan_button",
42+
# "demo_addons": [
43+
# ],
44+
# "demo_addons_hidden": [
45+
# ],
46+
# "demo_url": "DEMO-URL",
47+
# "demo_summary": "Adds scan button for some fields on clientlist screen",
48+
# "demo_images": [
49+
# "images/MAIN_IMAGE",
50+
# ]
51+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
`1.0.0`
2+
-------
3+
4+
- **Init version**
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
============================
2+
Pos Clientlist Scan Button
3+
============================
4+
5+
Installation
6+
============
7+
{Instruction about things to do before actual installation}
8+
9+
* {OPTIONAL }`Activate longpolling <https://odoo-development.readthedocs.io/en/latest/admin/longpolling.html>`__
10+
* {Additional notes if any}
11+
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way
12+
13+
Configuration
14+
=============
15+
16+
{Instruction how to configure the module before start to use it}
17+
18+
* `Log in as SUPERUSER <https://odoo-development.readthedocs.io/en/latest/odoo/usage/login-as-superuser.html>`__
19+
* `Activate Developer Mode <https://odoo-development.readthedocs.io/en/latest/odoo/usage/debug-mode.html>`__
20+
* Open menu ``[[ {Menu} ]] >> {Submenu} >> {Subsubmenu}``
21+
* Click ``[{Button Name}]``
22+
23+
Usage
24+
=====
25+
26+
{Instruction for daily usage. It should describe how to check that module works. What shall user do and what would user get.}
27+
28+
* Open menu ``[[ {Menu} ]]>> {Submenu} >> {Subsubmenu}``
29+
* Click ``[{Button Name}]``
30+
* RESULT: {what user gets, how the modules changes default behaviour}
31+
32+
Uninstallation
33+
==============
34+
35+
{Optional section for uninstallation notes. Delete it if you don't have notes for uninstallation.}
1.87 KB
Loading
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
2+
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */
3+
odoo.define('pos_clientlist_scan_button.pos', function (require) {
4+
"use strict";
5+
6+
var screens = require('point_of_sale.screens');
7+
8+
screens.ClientListScreenWidget.include({
9+
10+
display_client_details: function(visibility, partner, clickpos){
11+
var self = this;
12+
this._super(visibility, partner, clickpos);
13+
var $buttons = this.$el.find('.button.scan').off();
14+
if(visibility === 'edit'){
15+
$buttons.on('click', function(ev) {
16+
var field = this.attributes.data.value;
17+
self.gui.show_popup('qr_scan', {
18+
read_callback: self.scan_callback,
19+
field: field,
20+
ClientListScreenWidget: self
21+
});
22+
});
23+
}
24+
},
25+
26+
scan_callback: function(value, method) {
27+
if (this.pos.debug){
28+
console.log(method.toUpperCase() + ' scanned', value);
29+
}
30+
var $input = this.options.ClientListScreenWidget.$el.find('input.' + this.options.field);
31+
if ($input) {
32+
$input.val(value);
33+
}
34+
this.click_cancel();
35+
},
36+
});
37+
38+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
3+
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). -->
4+
<templates>
5+
6+
<t t-extend="ClientDetailsEdit">
7+
<t t-jquery="input.detail.barcode" t-operation="after">
8+
<span class='button scan barcode' data="barcode"><i class='fa fa-qrcode' role="img" aria-label="Scan" title="Scan"/></span>
9+
</t>
10+
11+
<t t-jquery="input.detail.vat" t-operation="after">
12+
<span class='button scan' data="vat"><i class='fa fa-qrcode' role="img" aria-label="Scan" title="Scan"/></span>
13+
</t>
14+
</t>
15+
16+
</templates>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
2+
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). -->
3+
<odoo>
4+
5+
<template id="pos" inherit_id="web.assets_backend">
6+
<xpath expr="." position="inside">
7+
<script type="text/javascript" src="/pos_clientlist_scan_button/static/src/js/pos.js"></script>
8+
</xpath>
9+
</template>
10+
11+
</odoo>

pos_qr_scan/static/src/js/qr_scan.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ odoo.define('pos_qr_scan', function(require){
99
var gui = require('point_of_sale.gui');
1010
var PopupWidget = require('point_of_sale.popups');
1111
var screens = require('point_of_sale.screens');
12-
Quagga = window.Quagga;
12+
var core = require('web.core');
13+
var _t = core._t;
14+
var Quagga = window.Quagga;
1315

1416
var QrButton = screens.ActionButtonWidget.extend({
1517
template: 'QrButton',
@@ -54,26 +56,26 @@ odoo.define('pos_qr_scan', function(require){
5456
inputStream : {
5557
name : "Live",
5658
type : "LiveStream",
57-
target: document.querySelector('#preview') // Or '#yourElement' (optional)
59+
target: document.querySelector('#preview')
5860
},
5961
decoder : {
6062
readers : [
61-
"code_128_reader",
63+
// "code_128_reader",
6264
"ean_reader",
63-
"ean_8_reader",
64-
"code_39_reader",
65-
"code_39_vin_reader",
66-
"codabar_reader",
67-
"upc_reader",
68-
"upc_e_reader",
69-
"i2of5_reader",
70-
"code_93_reader",
65+
// "ean_8_reader",
66+
// "code_39_reader",
67+
// "code_39_vin_reader",
68+
// "codabar_reader",
69+
// "upc_reader",
70+
// "upc_e_reader",
71+
// "i2of5_reader",
72+
// "code_93_reader",
7173
]
7274
}
7375
}, function(err) {
7476
if (err) {
7577
console.log(err);
76-
return
78+
return;
7779
}
7880
console.log("Initialization finished. Ready to start");
7981
Quagga.start();
@@ -161,9 +163,14 @@ odoo.define('pos_qr_scan', function(require){
161163
}
162164
} else{
163165
console.log("no navigator.mediaDevices.enumerateDevices" );
166+
this.pos.gui.show_popup('alert', {
167+
title: _t('Error'),
168+
body: _t('No Media Devices Found')
169+
});
164170
}
165171
},
166172
generate_qr_scanner: function() {
173+
var self = this;
167174
this.cam_is_on = true;
168175
setTimeout(function(){
169176
self.captureToCanvas();

0 commit comments

Comments
 (0)