Skip to content

Commit

Permalink
Merge branch '12.0' into 12.0-c6e7e846da21776622829dd972eba34049060fd6
Browse files Browse the repository at this point in the history
  • Loading branch information
KolushovAlexandr authored Nov 15, 2019
2 parents 87debdc + f7649ec commit 53ab19e
Showing 8 changed files with 68 additions and 19 deletions.
6 changes: 6 additions & 0 deletions pos_product_available/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -3,6 +3,12 @@

- **New:** Added option to show product quantities

`1.0.7`
-------

- **Fix:** Non rounded long values of quantities


`1.0.6`
-------

6 changes: 6 additions & 0 deletions pos_product_available/i18n/pos_product_available.pot
Original file line number Diff line number Diff line change
@@ -43,6 +43,12 @@ msgstr ""
msgid "Close POS"
msgstr ""

#. module: pos_product_available
#: code:addons/pos_product_available/tests/test_quantities.py:32
#, python-format
msgid "INV: %s"
msgstr ""

#. module: pos_product_available
#. openerp-web
#: code:addons/pos_product_available/static/src/js/test_pos_quantities.js:42
21 changes: 17 additions & 4 deletions pos_product_available/static/src/js/pos.js
Original file line number Diff line number Diff line change
@@ -2,13 +2,14 @@
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>
Copyright 2018,2019 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_available.PosModel', function(require){
"use strict";

var rpc = require('web.rpc');
var models = require('point_of_sale.models');
var field_utils = require('web.field_utils');

var PosModelSuper = models.PosModel.prototype;
models.PosModel = models.PosModel.extend({
@@ -20,6 +21,7 @@ odoo.define('pos_product_available.PosModel', function(require){
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;
@@ -57,7 +59,8 @@ odoo.define('pos_product_available.PosModel', function(require){
var self = this;
order.orderlines.each(function(line){
var product = line.get_product();
product.qty_available -= line.get_quantity();
product.qty_available = product.format_float_value(
product.qty_available - line.get_quantity(), {digits: [69, 3]});
self.refresh_qty_available(product);
});
// compatibility with pos_multi_session
@@ -73,7 +76,7 @@ odoo.define('pos_product_available.PosModel', function(require){
},
refresh_qty_available:function(product){
var $elem = $("[data-product-id='"+product.id+"'] .qty-tag");
$elem.html(product.qty_available);
$elem.html(product.rounded_qty());
if (product.qty_available <= 0 && !$elem.hasClass('not-available')){
$elem.addClass('not-available');
}
@@ -114,7 +117,17 @@ odoo.define('pos_product_available.PosModel', function(require){
this.pos.set_product_qty_available(product, data.qty_available);
}
},

});

var ProductSuper = models.Product;
models.Product = models.Product.extend({
format_float_value: function(val) {
var value = parseFloat(val);
value = field_utils.format.float(value, {digits: [69, 3]});
return String(parseFloat(value));
},
rounded_qty: function() {
return this.format_float_value(this.qty_available);
},
});
});
22 changes: 12 additions & 10 deletions pos_product_available/static/src/js/test_pos_quantities.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
/* Copyright 2018-2019 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_available.tour', function (require) {
"use strict";
@@ -16,7 +16,7 @@ odoo.define('pos_product_available.tour', function (require) {
content: "Switch to table or make dummy action",
trigger: '.table, .order-button.selected',
position: "bottom",
timeout: 20000,
timeout: 30000,
}, {
content: 'waiting for loading to finish',
trigger: '.order-button.neworder-button',
@@ -74,10 +74,10 @@ odoo.define('pos_product_available.tour', function (require) {
}];
}

function check_quantity() {
function check_quantity(qty) {
return [{
content: 'check quantity',
extra_trigger: '.product-list .product:contains("LED Lamp") .qty-tag.not-available:not(:contains("0"))',
extra_trigger: '.product-list .product:contains("LED Lamp") .qty-tag:contains(' + String(qty) + '):not(.not-available)',
trigger: '.order-button.selected',
}];
}
@@ -93,12 +93,14 @@ odoo.define('pos_product_available.tour', function (require) {
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());
steps = steps.concat(
open_pos_neworder(),
add_product_to_order('LED Lamp'),
payment('Cash (USD)'),
close_pos(),
open_pos_neworder(),
check_quantity(2)
);

tour.register('tour_pos_product_available', { test: true, url: '/web' }, steps);

4 changes: 2 additions & 2 deletions pos_product_available/static/src/xml/pos.xml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
<t t-jquery=".product-img" t-operation="append">
<t t-if="widget.pos.config.show_qtys &amp;&amp; product.type == 'product'">
<span t-attf-class="qty-tag #{product.qty_available lte 0 ? 'not-available':''}">
<t t-esc="product.qty_available"/>
<t t-esc="product.rounded_qty()"/>
</span>
</t>
</t>
@@ -19,7 +19,7 @@
<t t-jquery="t[t-esc='line.get_quantity_str()']" t-operation="after">
<t t-if="widget.pos.config.show_qtys &amp;&amp; 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>)
(of <span t-attf-class="qty-info #{qty_available lt line.quantity ? 'not-available':''}"><t t-esc="line.get_product().rounded_qty()"/></span>)
</t>
</t>
</t>
26 changes: 24 additions & 2 deletions pos_product_available/tests/test_quantities.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# Copyright 2018-2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

import odoo.tests
from odoo import tools, _


@odoo.tests.common.at_install(True)
@@ -17,10 +18,31 @@ def test_pos_product_available(self):
env = self.env
env['ir.module.module'].search([('name', '=', 'pos_product_available')], limit=1).state = 'installed'

env['product.template'].search([('name', '=', 'LED Lamp')]).write({
product = env['product.product'].search([('name', '=', 'LED Lamp')], limit=1)
product.product_tmpl_id.write({
'type': 'product',
})

# updating product qty
new_quantity = 3
company_user = self.env.user.company_id
location = self.env['stock.warehouse'].search([('company_id', '=', company_user.id)], limit=1).lot_stock_id
th_qty = product.qty_available
inventory = self.env['stock.inventory'].create({
'name': _('INV: %s') % tools.ustr(product.display_name),
'filter': 'product',
'product_id': product.id,
'location_id': location.id,
'line_ids': [(0, 0, {
'product_qty': new_quantity,
'location_id': location.id,
'product_id': product.id,
'product_uom_id': product.uom_id.id,
'theoretical_qty': th_qty,
})],
})
inventory.action_validate()

# 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_available', 500)",
2 changes: 1 addition & 1 deletion qr_payments/__manifest__.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
"summary": """Technical module to support qr-based payments like Alipay, WeChat""",
"category": "Hidden",
# "live_test_url": "",
"images": [],
"images": ["images/QR-based payments.jpg"],
"version": "12.0.1.0.1",
"application": False,

Binary file added qr_payments/images/QR-based payments.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 53ab19e

Please sign in to comment.