Browse Source

May 08: [FIX] Bug Fixed 'pos_low_sales_price'

pull/320/head
RisvanaCybro 12 months ago
parent
commit
7d83f48cfc
  1. 60
      pos_low_sales_price/static/src/js/high_cost.js

60
pos_low_sales_price/static/src/js/high_cost.js

@ -2,52 +2,52 @@ odoo.define('pos_low_sales_price.validation', function(require) {
'use strict'; 'use strict';
const PaymentScreen = require('point_of_sale.PaymentScreen'); const PaymentScreen = require('point_of_sale.PaymentScreen');
const Registries = require('point_of_sale.Registries'); const Registries = require('point_of_sale.Registries');
// Created new class validation that extends PaymentScreen and overrides the validateOrder // Created new class validation that extends PaymentScreen and overrides the validateOrder
const validation = PaymentScreen => const validation = PaymentScreen =>
class extends PaymentScreen { class extends PaymentScreen {
async validateOrder(isForceValidate) { async validateOrder(isForceValidate) {
var self = this var self = this;
var condition = true var product_list = [];
var flag = true var orderlines = this.env.pos.selectedOrder.orderlines;
var normal_flow = false
var number = 1 // Checking condition for each order line
var orderlines = this.env.pos.selectedOrder.orderlines for (const line of orderlines) {
// Checking condition for each orderlines if (line.product.lst_price < line.product.standard_price || line.price < line.product.standard_price) {
for (const lines of orderlines) { product_list.push("'" + line.product.display_name + "'");
if (lines.product.lst_price < lines.product.standard_price || lines.price < lines.product.standard_price) {
condition = false;
const { confirmed } = await self.showPopup('ConfirmPopup', {
title: 'Alert',
body: 'The Sales Price of ' + lines.product.display_name +
' is less than the Cost Price. Do you want to continue validation?',
});
if (confirmed) {
// Set flag to false if popup is confirmed
if (orderlines.length === number) {
flag = false;
}
} }
} }
else{
// Set normal_flow to true if there is no pop-up
normal_flow = true
} if (product_list.length > 0) {
number = number + 1 var content = '';
if (product_list.length === 1) {
content = 'The Sales Price of ' + product_list.join(' ') +
' is less than the Cost Price. Do you want to continue validation?';
} else {
var lastIndex = product_list.length - 1;
product_list[lastIndex] = "and " + product_list[lastIndex];
content = 'The Sales Prices of ' + product_list.join(', ') +
' are less than the Cost Price. Do you want to continue validation?';
} }
const { confirmed } = await self.showPopup('ConfirmPopup', {
title: 'Alert',
body: content,
});
if (normal_flow == true){ if (confirmed) {
// Order validation for normal flow
super.validateOrder(isForceValidate); super.validateOrder(isForceValidate);
} }
if (flag==false && condition== false && normal_flow== false){ } else {
// Order validation for low price product after confirming the pop-up
super.validateOrder(isForceValidate); super.validateOrder(isForceValidate);
} }
} }
}; };
Registries.Component.extend(PaymentScreen, validation); Registries.Component.extend(PaymentScreen, validation);
return PaymentScreen; return PaymentScreen;
}); });

Loading…
Cancel
Save