Browse Source

[MIG] pos_tare: Migration to 12.0

pull/501/head
Sylvain LE GAL 5 years ago
committed by François Kawala
parent
commit
b03d1ba64a
  1. 64
      pos_tare/README.rst
  2. 1
      pos_tare/__init__.py
  3. 18
      pos_tare/__manifest__.py
  4. 13
      pos_tare/demo/pos_config.xml
  5. 49
      pos_tare/i18n/fr.po
  6. 2
      pos_tare/readme/CONFIGURE.rst
  7. 6
      pos_tare/readme/DESCRIPTION.rst
  8. 3
      pos_tare/readme/ROADMAP.rst
  9. BIN
      pos_tare/static/description/pos_tare.png
  10. 64
      pos_tare/static/src/css/pos_tare.css
  11. 140
      pos_tare/static/src/js/pos_tare.js
  12. 97
      pos_tare/static/src/js/screens.js
  13. 45
      pos_tare/static/src/xml/pos_tare.xml
  14. 18
      pos_tare/views/assets.xml

64
pos_tare/README.rst

@ -6,67 +6,3 @@ Point Of Sale - Tare
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-grap%2Fgrap--odoo--business-lightgray.png?logo=github
:target: https://github.com/grap/grap-odoo-business/tree/8.0/pos_tare
:alt: grap/grap-odoo-business
|badge1| |badge2| |badge3|
Give the possibility to the user to provide Gross weight and Tare weight.
This will compute automatically net weight and set it to the current
selected order
.. figure:: https://raw.githubusercontent.com/grap/grap-odoo-business/8.0/pos_tare/static/description/pos_tare.png
The screen will be displayed only for 'to_weight' products and if scale is
enabled in PoS Configuration.
**Table of contents**
.. contents::
:local:
Known issues / Roadmap
======================
For the time being, this module disable Scale functionnality.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/grap/grap-odoo-business/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/grap/grap-odoo-business/issues/new?body=module:%20pos_tare%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* GRAP
Contributors
~~~~~~~~~~~~
* Sylvain LE GAL (https://www.twitter.com/legalsylvain)
Maintainers
~~~~~~~~~~~
This module is part of the `grap/grap-odoo-business <https://github.com/grap/grap-odoo-business/tree/8.0/pos_tare>`_ project on GitHub.
You are welcome to contribute.

1
pos_tare/__init__.py

@ -1 +0,0 @@
# coding: utf-8

18
pos_tare/__openerp__.py → pos_tare/__manifest__.py

@ -1,4 +1,3 @@
# coding: 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).
@ -6,14 +5,15 @@
{
"name": "Point Of Sale - Tare",
"summary": "Manage Tare in Point Of Sale module",
"version": "8.0.1.0.0",
"version": "12.0.1.0.0",
"category": "Point Of Sale",
"author": "GRAP",
"website": "http://www.grap.coop",
"author": "GRAP, "
"Odoo Community Association (OCA)",
"maintainers": ["legalsylvain"],
"website": "https://www.github.com/pos",
"license": "AGPL-3",
"depends": ["point_of_sale",],
"data": ["views/templates.xml",],
"demo": ["demo/pos_config.xml",],
"qweb": ["static/src/xml/pos_tare.xml",],
"installable": False,
"depends": ["point_of_sale"],
"data": ["views/assets.xml"],
"qweb": ["static/src/xml/pos_tare.xml"],
"installable": True,
}

13
pos_tare/demo/pos_config.xml

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2018 - 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).
-->
<openerp><data>
<record id="point_of_sale.pos_config_main" model="pos.config">
<field name="iface_electronic_scale" eval="1" />
</record>
</data></openerp>

49
pos_tare/i18n/fr.po

@ -4,10 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-21 10:31+0000\n"
"PO-Revision-Date: 2016-06-21 10:31+0000\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"
@ -17,52 +17,35 @@ msgstr ""
#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/js/pos_tare.js:65
#, python-format
msgid "Back"
msgstr "Retour"
#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/xml/pos_tare.xml:17
#: code:addons/pos_tare/static/src/xml/pos_tare.xml:18
#: 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/xml/pos_tare.xml:31
#: code:addons/pos_tare/static/src/js/screens.js:49
#, python-format
msgid "Net Weight"
msgstr "Poids Net"
msgid "Incorrect Tare Value"
msgstr "Valeur de tare incorrecte"
#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/js/pos_tare.js:73
#: code:addons/pos_tare/static/src/xml/pos_tare.xml:19
#, python-format
msgid "Order"
msgstr "Commander"
msgid "Kg"
msgstr "Kg"
#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/xml/pos_tare.xml:21
#: code:addons/pos_tare/static/src/xml/pos_tare.xml:22
#: code:addons/pos_tare/static/src/js/screens.js:50
#, python-format
msgid "Tare"
msgstr "Tare"
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:35
#: code:addons/pos_tare/static/src/xml/pos_tare.xml:15
#, python-format
msgid "Total Price"
msgstr "Prix Total"
#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/xml/pos_tare.xml:26
#, python-format
msgid "Unit Price"
msgstr "Prix Unitaire"
msgid "Tare"
msgstr "Tare"

2
pos_tare/readme/CONFIGURE.rst

@ -0,0 +1,2 @@
To enable this feature, you should enable "IoT Box" on your Point of Sale,
and check the box "Electronic Scale"

6
pos_tare/readme/DESCRIPTION.rst

@ -1,8 +1,6 @@
Give the possibility to the user to provide Gross weight and Tare weight.
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
The screen will be displayed only for 'to_weight' products and if scale is
enabled in PoS Configuration.

3
pos_tare/readme/ROADMAP.rst

@ -1 +1,2 @@
For the time being, this module disable Scale functionnality.
* Display the gross weight and the tare on each order line, on the screen
and on the receipt.

BIN
pos_tare/static/description/pos_tare.png

Before

Width: 871  |  Height: 388  |  Size: 36 KiB

After

Width: 501  |  Height: 480  |  Size: 30 KiB

64
pos_tare/static/src/css/pos_tare.css

@ -1,31 +1,49 @@
.pos .pos-tare-container .left-block{
.pos .scale-screen .weight-label {
font-size: 25px;
margin: 16px;
text-align: center;
display: inline-block;
width:45%;
margin:0;
padding:0;
text-align:left;
font-size: 16px;
color: #555;
font-weight: bold;
width: 40%;
margin-bottom: 0px;
}
.pos .pos-tare-container .right-block, .pos .pos-tare-container .right-block-readonly{
.pos .scale-screen .weight-value {
font-size: 25px;
display: inline-block;
width:45%;
text-align:right;
height: 40px;
font-size: 20px;
font-family: Lato;
-moz-box-sizing: border-box;
outline: none;
border: none;
padding: 6px 8px;
color: #484848;
border-radius: 3px;
margin-top: 5px;
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 .pos-tare-container .right-block{
.pos .scale-screen .weight-value-gross-weight {
border-radius: 3px;
box-shadow: 0px 2px 0px rgb(225,225,225) inset;
text-align: right;
background: white;
box-shadow: 0px 2px rgba(143, 143, 143, 0.3) inset;
}
.pos .scale-screen .weight-value-tare {
text-align: left;
padding-bottom: 0px;
padding-left: 0px;
}
.pos .scale-screen .input-weight-tare {
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-tare:focus {
outline: none;
box-shadow: 0px 0px 0px 3px #6EC89B;
}

140
pos_tare/static/src/js/pos_tare.js

@ -1,140 +0,0 @@
/*
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).
*/
"use strict";
openerp.pos_tare = function(instance){
var module = instance.point_of_sale;
var _t = instance.web._t;
/*************************************************************************
Extend : Widget 'PosWidget'
*/
module.PosWidget = module.PosWidget.extend({
build_widgets: function(){
this._super();
// Add a new screen 'TareScreenWidget'
this.tare_screen = new module.TareScreenWidget(this,{});
this.tare_screen.appendTo(this.$('.screens'));
this.screen_selector.add_screen('tare', this.tare_screen);
},
});
/*************************************************************************
Extend : Widget 'ScaleScreenWidget'
*/
module.ScaleScreenWidget = module.ScaleScreenWidget.extend({
next_screen: 'tare',
// Overwrite 'show' function to display TareScreenWidget
show: function(){
this.pos_widget.screen_selector.set_current_screen(this.next_screen,{product: this.get_product()});
},
});
/*************************************************************************
Define : New Widget 'TareScreenWidget'
*/
module.TareScreenWidget = module.ScreenWidget.extend({
template:'TareScreenWidget',
next_screen: 'products',
previous_screen: 'products',
show_leftpane: false,
show: function(){
this._super();
this.renderElement();
var self = this;
// Initialize values
this.net_weight = 0;
this.current_product = this.get_product();
this.$('#product-name').html(this.get_product().display_name);
this.$('#unit-price').html(this.format_currency(this.get_product().price));
// Add a 'next' Button
this.add_action_button({
label: _t('Back'),
icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png',
click: function(){
self.pos_widget.screen_selector.set_current_screen(self.previous_screen);
},
});
this.order_button = this.add_action_button({
label: _t('Order'),
icon: '/point_of_sale/static/src/img/icons/png48/go-next.png',
click: function() { self.order_product_click(); },
});
// Initialize Display
this.onChangeGrossWeightTareWeight();
this.$('#gross-weight').keyup(function(event){
self.onChangeGrossWeightTareWeight(event);
});
this.$('#tare-weight').keyup(function(event){
self.onChangeGrossWeightTareWeight(event);
});
// Focus on Gross Weight
this.$('#gross-weight').focus();
},
sanitize_value: function (input_name){
var res = this.$(input_name)[0].value.replace(',', '.').trim();
if (isNaN(res)){
this.$(input_name).css("background-color", "#F66");
}
else{
this.$(input_name).css("background-color", "#FFF");
}
return res;
},
onChangeGrossWeightTareWeight: function(event){
var gross_weight = this.sanitize_value('#gross-weight');
var tare_weight = this.sanitize_value('#tare-weight');
var ok = false;
if (!isNaN(gross_weight) && (gross_weight !== '') && (parseFloat(gross_weight) !== 0) && !isNaN(tare_weight)){
this.net_weight = gross_weight - tare_weight;
var price = this.get_product().price * this.net_weight;
this.current_net_weight_text = this.net_weight.toFixed(3);
this.current_total_price_text = this.format_currency(price);
ok = true;
}
else{
this.current_net_weight_text = '/';
this.current_total_price_text = '/';
}
this.$('#net-weight').html(this.current_net_weight_text);
this.$('#total-price').html(this.current_total_price_text);
this.order_button.set_disabled(!ok);
},
get_product: function(){
var ss = this.pos_widget.screen_selector;
if(ss){
return ss.get_current_screen_param('product');
}else{
return undefined;
}
},
order_product_click: function(){
this.pos.get('selectedOrder').addProduct(this.current_product,{ quantity:this.net_weight });
this.pos_widget.screen_selector.set_current_screen(this.next_screen);
},
});
};

97
pos_tare/static/src/js/screens.js

@ -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;
this.correct_value = true;
var self = this;
this.$('#weight_tare').keyup(function(event){
self.onchange_tare(event);
});
},
// 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.$('.weight-value-gross-weight').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('#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 res;
}
},
});
});

45
pos_tare/static/src/xml/pos_tare.xml

@ -6,40 +6,19 @@ Copyright (C) 2015-Today GRAP (http://www.grap.coop)
-->
<templates id="template" xml:space="preserve">
<t t-name="TareScreenWidget">
<div class="scale-screen screen">
<div class="screen-content">
<div class="top-content">
<h1 id="product-name" />
</div>
<div class="centered-content pos-tare-container">
<div>
<span class="left-block">Unit Price</span>
<span id="unit-price" class="right-block-readonly"/>
</div>
<div>
<span class="left-block">Gross Weight</span>
<input id="gross-weight" class="right-block" pattern="[0-9]+([\.][0-9]+)?"/>
</div>
<div>
<span class="left-block">Tare</span>
<input id="tare-weight" class="right-block" pattern="[0-9]+([\.][0-9]+)?"/>
</div>
<br />
<br />
<div>
<span class="left-block">Net Weight</span>
<span id="net-weight" class="right-block-readonly"/>
</div>
<br />
<div>
<span class="left-block">Total Price</span>
<span id="total-price" class="right-block-readonly"/>
</div>
</div>
<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-gross-weight" />
<div class="weight-label">
Tare
</div>
<div class="weight-value weight-value-tare">
<input type="text" class="input-weight-tare" id="weight_tare" name="weight_tare" placeholder="0.000"/> Kg
</div>
</div>
</t>
</t>
</templates>

18
pos_tare/views/templates.xml → pos_tare/views/assets.xml

@ -5,19 +5,13 @@ Copyright (C) 2015-Today GRAP (http://www.grap.coop)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<openerp><data>
<!-- JS Files -->
<template id="assets_backend" name="point_of_sale assets2" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_tare/static/src/js/pos_tare.js"></script>
</xpath>
</template>
<odoo>
<!-- CSS Files -->
<template id="index" name="pos_tare index" inherit_id="point_of_sale.index">
<xpath expr="//link[@id='pos-stylesheet']" position="after">
<link rel="stylesheet" href="/pos_tare/static/src/css/pos_tare.css" id="pos_tare-stylesheet"/>
<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>
</data></openerp>
</odoo>
Loading…
Cancel
Save