8 changed files with 127 additions and 0 deletions
@ -0,0 +1,36 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Gayathri V(odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from odoo import api, models |
||||
|
|
||||
|
|
||||
|
class ProductProduct(models.Model): |
||||
|
|
||||
|
_inherit = 'product.product' |
||||
|
|
||||
|
@api.model |
||||
|
def get_product_quantity(self): |
||||
|
""" |
||||
|
Retrieves a list of products that are available in the Point of Sale (POS) system, |
||||
|
including their current available quantity and virtual available quantity. |
||||
|
""" |
||||
|
products= self.search_read([('available_in_pos','=',True)],fields=['id', 'qty_available','virtual_available']) |
||||
|
return products |
@ -0,0 +1,11 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
/* |
||||
|
* This file is used to store a popup for stocks out of stock for forced orders. |
||||
|
*/ |
||||
|
import AbstractAwaitablePopup from 'point_of_sale.AbstractAwaitablePopup'; |
||||
|
import Registries from 'point_of_sale.Registries'; |
||||
|
|
||||
|
class OutOfStockPopup extends AbstractAwaitablePopup { |
||||
|
} |
||||
|
OutOfStockPopup.template = 'OutOfStockPopup'; |
||||
|
Registries.Component.add(OutOfStockPopup); |
@ -0,0 +1,34 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
import Registries from 'point_of_sale.Registries'; |
||||
|
import ProductItem from 'point_of_sale.ProductItem'; |
||||
|
var rpc = require('web.rpc'); |
||||
|
const { hooks } = owl; |
||||
|
const { onWillStart } = hooks; |
||||
|
|
||||
|
const ProductStockDisplay = (ProductItem) => class ProductStockDisplay extends ProductItem { |
||||
|
|
||||
|
async willStart() { |
||||
|
var self = this; |
||||
|
var result = null |
||||
|
await rpc.query({ |
||||
|
model: "product.product", |
||||
|
method: "get_product_quantity", |
||||
|
}).then(function (data) { |
||||
|
// Iterate through each product in the data received from the RPC query
|
||||
|
result=data |
||||
|
data.forEach(function (productData) { |
||||
|
// Find the corresponding product in product_by_id by matching product ID
|
||||
|
var productInDb = self.env.pos.db.product_by_id[productData.id]; |
||||
|
if (productInDb) { |
||||
|
// Compare qty_available and virtual_available between the two data sets
|
||||
|
if (productInDb.qty_available !== productData.qty_available || productInDb.virtual_available !== productData.virtual_available) { |
||||
|
// If there's a change, update the product in product_by_id
|
||||
|
productInDb.qty_available = productData.qty_available; |
||||
|
productInDb.virtual_available = productData.virtual_available; |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
Registries.Component.extend(ProductItem, ProductStockDisplay); |
@ -0,0 +1,19 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<template id="template" xml:space="preserve"> |
||||
|
<!--This template is used for registering a popup for restrict product from ordering--> |
||||
|
<t t-name="OutOfStockPopup" owl="1"> |
||||
|
<div role="dialog" class="modal-dialog"> |
||||
|
<div class="popup popup-text popup-med restrict-stock-popup"> |
||||
|
<div class="title">Product Out of Stock</div> |
||||
|
<div style="height:100px; margin-top:20px;"> |
||||
|
<span style="color:#811331"><t t-esc="props.body"/></span> is out of stock. |
||||
|
</div> |
||||
|
<div class="footer"> |
||||
|
<div class="button cancel" style="color:red" t-on-click="cancel"> |
||||
|
Cancel |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</t> |
||||
|
</template> |
Loading…
Reference in new issue