Browse Source

Barcode prefix is read from barcode parser.

pull/491/head
François Kawala 5 years ago
committed by Sylvain LE GAL
parent
commit
c911e94882
  1. 9
      pos_barcode_tare/models/pos_config.py
  2. 20
      pos_barcode_tare/readme/DESCRIPTION.rst
  3. 3
      pos_barcode_tare/readme/ROADMAP.rst
  4. 6
      pos_barcode_tare/readme/USAGE.rst
  5. BIN
      pos_barcode_tare/static/description/POS_with_button.png
  6. BIN
      pos_barcode_tare/static/description/null_weight.png
  7. BIN
      pos_barcode_tare/static/description/ready_to_print.png
  8. BIN
      pos_barcode_tare/static/description/zoom_action_widget.png
  9. 28
      pos_barcode_tare/static/src/js/pos_barcode_tare.js
  10. 1
      pos_barcode_tare/views/pos_config_view.xml

9
pos_barcode_tare/models/pos_config.py

@ -9,3 +9,12 @@ class PosConfig(models.Model):
'Show tare label button', 'Show tare label button',
help="Print tare labels with this POS" help="Print tare labels with this POS"
) )
iface_tare_barcode_sequence_id = fields.Integer(
'Barcode nomenclature sequence ID',
default=36,
required=True,
help="""The nomenclature ID gives barcode pattern.
It can be found in POS Barcode Nomenclatures. The expected barcode
pattern is 21.....{NNDDD}"""
)

20
pos_barcode_tare/readme/DESCRIPTION.rst

@ -1,24 +1,30 @@
This add-on enables POS to read and print tare barcodes. We print a barcode tare label to sell loose goods in a Bring Your Own Container (BYOC) scheme.
This add-on enables POS to read and print tare barcodes. We print a barcode tare label to sell loose goods in a Bring Your Own pot (BYOC) scheme.
The BYOC scheme has four steps:
1. The cashier weighs the container and sticks the tare bar code onto the customer's pot.
2. The customer takes the desired quantity of the goods s-he wants to buy.
3. The cashier weighs the filled container and goods, and POS gives the corresponding price.
4. The cashier scans the tare bar code, and POS removes the container's weight from the latest product of the order.
The BYOC scheme has five steps:
1. The cashier weighs the pot and sticks the tare barcode onto the customer's pot.
2. The customer go and put loose goods into the labeled pot.
3. The cashier weighs the pot with loose goods inside. POS computes the price including the pot.
4. The cashier scans the tare barcode. POS get the pot weight from the barcode. POS subtracts the pot weight from the weight of the latest product. POS sets the billable price for the loose goods.
5. The customer pays.
This add-on adds a news screen to POS to print (web) the tare barcode labels. This add-on enables POS to read a tare barcode. Reading a barcode makes POS adjust the weight of the latest article in the order list. The new weight is equal to the total weight minus the tare weight. The price is updated accordingly to the weight change. This add-on adds a news screen to POS to print (web) the tare barcode labels. This add-on enables POS to read a tare barcode. Reading a barcode makes POS adjust the weight of the latest article in the order list. The new weight is equal to the total weight minus the tare weight. The price is updated accordingly to the weight change.
POS home screen is now: POS home screen is now:
.. image:: ../static/description/POS_with_button.png .. image:: ../static/description/POS_with_button.png
The label screen is: The label screen is:
.. image:: ../static/description/null_weight.png .. image:: ../static/description/null_weight.png
When we read a weight the impression button is enabled When we read a weight the impression button is enabled
.. image:: ../static/description/ready_to_print.png .. image:: ../static/description/ready_to_print.png
A barcode label looks like: A barcode label looks like:
.. image:: ../static/description/label.png .. image:: ../static/description/label.png
Zoom on the action widget: Zoom on the action widget:
.. image:: ../static/description/zoom_action_widget.png
.. image:: ../static/description/zoom_action_widget.png

3
pos_barcode_tare/readme/ROADMAP.rst

@ -1,2 +1 @@
- Use barcode nomenclature instead of hardcoded barcode prefix 21.
- Add french translation.
- Add french translation.

6
pos_barcode_tare/readme/USAGE.rst

@ -1 +1,5 @@
Install this add-on and configure the point of sale where you want to be able to use the tare barecode. The label printing is done using web print. To streamline the label printing it is advised to use the silent printing mode (firefox) or the kiosk printing (chrome).
Install this add-on and configure the point of sale where you want to be able to use the tare barecode. Setup the default barcode sequence ID according to your barcode nomenclature. The label printing is done using web print. To streamline the label printing it is advised to use the silent printing mode (firefox) or the kiosk printing (chrome).
The command line to start a chrome base browser in kiosk mode with silent printing looks like:
``chromium-browser --use-system-default-printer --kiosk --kiosk-printing http://localhost:8069/``

BIN
pos_barcode_tare/static/description/POS_with_button.png

Before

Width: 1920  |  Height: 1080  |  Size: 625 KiB

After

Width: 960  |  Height: 540  |  Size: 198 KiB

BIN
pos_barcode_tare/static/description/null_weight.png

Before

Width: 1920  |  Height: 1080  |  Size: 50 KiB

After

Width: 960  |  Height: 540  |  Size: 20 KiB

BIN
pos_barcode_tare/static/description/ready_to_print.png

Before

Width: 1920  |  Height: 1080  |  Size: 50 KiB

After

Width: 960  |  Height: 540  |  Size: 21 KiB

BIN
pos_barcode_tare/static/description/zoom_action_widget.png

Before

Width: 438  |  Height: 295  |  Size: 16 KiB

After

Width: 437  |  Height: 292  |  Size: 15 KiB

28
pos_barcode_tare/static/src/js/pos_barcode_tare.js

@ -74,10 +74,15 @@ odoo.define('pos_barcode_tare.screens', function (require) {
next_screen: 'products', next_screen: 'products',
previous_screen: 'products', previous_screen: 'products',
default_tare_value_kg: 0.0, default_tare_value_kg: 0.0,
weight_barcode_prefix: null,
show: function () { show: function () {
this._super(); this._super();
var self = this; var self = this;
// Fetch the barcode prefix from POS barcode parser rules.
this.weight_barcode_prefix = this.get_barcode_prefix(
this.pos.config.iface_tare_barcode_sequence_id);
// Setup the proxy
var queue = this.pos.proxy_queue; var queue = this.pos.proxy_queue;
// The pooling of the scale starts here. // The pooling of the scale starts here.
queue.schedule(function () { queue.schedule(function () {
@ -90,6 +95,24 @@ odoo.define('pos_barcode_tare.screens', function (require) {
this.render_receipt(); this.render_receipt();
this.lock_screen(true); this.lock_screen(true);
}, },
get_barcode_prefix: function (barcode_sequence_id) {
var self = this;
var barcode_pattern = self.get_barcode_pattern(barcode_sequence_id);
return barcode_pattern.substr(0, 2);
},
get_barcode_pattern: function (barcode_sequence_id) {
var self = this;
var rules = self.get_barcode_rules();
var rule = rules.filter(
function (r) {
return r.sequence === barcode_sequence_id;
})[0];
return rule.pattern;
},
get_barcode_rules: function () {
var self = this;
return self.pos.barcode_reader.barcode_parser.nomenclature.rules;
},
set_weight: function (weight) { set_weight: function (weight) {
if (weight > 0) { if (weight > 0) {
this.weight = weight; this.weight = weight;
@ -124,7 +147,6 @@ odoo.define('pos_barcode_tare.screens', function (require) {
// grams. Here the weight is 12.345kg. The last digit of the barcode // grams. Here the weight is 12.345kg. The last digit of the barcode
// is a checksum, here symbolized by x. // is a checksum, here symbolized by x.
var padding_size = 5; var padding_size = 5;
var default_weight_prefix_id = "21";
var void_product_id = '0'.repeat(padding_size); var void_product_id = '0'.repeat(padding_size);
var weight_in_gram = weight * 10e2; var weight_in_gram = weight * 10e2;
// Weight has to be padded with zeros. // Weight has to be padded with zeros.
@ -132,8 +154,8 @@ odoo.define('pos_barcode_tare.screens', function (require) {
var padded_weight = weight_with_padding.substr( var padded_weight = weight_with_padding.substr(
weight_with_padding.length - padding_size); weight_with_padding.length - padding_size);
// Builds the barcode data (ie. all but the checksum). // Builds the barcode data (ie. all but the checksum).
var barcode_data = default_weight_prefix_id.concat(void_product_id,
padded_weight);
var barcode_data = this.weight_barcode_prefix
.concat(void_product_id, padded_weight);
// Compute checksum and concat with barcode data to get the actual // Compute checksum and concat with barcode data to get the actual
// barcode. // barcode.
var checksum = this.ean13_checksum(barcode_data); var checksum = this.ean13_checksum(barcode_data);

1
pos_barcode_tare/views/pos_config_view.xml

@ -9,6 +9,7 @@
<separator string="Loose good options" colspan="4"/> <separator string="Loose good options" colspan="4"/>
<group> <group>
<field name="iface_tare_label" /> <field name="iface_tare_label" />
<field name="iface_tare_barcode_sequence_id" />
</group> </group>
</xpath> </xpath>
</field> </field>

Loading…
Cancel
Save