[ADD] open_workshop_pos: Standard-Kategorie beim POS-Start
- Automatische Auswahl einer konfigurierbaren Standard-Kategorie - Konfiguration über Kategorie-Name oder ID möglich - Aktuell auf 'Nutzung' gesetzt - Vereinfacht die Navigation für häufig genutzte Kategorien
This commit is contained in:
parent
e443f8709d
commit
93385abb0f
|
|
@ -38,6 +38,7 @@ Autor: HobbyHimmel
|
|||
'open_workshop_pos/static/src/js/ows_pos_customer_sidebar.js',
|
||||
'open_workshop_pos/static/src/js/ows_machine_access_list.js',
|
||||
'open_workshop_pos/static/src/js/ows_product_screen_template_patch.js',
|
||||
'open_workshop_pos/static/src/js/ows_product_screen_default_category.js',
|
||||
|
||||
# XML Templates
|
||||
'open_workshop_pos/static/src/xml/ows_pos_sidebar.xml',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
// ows_product_screen_default_category.js
|
||||
// @odoo-module
|
||||
|
||||
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { onMounted } from "@odoo/owl";
|
||||
|
||||
// Konfiguration: Tragen Sie hier den Namen oder die ID der Standardkategorie ein
|
||||
const DEFAULT_CATEGORY_NAME = "Nutzung"; // Name der Kategorie
|
||||
// oder verwenden Sie eine ID:
|
||||
// const DEFAULT_CATEGORY_ID = 1; // ID der Kategorie
|
||||
|
||||
patch(ProductScreen.prototype, {
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
onMounted(() => {
|
||||
// Setze die Standardkategorie beim Laden des Screens
|
||||
this.setDefaultCategory();
|
||||
});
|
||||
},
|
||||
|
||||
setDefaultCategory() {
|
||||
// Suche die Kategorie nach Name oder ID
|
||||
let category = null;
|
||||
|
||||
if (typeof DEFAULT_CATEGORY_NAME !== 'undefined' && DEFAULT_CATEGORY_NAME) {
|
||||
// Suche nach Name
|
||||
const categories = this.pos.models["pos.category"].getAll();
|
||||
category = categories.find(cat => cat.name === DEFAULT_CATEGORY_NAME);
|
||||
} else if (typeof DEFAULT_CATEGORY_ID !== 'undefined' && DEFAULT_CATEGORY_ID) {
|
||||
// Suche nach ID
|
||||
category = this.pos.models["pos.category"].get(DEFAULT_CATEGORY_ID);
|
||||
}
|
||||
|
||||
if (category) {
|
||||
this.pos.setSelectedCategory(category.id);
|
||||
}
|
||||
},
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user