Browse Source

Merge bd0eb7a2dc into 45a15ac568

pull/332/merge
Artem Rafailov 4 years ago
committed by GitHub
parent
commit
8f718fc693
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 101
      pos_product_qty_available/README.rst
  2. 0
      pos_product_qty_available/__init__.py
  3. 29
      pos_product_qty_available/__manifest__.py
  4. 21
      pos_product_qty_available/data/pos_product_qty_available_data.xml
  5. 71
      pos_product_qty_available/i18n/de.po
  6. 71
      pos_product_qty_available/i18n/es.po
  7. 9
      pos_product_qty_available/readme/CONTRIBUTORS.rst
  8. 6
      pos_product_qty_available/readme/CREDITS.rst
  9. 3
      pos_product_qty_available/readme/DESCRIPTION.rst
  10. 3
      pos_product_qty_available/readme/USAGE.rst
  11. BIN
      pos_product_qty_available/static/description/icon.png
  12. 102
      pos_product_qty_available/static/description/index.html
  13. BIN
      pos_product_qty_available/static/description/screenshot-2.png
  14. BIN
      pos_product_qty_available/static/description/screenshot.png
  15. 24
      pos_product_qty_available/static/src/css/pos.css
  16. 123
      pos_product_qty_available/static/src/js/pos.js
  17. 104
      pos_product_qty_available/static/src/js/test_pos_quantities.js
  18. 27
      pos_product_qty_available/static/src/xml/pos.xml
  19. 3
      pos_product_qty_available/tests/__init__.py
  20. 34
      pos_product_qty_available/tests/test_quantities.py

101
pos_product_qty_available/README.rst

@ -0,0 +1,101 @@
=====================================
Available quantity of products in POS
=====================================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github
:target: https://github.com/OCA/server-auth/tree/11.0/pos_product_qty_available
:alt: OCA/server-auth
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-auth-11-0/server-auth-11-0-pos_product_qty_available
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/251/11.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
This module allows you to see the available quantity of products in the POS.
At the *Point of Sale*, the quantity of the product is displayed in the card and in the order panel.
**Table of contents**
.. contents::
:local:
Usage
=====
* Go to *Point of Sale*
* Now the quantity of the product is shown on the product card and on the order panel
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-auth/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/OCA/server-auth/issues/new?body=module:%20pos_product_qty_available%0Aversion:%2011.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
~~~~~~~
* IT-Projects LLC
* Ivan Yelizariev
Contributors
~~~~~~~~~~~~
* Ivan Yelizariev <yelizariev@it-projects.info> (https://it-projects.info/team/yelizariev)
* Ilmir Karamov <karamov@it-projects.info> (https://it-projects.info/team/ilmir-k)
* Kolushov Alexandr <kolushov@it-projects.info> (https://it-projects.info/team/KolushovAlexandr)
* gaelTorrecillas <gael.torrecillas@mind-and-go.com> (https://github.com/gaelTorrecillas)
* manawi (https://github.com/manawi)
Other credits
~~~~~~~~~~~~~
The development of this module has been financially supported by:
* IT-Projects LLC <https://it-projects.info>
Original module: pos_product_available
Repository: https://github.com/it-projects-llc/pos-addons/tree/12.0/
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/11.0/pos_product_qty_available>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

0
pos_product_qty_available/__init__.py

29
pos_product_qty_available/__manifest__.py

@ -0,0 +1,29 @@
# Copyright 2014-2018 Ivan Yelizariev<https://it-projects.info/team/yelizariev>
# Copyright 2017 Gabbasov Dinar<https://it-projects.info/team/GabbasovDinar>
# Copyright 2018 Kolushov Alex<https://it-projects.info/team/KolushovAlexandr>
# Copyright 2018 Ildar Nasyrov<https://it-projects.info/team/iledarn>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": """Available quantity of products in POS""",
"summary": """Adds available quantity at products in POS""",
"category": "Point Of Sale",
"images": [],
"version": "12.0.1.0.0",
"application": False,
"author": "IT-Projects LLC, Ivan Yelizariev, "
"Odoo Community Association (OCA)",
"support": "pos@it-projects.info",
"website": "https://github.com/OCA/pos",
"license": "LGPL-3",
"depends": [
'point_of_sale',
],
'data': [
'data/pos_product_qty_available_data.xml',
],
'qweb': [
'static/src/xml/pos.xml',
],
"auto_install": False,
"installable": True,
}

21
pos_product_qty_available/data/pos_product_qty_available_data.xml

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright 2014-2016 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
Copyright 2018 Gabbasov Dinar <https://it-projects.info/team/GabbasovDinar>
Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
Copyright 2018 Ildar Nasyrov <https://it-projects.info/team/iledarn>
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -->
<odoo>
<template id="assets_backend" name="pos assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_product_qty_available/static/src/js/pos.js"></script>
</xpath>
<xpath expr="//link[@id='pos-stylesheet']" position="after">
<link rel="stylesheet" href="/pos_product_qty_available/static/src/css/pos.css"/>
</xpath>
</template>
<template id="assets_backend_web" name="pos_product_qty_available_backend_assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_product_qty_available/static/src/js/test_pos_quantities.js"></script>
</xpath>
</template>
</odoo>

71
pos_product_qty_available/i18n/de.po

@ -0,0 +1,71 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_product_qty_available
#
# Translators:
# Translation Bot <i18n-bot@it-projects.info>, 2017
# Ermin Trevisan <trevi@twanda.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-27 23:49+0000\n"
"PO-Revision-Date: 2018-04-27 23:49+0000\n"
"Last-Translator: Ermin Trevisan <trevi@twanda.com>, 2018\n"
"Language-Team: German (https://www.transifex.com/it-projects-llc/teams/76080/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: pos_product_qty_available
#. openerp-web
#: code:addons/pos_product_qty_available/static/src/xml/pos.xml:15
#, python-format
msgid "(of"
msgstr "(von "
#. module: pos_product_qty_available
#. openerp-web
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:11
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:68
#, python-format
msgid ""
"<p>Click to start the point of sale interface. It <b>runs on tablets</b>, "
"laptops, or industrial hardware.</p><p>Once the session launched, the system"
" continues to run without an internet connection.</p>"
msgstr ""
"<p>Anklicken, um das POS-System zu starten. Es <b>läuft auf Tablets</b>, "
"Laptops, oder industrieller Hardware.</p><p>Sobald eine Sitzung gestartet "
"wurde, funktioniert das System auch ohne Internet-Verbindung.</p>"
#. module: pos_product_qty_available
#. openerp-web
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:43
#, python-format
msgid "Click the payment method"
msgstr ""
#. module: pos_product_qty_available
#. openerp-web
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:61
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:64
#, python-format
msgid "Close POS"
msgstr ""
#. module: pos_product_qty_available
#. openerp-web
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:36
#, python-format
msgid "Open the payment screen"
msgstr ""
#. module: pos_product_qty_available
#. openerp-web
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:83
#, python-format
msgid "Ready to launch your <b>point of sale</b>? <i>Click here</i>."
msgstr ""
"Bereit, Ihren <b>Point of Sale</b>zu starten? <i>Klicken Sie hier</i>."

71
pos_product_qty_available/i18n/es.po

@ -0,0 +1,71 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_product_qty_available
#
# Translators:
# charles paul requena palomino <rcharles84@gmail.com>, 2018
# Alexandr Frrost <alexandr.frrost@gmail.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-27 23:49+0000\n"
"PO-Revision-Date: 2018-04-27 23:49+0000\n"
"Last-Translator: Alexandr Frrost <alexandr.frrost@gmail.com>, 2018\n"
"Language-Team: Spanish (https://www.transifex.com/it-projects-llc/teams/76080/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: pos_product_qty_available
#. openerp-web
#: code:addons/pos_product_qty_available/static/src/xml/pos.xml:15
#, python-format
msgid "(of"
msgstr ""
#. module: pos_product_qty_available
#. openerp-web
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:11
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:68
#, python-format
msgid ""
"<p>Click to start the point of sale interface. It <b>runs on tablets</b>, "
"laptops, or industrial hardware.</p><p>Once the session launched, the system"
" continues to run without an internet connection.</p>"
msgstr ""
"<p>Haga clic para iniciar la interfaz del punto de venta. <b>Se ejecuta en "
"tabletas</b>, computadoras portátiles o hardware industrial.</p><p> Una vez "
"que se inicia la sesión, el sistema continúa ejecutándose sin conexión a "
"Internet.</p>"
#. module: pos_product_qty_available
#. openerp-web
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:43
#, python-format
msgid "Click the payment method"
msgstr ""
#. module: pos_product_qty_available
#. openerp-web
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:61
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:64
#, python-format
msgid "Close POS"
msgstr ""
#. module: pos_product_qty_available
#. openerp-web
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:36
#, python-format
msgid "Open the payment screen"
msgstr ""
#. module: pos_product_qty_available
#. openerp-web
#: code:addons/pos_product_qty_available/static/src/js/test_pos_quantities.js:83
#, python-format
msgid "Ready to launch your <b>point of sale</b>? <i>Click here</i>."
msgstr "¿Listo para lanzar su <b>punto de venta</b>? <i>Haga clic aquí</i>."

9
pos_product_qty_available/readme/CONTRIBUTORS.rst

@ -0,0 +1,9 @@
* Ivan Yelizariev <yelizariev@it-projects.info> (https://it-projects.info/team/yelizariev)
* Ilmir Karamov <karamov@it-projects.info> (https://it-projects.info/team/ilmir-k)
* Kolushov Alexandr <kolushov@it-projects.info> (https://it-projects.info/team/KolushovAlexandr)
* gaelTorrecillas <gael.torrecillas@mind-and-go.com> (https://github.com/gaelTorrecillas)
* manawi (https://github.com/manawi)

6
pos_product_qty_available/readme/CREDITS.rst

@ -0,0 +1,6 @@
The development of this module has been financially supported by:
* IT-Projects LLC <https://it-projects.info>
Original module: pos_product_available
Repository: https://github.com/it-projects-llc/pos-addons/tree/12.0/

3
pos_product_qty_available/readme/DESCRIPTION.rst

@ -0,0 +1,3 @@
This module allows you to see the available quantity of products in the POS.
At the *Point of Sale*, the quantity of the product is displayed in the card and in the order panel.

3
pos_product_qty_available/readme/USAGE.rst

@ -0,0 +1,3 @@
* Go to *Point of Sale*
* Now the quantity of the product is shown on the product card and on the order panel

BIN
pos_product_qty_available/static/description/icon.png

After

Width: 100  |  Height: 100  |  Size: 1.9 KiB

102
pos_product_qty_available/static/description/index.html

@ -0,0 +1,102 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">Available quantity of products in POS</h2>
<h3 class="oe_slogan">Let a cashier know how many products are available</h3>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<img src="screenshot.png"/>
</div>
</div>
<div class="oe_span6">
<p class="oe_mt32">
Adds available quantity at order panel
</p>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_span6">
<p class="oe_mt32">
Adds available quantity at products.
</p>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<img src="screenshot-2.png"/>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2>Usage</h2>
<p class="oe_mt32">
There no any settings. Just install the module and start POS.
</p>
<p class="oe_mt32">
Works in offline mode.
</p>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span8">
<h2>Need our service?</h2>
<p class="oe_mt32">Contact us by <a href="mailto:pos@it-projects.info">email</a> or fill out <a href="https://www.it-projects.info/page/website.contactus " target="_blank">request form</a></p>
<ul>
<li><a href="mailto:pos@it-projects.info">pos@it-projects.info <i class="fa fa-envelope-o"></i></a></li>
<li><a href="https://www.it-projects.info/page/website.contactus " target="_blank">https://www.it-projects.info/page/website.contactus <i class="fa fa-list-alt"></i></a></li>
<li><a href="https://m.me/itprojectsllc" target="_blank">https://m.me/itprojectsllc <i class="fa fa-facebook-square"></i></a></li>
<li>skype@it-projects.info <i class="fa fa-skype"></i></li>
</ul>
</div>
<div class="oe_span4">
<div class="stamp" style="width:200px;">
<div style="margin-top: 15px;
position: relative;
font-family:'Vollkorn', serif;
font-size: 16px;
line-height: 25px;
text-transform: uppercase;
font-weight: bold;
color: #75526b;
border: 3px dashed #75526b;
float: left;
padding: 4px 12px;
-webkit-transform: rotate(6deg);
-o-transform: rotate(6deg);
-moz-transform: rotate(6deg);
-ms-transform: rotate(6deg);">
Tested on Odoo<br/>10.0 community
</div>
<div style="margin-top: 15px;
position: relative;
font-family:'Vollkorn', serif;
font-size: 16px;
line-height: 25px;
text-transform: uppercase;
font-weight: bold;
color: #75526b;
border: 3px dashed #75526b;
float: left;
padding: 4px 12px;
-webkit-transform: rotate(-7deg);
-o-transform: rotate(-7deg);
-moz-transform: rotate(-7deg);
-ms-transform: rotate(-7deg);">
Tested on Odoo<br/>10.0 enterprise
</div>
</div>
</div>
</div>
</section>

BIN
pos_product_qty_available/static/description/screenshot-2.png

After

Width: 401  |  Height: 400  |  Size: 96 KiB

BIN
pos_product_qty_available/static/description/screenshot.png

After

Width: 443  |  Height: 386  |  Size: 39 KiB

24
pos_product_qty_available/static/src/css/pos.css

@ -0,0 +1,24 @@
.pos .product .qty-tag {
position: absolute;
top: 2px;
left: 2px;
vertical-align: top;
color: white;
line-height: 13px;
background: #7f82ac;
padding: 2px 5px;
border-radius: 2px;
font-weight: bold;
}
.pos .product .qty-tag.not-available {
background: #d882ac;
}
.pos .order .orderline .qty-info{
color: #777;
font-weight: bold;
font-style: normal;
}
.pos .order .orderline .qty-info.not-available{
color:red;
}

123
pos_product_qty_available/static/src/js/pos.js

@ -0,0 +1,123 @@
/* Copyright 2014-2017 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
Copyright 2016 gaelTorrecillas <https://github.com/gaelTorrecillas>
Copyright 2016 manawi <https://github.com/manawi>
Copyright 2017 Ilmir Karamov <https://it-projects.info/team/ilmir-k>
Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */
odoo.define('pos_product_qty_available.PosModel', function (require) {
"use strict";
var rpc = require('web.rpc');
var models = require('point_of_sale.models');
var PosModelSuper = models.PosModel.prototype;
models.PosModel = models.PosModel.extend({
load_server_data: function () {
var self = this;
var loaded = PosModelSuper.load_server_data.call(this);
var prod_model = _.find(this.models, function (model) {
return model.model === 'product.product';
});
if (prod_model) {
prod_model.fields.push('qty_available', 'type');
var context_super = prod_model.context;
prod_model.context = function (that) {
var ret = context_super(that);
ret.location = that.config.stock_location_id[0];
return ret;
};
var loaded_super = prod_model.loaded;
prod_model.loaded = function (that, products) {
loaded_super(that, products);
self.db.product_qtys = products;
};
return loaded;
}
return loaded.then(function () {
return rpc.query({
model: 'product.product',
method: 'search_read',
args: [],
fields: ['qty_available', 'type'],
domain: [['sale_ok', '=', true],
['available_in_pos', '=', true]],
context: {'location': self.config.stock_location_id[0]},
}).then(function (products) {
self.db.product_qtys = products;
});
});
},
set_product_qty_available: function (product, qty) {
product.qty_available = qty;
this.refresh_qty_available(product);
},
update_product_qty_from_order_lines: function (order) {
var self = this;
order.orderlines.each(function (line) {
var product = line.get_product();
product.qty_available -= line.get_quantity();
self.refresh_qty_available(product);
});
// Compatibility with pos_multi_session
order.trigger('new_updates_to_send');
},
after_load_server_data: function () {
var self = this;
var res = PosModelSuper.after_load_server_data
.apply(this, arguments);
_.each(this.db.product_qtys, function (v) {
_.extend(self.db.get_product_by_id(v.id), v);
});
return res;
},
refresh_qty_available:function (product) {
var $elem = $("[data-product-id='"+product.id+"'] .qty-tag");
$elem.html(product.qty_available);
if (product.qty_available <= 0 && !$elem.hasClass('not-available')) {
$elem.addClass('not-available');
}
},
push_order: function (order, opts) {
var pushed = PosModelSuper.push_order.call(this, order, opts);
if (order) {
this.update_product_qty_from_order_lines(order);
}
return pushed;
},
push_and_invoice_order: function (order) {
var invoiced = PosModelSuper.push_and_invoice_order
.call(this, order);
if (order && order.get_client() && order.orderlines) {
this.update_product_qty_from_order_lines(order);
}
return invoiced;
},
});
var OrderlineSuper = models.Orderline;
models.Orderline = models.Orderline.extend({
export_as_JSON: function () {
var data = OrderlineSuper.prototype.export_as_JSON
.apply(this, arguments);
data.qty_available = this.product.qty_available;
return data;
},
// Compatibility with pos_multi_session
apply_ms_data: function (data) {
if (OrderlineSuper.prototype.apply_ms_data) {
OrderlineSuper.prototype.apply_ms_data.apply(this, arguments);
}
var product = this.pos.db.get_product_by_id(data.product_id);
if (product.qty_available !== data.qty_available) {
this.pos.set_product_qty_available(product, data.qty_available);
}
},
});
});

104
pos_product_qty_available/static/src/js/test_pos_quantities.js

@ -0,0 +1,104 @@
/* Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */
odoo.define('pos_product_qty_available.tour', function (require) {
"use strict";
var tour = require("web_tour.tour");
var core = require('web.core');
var _t = core._t;
function open_pos_neworder () {
return [{
trigger: ".o_pos_kanban button.oe_kanban_action_button",
content: _t("Click to start the point of sale interface"),
position: "bottom",
}, {
content: "Switch to table or make dummy action",
trigger: '.table, .order-button.selected',
position: "bottom",
timeout: 20000,
}, {
content: 'waiting for loading to finish',
trigger: '.order-button.neworder-button',
}];
}
function add_product_to_order (product_name) {
return [{
content: 'buy ' + product_name,
trigger: '.product-list .product-name:contains("' + product_name + '")',
}, {
content: 'the ' + product_name + ' have been added to the order',
trigger: '.orderline:contains("' + product_name + '") .qty-info:contains("0")',
}];
}
function payment (pay_method) {
return [{
trigger: '.button.pay',
content: _t("Open the payment screen"),
}, {
content: "Choose Administrator like a cashier",
trigger: '.modal-dialog.cashier:not(.oe_hidden) .cashier .selection-item:contains("Mitchell Admin"), .payment-screen:not(.oe_hidden) h1:contains("Payment")',
}, {
extra_trigger: '.button.paymentmethod:contains("' + pay_method +'")',
trigger: '.button.paymentmethod:contains("' + pay_method +'")',
content: _t("Click the payment method"),
}, {
trigger: '.payment-screen .input-button.number-char:contains("2")',
content: 'Set payment amount',
}, {
extra_trigger: '.button.next.highlight:contains("Validate")',
trigger: '.button.next.highlight:contains("Validate")',
content: 'Validate payment',
}, {
extra_trigger: '.pos-sale-ticket',
trigger: '.button.next.highlight:contains("Next Order")',
content: 'Check proceeded validation',
}];
}
function close_pos () {
return [{
trigger: '.header-button:contains("Close")',
content: _t("Close POS"),
}, {
trigger: '.header-button.confirm:contains("Confirm")',
content: _t("Close POS"),
}, {
extra_trigger: ".o_pos_kanban button.oe_kanban_action_button",
trigger: '.breadcrumb li.active',
content: _t("Click to start the point of sale interface"),
position: "bottom",
}];
}
function check_quantity () {
return [{
content: 'check quantity',
extra_trigger: '.product-list .product:contains("LED Lamp") .qty-tag.not-available:contains("-1")',
trigger: '.order-button.selected',
}];
}
var steps = [tour.STEPS.SHOW_APPS_MENU_ITEM, {
trigger: '.o_app[data-menu-xmlid="point_of_sale.menu_point_root"]',
content: _t("Launch your point of sale"),
position: 'right',
edition: 'community',
}, {
trigger: '.o_app[data-menu-xmlid="point_of_sale.menu_point_root"]',
content: _t("Launch your point of sale"),
position: 'bottom',
edition: 'enterprise',
}];
steps = steps.concat(open_pos_neworder());
steps = steps.concat(add_product_to_order('LED Lamp'));
steps = steps.concat(payment('Cash (USD)'));
steps = steps.concat(close_pos());
steps = steps.concat(open_pos_neworder());
steps = steps.concat(check_quantity());
tour.register('tour_pos_product_qty_available', {test: true, url: '/web'}, steps);
});

27
pos_product_qty_available/static/src/xml/pos.xml

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Copyright 2014-2015 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -->
<templates id="template" xml:space="preserve">
<t t-extend="Product">
<t t-jquery=".product-img" t-operation="append">
<t t-if="product.type == 'product'">
<span t-attf-class="qty-tag #{product.qty_available lte 0 ? 'not-available':''}">
<t t-esc="product.qty_available"/>
</span>
</t>
</t>
</t>
<t t-extend="Orderline">
<t t-jquery=".info-list>t:first-child">
this.attr('t-if', "line.get_quantity_str() !== '1' || line.selected || line.get_product().qty_available lt line.quantity ");
</t>
<t t-jquery="t[t-esc='line.get_quantity_str()']" t-operation="after">
<t t-if="line.get_product().type == 'product'">
<t t-set='qty_available' t-value='line.get_product().qty_available'/>
(of <span t-attf-class="qty-info #{qty_available lt line.quantity ? 'not-available':''}"><t t-esc="qty_available"/></span>)
</t>
</t>
</t>
</templates>

3
pos_product_qty_available/tests/__init__.py

@ -0,0 +1,3 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import test_quantities

34
pos_product_qty_available/tests/test_quantities.py

@ -0,0 +1,34 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Kolushov Alex <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
import odoo.tests
@odoo.tests.common.at_install(True)
@odoo.tests.common.post_install(True)
class TestUi(odoo.tests.HttpCase):
def test_pos_product_qty_available(self):
# needed because tests are run before the module is marked as
# installed. In js web will only load qweb coming from modules
# that are returned by the backend in module_boot. Without
# this you end up with js, css but no qweb.
env = self.env
env['ir.module.module'].search([('name',
'=',
'pos_product_qty_available')],
limit=1).state = 'installed'
env['product.template'].search([('name', '=', 'LED Lamp')]).write({
'type': 'product',
})
# without a delay there might be problems
# caused by a not yet loaded button's action
self.phantom_js("/web",
"odoo.__DEBUG__.services['web_tour.tour']."
"run('tour_pos_product_qty_available', 500)",
"odoo.__DEBUG__.services['web_tour.tour']."
"tours.tour_pos_product_qty_available.ready",
login="admin", timeout=200)
Loading…
Cancel
Save