Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pos_tare/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
====================
Point Of Sale - Tare
====================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Empty file added pos_tare/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions pos_tare/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2015-Today GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Point Of Sale - Tare",
"summary": "Manage Tare in Point Of Sale module",
"version": "12.0.1.0.0",
"category": "Point Of Sale",
"author": "GRAP, "
"Odoo Community Association (OCA)",
"maintainers": ["legalsylvain"],
"website": "https://www.github.com/OCA/pos",
"license": "AGPL-3",
"depends": ["point_of_sale"],
"data": ["views/assets.xml"],
"qweb": ["static/src/xml/pos_tare.xml"],
"installable": True,
"images": ["static/description/pos_tare.png"],
}
51 changes: 51 additions & 0 deletions pos_tare/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_tare
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-08 15:03+0000\n"
"PO-Revision-Date: 2020-01-08 15:03+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/xml/pos_tare.xml:11
#, python-format
msgid "Gross Weight"
msgstr "Poids Brut"

#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/js/screens.js:49
#, python-format
msgid "Incorrect Tare Value"
msgstr "Valeur de tare incorrecte"

#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/xml/pos_tare.xml:19
#, python-format
msgid "Kg"
msgstr "Kg"

#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/js/screens.js:50
#, python-format
msgid "Please set a numeric value in the tare field, or let empty."
msgstr "Veuillez saisir une valeur numérique dans le champ 'tare', ou le laisser vide."

#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/xml/pos_tare.xml:15
#, python-format
msgid "Tare"
msgstr "Tare"
2 changes: 2 additions & 0 deletions pos_tare/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
To enable this feature, you should enable "IoT Box" on your Point of Sale,
and check the box "Electronic Scale"
1 change: 1 addition & 0 deletions pos_tare/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Sylvain LE GAL (https://www.twitter.com/legalsylvain)
6 changes: 6 additions & 0 deletions pos_tare/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Give the possibility to the user to enter a Tare weight, when weighting
products in the Point of Sale.
This will compute automatically net weight and set it to the current
selected order

.. figure:: ../static/description/pos_tare.png
2 changes: 2 additions & 0 deletions pos_tare/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Display the gross weight and the tare on each order line, on the screen
and on the receipt.
Binary file added pos_tare/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pos_tare/static/description/pos_tare.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions pos_tare/static/src/css/pos_tare.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

.pos .scale-screen .weight-label {
font-size: 25px;
margin: 16px;
text-align: center;
display: inline-block;
width: 40%;
margin-bottom: 0px;
}

.pos .scale-screen .weight-value {
font-size: 25px;
display: inline-block;
margin: 16px;
margin-top: 0px;
padding: 16px;
width: 40%;
font-family: Inconsolata;
font-weight: bold;
text-shadow: 0px 2px 0px rgb(210,210,210);
margin-bottom: 0px;
}

.pos .scale-screen .weight-value-fixed {
border-radius: 3px;
box-shadow: 0px 2px 0px rgb(225,225,225) inset;
text-align: right;
background: white;
}

.pos .scale-screen .weight-value-alterable {
text-align: left;
padding-bottom: 0px;
padding-left: 0px;
}
.pos .scale-screen .input-weight {
border: 1px solid #cecbcb;
border-radius: 20px;
padding: 15px 20px;
width: 50%;
font-family: Inconsolata;
font-weight: bold;
font-size: 25px;
}

.pos .scale-screen .input-weight:focus {
outline: none;
box-shadow: 0px 0px 0px 3px #6EC89B;
}
97 changes: 97 additions & 0 deletions pos_tare/static/src/js/screens.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
Copyright (C) 2015-Today GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
*/


odoo.define('pos_tare.screens', function (require) {
"use strict";

var screens = require('point_of_sale.screens');
var utils = require('web.utils');
var round_pr = utils.round_precision;


screens.ScaleScreenWidget.include({

// /////////////////////////////
// Overload Section
// /////////////////////////////

// Overload show function
// add an handler on the
show: function(){
this._super();
this.tare = 0.0;
var self = this;
this.$('#input_weight_tare').keyup(function(event){
self.onchange_tare(event);
});
this.$('#input_weight_tare').focus()
},

// Overload set_weight function
// We assume that the argument is now the gross weight
// we compute the net weight, depending on the tare and the gross weight
// then we call super, with the net weight
set_weight: function(gross_weight){
this.gross_weight = gross_weight;
var net_weight = gross_weight - (this.tare || 0);
this.$('#container_weight_gross').text(this.get_product_gross_weight_string());
this._super(net_weight);
},

order_product: function(){
// TODO Set a warning, if the value is incorrect;
if (this.tare === undefined) {
this.gui.show_popup('error',{
'title': _t('Incorrect Tare Value'),
'body': _t('Please set a numeric value in the tare field, or let empty.'),
});
}
else {
this._super();
}
},

// /////////////////////////////
// Custom Section
// /////////////////////////////
get_product_gross_weight_string: function(){
var product = this.get_product();
var defaultstr = (this.gross_weight || 0).toFixed(3) + ' Kg';
if(!product || !this.pos){
return defaultstr;
}
var unit_id = product.uom_id;
if(!unit_id){
return defaultstr;
}
var unit = this.pos.units_by_id[unit_id[0]];
var weight = round_pr(this.gross_weight || 0, unit.rounding);
var weightstr = weight.toFixed(Math.ceil(Math.log(1.0/unit.rounding) / Math.log(10) ));
weightstr += ' ' + unit.name;
return weightstr;
},

onchange_tare: function(event){
this.tare = this.check_sanitize_value('#input_weight_tare');;
this.set_weight(this.gross_weight);
},

check_sanitize_value: function (input_name){
var res = this.$(input_name)[0].value.replace(',', '.').trim();
if (isNaN(res)){
this.$(input_name).css("background-color", "#F66");
return undefined;
}
else{
this.$(input_name).css("background-color", "#FFF");
return parseFloat(res, 10);
}
},

});

});
24 changes: 24 additions & 0 deletions pos_tare/static/src/xml/pos_tare.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2015-Today GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<templates id="template" xml:space="preserve">

<t t-extend="ScaleScreenWidget">
<t t-jquery=".js-weight" t-operation="before">
<div class="weight-label">
Gross Weight
</div>
<div class="weight-value weight-value-fixed" id="container_weight_gross"/>
<div class="weight-label">
Tare
</div>
<div class="weight-value weight-value-alterable">
<input type="text" class="input-weight" id="input_weight_tare" placeholder="0.000"/> Kg
</div>
</t>
</t>

</templates>
17 changes: 17 additions & 0 deletions pos_tare/views/assets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2015-Today GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->

<odoo>

<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_tare/static/src/js/screens.js"/>
<link rel="stylesheet" href="/pos_tare/static/src/css/pos_tare.css"/>
</xpath>
</template>

</odoo>