Skip to content

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

Open
fedoranvar wants to merge 1 commit intoit-projects-llc:pos-addons-11.0-pos_product_syncfrom
fedoranvar:pos-addons-11.0-pos_product_sync
Open

🔥 Popup alert-message for exceding available quantity of#761
fedoranvar wants to merge 1 commit intoit-projects-llc:pos-addons-11.0-pos_product_syncfrom
fedoranvar:pos-addons-11.0-pos_product_sync

Conversation

@fedoranvar
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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

Copy link
Copy Markdown

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
Copy Markdown
Author

Choose a reason for hiding this comment

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

check

Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Copy link
Copy Markdown

@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

Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
var _t = core._t;

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

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
Copy Markdown
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) {
Copy link
Copy Markdown

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

Copy link
Copy Markdown

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.

Copy link
Copy Markdown

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
Copy Markdown
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){
Copy link
Copy Markdown

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

Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Comment thread pos_product_available_negative/static/src/js/pos.js Outdated
Copy link
Copy Markdown

@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

var _t = core._t;

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

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
Copy Markdown
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();
Copy link
Copy Markdown

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
Copy Markdown
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;
Copy link
Copy Markdown

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
Copy Markdown
Author

Choose a reason for hiding this comment

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

check

Copy link
Copy Markdown
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