|
|
@ -6,14 +6,14 @@ import Registries from 'point_of_sale.Registries'; |
|
|
import ProductScreen from 'point_of_sale.ProductScreen'; |
|
|
import ProductScreen from 'point_of_sale.ProductScreen'; |
|
|
import { Gui } from 'point_of_sale.Gui'; |
|
|
import { Gui } from 'point_of_sale.Gui'; |
|
|
var models = require('point_of_sale.models'); |
|
|
var models = require('point_of_sale.models'); |
|
|
models.load_fields('product.product', ['qty_available','virtual_available']); |
|
|
models.load_fields('product.product', ['qty_available','virtual_available','detailed_type']); |
|
|
const RestrictProductScreen = (ProductScreen) => class RestrictProductScreen extends ProductScreen { |
|
|
const RestrictProductScreen = (ProductScreen) => class RestrictProductScreen extends ProductScreen { |
|
|
async _clickProduct(event) { |
|
|
async _clickProduct(event) { |
|
|
// Overriding product item click to restrict product out of stock
|
|
|
// Overriding product item click to restrict product out of stock
|
|
|
const product = event.detail; |
|
|
const product = event.detail; |
|
|
var type = this.env.pos.config.stock_type |
|
|
var type = this.env.pos.config.stock_type |
|
|
if (this.env.pos.config.is_restrict_product && ((type == 'qty_on_hand') && (product.qty_available <= 0)) | ((type == 'virtual_qty') && (product.virtual_available <= 0)) | |
|
|
if (this.env.pos.config.is_restrict_product && ((type == 'qty_on_hand') && (product.qty_available <= 0)) | ((type == 'virtual_qty') && (product.virtual_available <= 0)) | |
|
|
((product.qty_available <= 0) && (product.virtual_available <= 0))) { |
|
|
((product.qty_available <= 0) && (product.virtual_available <= 0)) && (product.detailed_type != 'service' && (!(product.to_weight)))) { |
|
|
// If the product restriction is activated in the settings and quantity is out stock, it show the restrict popup.
|
|
|
// If the product restriction is activated in the settings and quantity is out stock, it show the restrict popup.
|
|
|
this.showPopup("RestrictStockPopup", { |
|
|
this.showPopup("RestrictStockPopup", { |
|
|
body: product.display_name, |
|
|
body: product.display_name, |
|
|
@ -29,7 +29,7 @@ const RestrictProductScreen = (ProductScreen) => class RestrictProductScreen ext |
|
|
var out_of_stock = false |
|
|
var out_of_stock = false |
|
|
for (let rec of this.env.pos.get_order().orderlines.models) { |
|
|
for (let rec of this.env.pos.get_order().orderlines.models) { |
|
|
if (this.env.pos.config.is_restrict_product && ((type == 'qty_on_hand') && (rec.quantity > rec.product.qty_available)) | ((type == 'virtual_qty') && (rec.quantity > rec.product.virtual_available)) | |
|
|
if (this.env.pos.config.is_restrict_product && ((type == 'qty_on_hand') && (rec.quantity > rec.product.qty_available)) | ((type == 'virtual_qty') && (rec.quantity > rec.product.virtual_available)) | |
|
|
((rec.quantity > rec.product.qty_available) && (rec.quantity > rec.product.virtual_available))) { |
|
|
((rec.quantity > rec.product.qty_available) && (rec.quantity > rec.product.virtual_available)) && (rec.product.detailed_type != 'service' && (!(rec.product.to_weight)))) { |
|
|
out_of_stock = true |
|
|
out_of_stock = true |
|
|
this.showPopup("OutOfStockPopup", { |
|
|
this.showPopup("OutOfStockPopup", { |
|
|
body: rec.product.display_name, |
|
|
body: rec.product.display_name, |
|
|
|