|
|
@ -4,18 +4,18 @@ import { usePos } from "@point_of_sale/app/store/pos_hook"; |
|
|
|
import { patch } from "@web/core/utils/patch"; |
|
|
|
import { useService } from "@web/core/utils/hooks"; |
|
|
|
import { useRef, useState } from "@odoo/owl"; |
|
|
|
|
|
|
|
patch(ProductCard.prototype, { |
|
|
|
setup() { |
|
|
|
super.setup(); |
|
|
|
this.pos = usePos(); |
|
|
|
this.orm = useService('orm'); |
|
|
|
this.state = useState({ |
|
|
|
qty_available: null, |
|
|
|
incoming_qty: null, |
|
|
|
outgoing_qty: null, |
|
|
|
display_stock: false |
|
|
|
display_stock: false, |
|
|
|
}); |
|
|
|
this.pos = usePos(); |
|
|
|
this.orm = useService('orm'); |
|
|
|
|
|
|
|
}, |
|
|
|
async fetchProductDetails(productId) { |
|
|
|
const product = await this.orm.call("product.product", "read", [[productId], ["name", "id", "incoming_qty","outgoing_qty","qty_available"]]); |
|
|
@ -28,8 +28,8 @@ patch(ProductCard.prototype, { |
|
|
|
const product_product = this.pos.product_product; |
|
|
|
const stock_product = this.pos.stock_quant; |
|
|
|
const main_product = product_product.find(product => product.id === productId); |
|
|
|
const product_tmpl_id = main_product._raw.product_tmpl_id; |
|
|
|
const product_variants = product_product.filter(product => product._raw.product_tmpl_id === product_tmpl_id); |
|
|
|
const product_tmpl_id = main_product.raw.product_tmpl_id; |
|
|
|
const product_variants = product_product.filter(product => product.raw.product_tmpl_id === product_tmpl_id); |
|
|
|
let total_qty_available = 0; |
|
|
|
product_variants.forEach((variant) => { |
|
|
|
if (variant.qty_available) { |
|
|
@ -51,8 +51,8 @@ patch(ProductCard.prototype, { |
|
|
|
let outgoing = 0; |
|
|
|
let incoming = 0; |
|
|
|
const main_product = product_product.find(product => product.id === current_product); |
|
|
|
const product_tmpl_id = main_product._raw.product_tmpl_id; |
|
|
|
const product_variants = product_product.filter(product => product._raw.product_tmpl_id === product_tmpl_id); |
|
|
|
const product_tmpl_id = main_product.raw.product_tmpl_id; |
|
|
|
const product_variants = product_product.filter(product => product.raw.product_tmpl_id === product_tmpl_id); |
|
|
|
stock_product.forEach((product) => { |
|
|
|
if (product && product.product_id) { |
|
|
|
const product_id = product.product_id.id; |
|
|
@ -65,9 +65,9 @@ patch(ProductCard.prototype, { |
|
|
|
}); |
|
|
|
move_line.forEach((line) => { |
|
|
|
if (line && line.product_id) { |
|
|
|
if(line.product_id.id == current_product && this.pos.res_setting && this.pos.res_setting._raw.stock_location_id[1] == line._raw.location_dest_id[1]){ |
|
|
|
if(line.product_id.id == current_product && this.pos.res_setting && this.pos.res_setting.raw.stock_location_id[1] == line.raw.location_dest_id[1]){ |
|
|
|
incoming = incoming + line.product_id.incoming_qty; |
|
|
|
}if(line.product_id.id == current_product && this.pos.res_setting && this.pos.res_setting._raw.stock_location_id && this.pos.res_setting._raw.stock_location_id[1] == line._raw.location_id[1]){ |
|
|
|
}if(line.product_id.id == current_product && this.pos.res_setting && this.pos.res_setting.raw.stock_location_id && this.pos.res_setting.raw.stock_location_id[1] == line.raw.location_id[1]){ |
|
|
|
outgoing = outgoing + line.product_id.outgoing_qty; |
|
|
|
} |
|
|
|
} |
|
|
@ -94,7 +94,6 @@ patch(ProductCard.prototype, { |
|
|
|
this.state.display_stock = true; |
|
|
|
return { |
|
|
|
display_stock: this.pos.res_setting.display_stock |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} else { |
|
|
|