Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pos_product_available/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ class PosConfig(models.Model):
default_location_src_id = fields.Many2one(
"stock.location", related="picking_type_id.default_location_src_id"
)
product_quantity_type = fields.Selection(
[
("qty_available", "Quantity On Hand"),
("virtual_available", "Forecast Quantity"),
],
required=True,
default="qty_available"
)
14 changes: 7 additions & 7 deletions pos_product_available/static/src/js/pos.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ odoo.define("pos_product_available.PosModel", function(require) {
});
});
},
set_product_qty_available: function(product, qty) {
product.qty_available = qty;
set_product_qty_available: function(product, qty) { // Set_product_qty
product.qty = qty;
this.refresh_qty_available(product);
},
update_product_qty_from_order_lines: function(order) {
var self = this;
order.orderlines.each(function(line) {
var product = line.get_product();
product.qty_available = product.format_float_value(
product.qty_available - line.get_quantity(),
product.qty = product.format_float_value(
product.qty - line.get_quantity(),
{digits: [69, 3]}
);
self.refresh_qty_available(product);
Expand All @@ -78,7 +78,7 @@ odoo.define("pos_product_available.PosModel", function(require) {
refresh_qty_available: function(product) {
var $elem = $("[data-product-id='" + product.id + "'] .qty-tag");
$elem.html(product.rounded_qty());
if (product.qty_available <= 0 && !$elem.hasClass("not-available")) {
if (product.qty <= 0 && !$elem.hasClass("not-available")) {
$elem.addClass("not-available");
}
},
Expand All @@ -104,7 +104,7 @@ odoo.define("pos_product_available.PosModel", function(require) {
models.Orderline = models.Orderline.extend({
export_as_JSON: function() {
var data = OrderlineSuper.prototype.export_as_JSON.apply(this, arguments);
data.qty_available = this.product.qty_available;
data.qty_available = this.product.qty;
return data;
},
// Compatibility with pos_multi_session
Expand All @@ -113,7 +113,7 @@ odoo.define("pos_product_available.PosModel", function(require) {
OrderlineSuper.prototype.apply_ms_data.apply(this, arguments);
}
var product = this.pos.db.get_product_by_id(data.product_id);
if (product.qty_available !== data.qty_available) {
if (product.qty !== data.qty_available) {
this.pos.set_product_qty_available(product, data.qty_available);
}
},
Expand Down
2 changes: 2 additions & 0 deletions pos_product_available/views/views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
</div>
<div class="o_setting_right_pane">
<label for="show_qtys" />
<div class="text-muted">Set Quantity Type</div>
<field name="product_quantity_type" />
</div>
</div>
</xpath>
Expand Down