Browse Source

[ADD][8.0] pos_tare

pull/491/head
Sylvain LE GAL 4 years ago
parent
commit
e2515637a2
  1. 72
      pos_tare/README.rst
  2. 1
      pos_tare/__init__.py
  3. 27
      pos_tare/__openerp__.py
  4. 13
      pos_tare/demo/pos_config.xml
  5. 68
      pos_tare/i18n/fr.po
  6. 1
      pos_tare/readme/CONTRIBUTORS.rst
  7. 8
      pos_tare/readme/DESCRIPTION.rst
  8. 1
      pos_tare/readme/ROADMAP.rst
  9. BIN
      pos_tare/static/description/icon.png
  10. BIN
      pos_tare/static/description/pos_tare.png
  11. 31
      pos_tare/static/src/css/pos_tare.css
  12. 140
      pos_tare/static/src/js/pos_tare.js
  13. 45
      pos_tare/static/src/xml/pos_tare.xml
  14. 23
      pos_tare/views/templates.xml

72
pos_tare/README.rst

@ -0,0 +1,72 @@
====================
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

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

27
pos_tare/__openerp__.py

@ -0,0 +1,27 @@
# 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).
{
'name': 'Point Of Sale - Tare',
'summary': 'Manage Tare in Point Of Sale module',
'version': '8.0.1.0.0',
'category': 'Point Of Sale',
'author': 'GRAP',
'website': 'http://www.grap.coop',
'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,
}

13
pos_tare/demo/pos_config.xml

@ -0,0 +1,13 @@
<?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>

68
pos_tare/i18n/fr.po

@ -0,0 +1,68 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_tare
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.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"
"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/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
#, python-format
msgid "Gross Weight"
msgstr "Poids Brut"
#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/xml/pos_tare.xml:31
#, python-format
msgid "Net Weight"
msgstr "Poids Net"
#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/js/pos_tare.js:73
#, python-format
msgid "Order"
msgstr "Commander"
#. 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
#, python-format
msgid "Tare"
msgstr "Tare"
#. module: pos_tare
#. openerp-web
#: code:addons/pos_tare/static/src/xml/pos_tare.xml:35
#, 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"

1
pos_tare/readme/CONTRIBUTORS.rst

@ -0,0 +1 @@
* Sylvain LE GAL (https://www.twitter.com/legalsylvain)

8
pos_tare/readme/DESCRIPTION.rst

@ -0,0 +1,8 @@
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:: ../static/description/pos_tare.png
The screen will be displayed only for 'to_weight' products and if scale is
enabled in PoS Configuration.

1
pos_tare/readme/ROADMAP.rst

@ -0,0 +1 @@
For the time being, this module disable Scale functionnality.

BIN
pos_tare/static/description/icon.png

After

Width: 64  |  Height: 64  |  Size: 3.3 KiB

BIN
pos_tare/static/description/pos_tare.png

After

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

31
pos_tare/static/src/css/pos_tare.css

@ -0,0 +1,31 @@
.pos .pos-tare-container .left-block{
display: inline-block;
width:45%;
margin:0;
padding:0;
text-align:left;
font-size: 16px;
color: #555;
font-weight: bold;
}
.pos .pos-tare-container .right-block, .pos .pos-tare-container .right-block-readonly{
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;
}
.pos .pos-tare-container .right-block{
background: white;
box-shadow: 0px 2px rgba(143, 143, 143, 0.3) inset;
}

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

@ -0,0 +1,140 @@
/*
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);
},
});
};

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

@ -0,0 +1,45 @@
<?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-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>
</div>
</div>
</t>
</templates>

23
pos_tare/views/templates.xml

@ -0,0 +1,23 @@
<?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).
-->
<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>
<!-- 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"/>
</xpath>
</template>
</data></openerp>
Loading…
Cancel
Save