Avecinal/avecinal#70 add pos_product_hide_subcategory module. Only show products of the selected category in the PoS

This commit is contained in:
Luis 2025-04-14 11:20:29 +02:00
parent 612b72778e
commit 4ab5fa28e8
4 changed files with 62 additions and 0 deletions

View file

@ -0,0 +1,5 @@
============================
Pos Product Hide Subcategory
============================
Displays only the products of the selected category, hiding those of the child categories.

View file

View file

@ -0,0 +1,19 @@
# Copyright 2025 Criptomart
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Pos Product Hide Subcategory",
"summary": """Displays only the products of the selected category, hiding those of the child categories.""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Criptomart",
"website": "https://criptomart.net",
"depends": ["point_of_sale"],
"assets": {
"point_of_sale.assets": [
"pos_product_hide_subcategory/static/src/js/db.js",
]
},
"data": [],
"demo": [],
}

View file

@ -0,0 +1,38 @@
odoo.define("pos_product_hide_subcategory.db", function (require) {
"use strict";
var PosDB = require("point_of_sale.DB");
var utils = require('web.utils');
PosDB.include({
add_products: function (products) {
var stored_categories = this.product_by_category_id;
if(!(products instanceof Array)){
products = [products];
}
for(var i = 0, len = products.length; i < len; i++){
var product = products[i];
if (product.id in this.product_by_id) continue;
if (product.available_in_pos){
var search_string = utils.unaccent(this._product_search_string(product));
var categ_id = product.pos_categ_id ? product.pos_categ_id[0] : this.root_category_id;
product.product_tmpl_id = product.product_tmpl_id[0];
if(!stored_categories[categ_id]){
stored_categories[categ_id] = [];
}
stored_categories[categ_id].push(product.id);
if(this.category_search_string[categ_id] === undefined){
this.category_search_string[categ_id] = '';
}
this.category_search_string[categ_id] += search_string;
}
this.product_by_id[product.id] = product;
if(product.barcode && product.active){
this.product_by_barcode[product.barcode] = product;
}
}
},
});
});