Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 Popup alert-message for exceding available quantity of #761

Open
wants to merge 1 commit into
base: pos-addons-11.0-pos_product_sync
Choose a base branch
from
Open

🔥 Popup alert-message for exceding available quantity of #761

wants to merge 1 commit into from

Conversation

fedoranvar
Copy link

product by orderlines

'special_group': this.pos.config.negative_order_group_id[0],
'do_not_change_cashier': true,
'product-imgarguments': {'ask_untill_correct': true},
}).done(function(user){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions declared within loops referencing an outer scoped variable may lead to confusing semantics. (order, _super, self, force_validation)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take it easy, sharik

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to avoid this error you may create a variable, and if the variable is true call sudo_custom after the cycle

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check

pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
Copy link

@itpp-bot itpp-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 installable modules are updated:

├─ pos_product_available_negative/
|  └─ static/
|     └─ src/
|        └─ js/
|           └─ pos.js
└─ pos_product_sync/
   └─ doc/
      └─ changelog.rst

Not installable modules remain unchanged.

sent by ✌️ Odoo Review Bot

@@ -9,6 +10,27 @@ odoo.define('pos_product_available_negative.pos', function (require) {
var core = require('web.core');
var _t = core._t;

models.PosModel = models.PosModel.extend({
check_qty_of_orderlines: function(self, product, quantity_to_add) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get rid of passing self to arguments

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check

});
break;
if (line.product.type === 'product') {
if (line.product.id in unique_products) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stop making new Pull Requests you miss my notes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(unique_products[line.product.id]) { ....
Try to find an example when your method might lead to an error.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also you may combine those two ifs in one

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Was making new PR's in order to understand the reason of travis's errors about branch commits

  • unique_products - is a dictionary got implementation of using it in (https://stackoverflow.com/questions/1208222/how-to-do-associative-array-hashing-in-javascript)
    product.id - is a unique value, so errors may be if line.product.id - undefined
    in normal case:
    -- if we met this stockable product for the first time, so create new property in dictionary of this value, else add value to already existent property

  • Refactored that block of code

'special_group': this.pos.config.negative_order_group_id[0],
'do_not_change_cashier': true,
'product-imgarguments': {'ask_untill_correct': true},
}).done(function(user){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to avoid this error you may create a variable, and if the variable is true call sudo_custom after the cycle

pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
pos_product_available_negative/static/src/js/pos.js Outdated Show resolved Hide resolved
Copy link

@KolushovAlexandr KolushovAlexandr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better, only some stylistic remarks left

@@ -9,6 +10,25 @@ odoo.define('pos_product_available_negative.pos', function (require) {
var core = require('web.core');
var _t = core._t;

models.PosModel = models.PosModel.extend({
check_qty_of_orderlines: function(orderlines, product, quantity_to_add) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Function name mismatches with what it does
  • You can take orderlines from inside of the func. Get rid of the argument. Don't forget to remove lines where orderline variable was defined in the code for the func

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check

return;
}
var selected_orderline = order.get_selected_orderline();
var orderlines = this.pos.get_order().get_orderlines();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

order variable is already defined

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check

var orderlines = self.pos.get_order().get_orderlines();
if (product.type === 'product') {
if (product.qty_available <= 0) {
var that = this;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is not used anywhere

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check

Copy link
Member

@ilmir-k ilmir-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the version in manifest and changelog needs to be changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants