machine access sidebar funktioniert
This commit is contained in:
parent
fb96a54c2d
commit
9b16baf196
|
|
@ -1,3 +1,6 @@
|
||||||
|
/* This file is based on the original code from the OrderWidget in Odoo Point of Sale module (screen.js).
|
||||||
|
* It has been modified to create a sidebar that displays machine access information for the selected customer.*/
|
||||||
|
|
||||||
odoo.define('machine_access_sidebar', function (require) {
|
odoo.define('machine_access_sidebar', function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -7,8 +10,6 @@ odoo.define('machine_access_sidebar', function (require) {
|
||||||
var core = require('web.core');
|
var core = require('web.core');
|
||||||
var QWeb = core.qweb;
|
var QWeb = core.qweb;
|
||||||
|
|
||||||
console.log("✅ machine_access_sidebar.js geladen");
|
|
||||||
|
|
||||||
var MachineAccessSidebar = screens.ScreenWidget.extend({
|
var MachineAccessSidebar = screens.ScreenWidget.extend({
|
||||||
template: 'MachineAccessSidebar',
|
template: 'MachineAccessSidebar',
|
||||||
|
|
||||||
|
|
@ -22,15 +23,15 @@ odoo.define('machine_access_sidebar', function (require) {
|
||||||
this.render_access();
|
this.render_access();
|
||||||
},
|
},
|
||||||
|
|
||||||
set_partner: function(partner) {
|
update_machine_access: function(partner) {
|
||||||
console.log("🔁 Sidebar bekommt neuen Partner:", partner);
|
console.log("🔁 Sidebar aktualisiert Maschinenfreigaben für Partner:", partner);
|
||||||
this.partner = partner;
|
this.partner = partner;
|
||||||
this.render_access();
|
this.render_access();
|
||||||
},
|
},
|
||||||
|
|
||||||
render_access: function() {
|
render_access: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var partner = this.partner || this.pos.get_order().get_client();
|
var partner = this.partner;
|
||||||
if (!partner) {
|
if (!partner) {
|
||||||
this.$('.access-content').html("<p>Kein Kunde ausgewählt.</p>");
|
this.$('.access-content').html("<p>Kein Kunde ausgewählt.</p>");
|
||||||
return;
|
return;
|
||||||
|
|
@ -41,41 +42,39 @@ odoo.define('machine_access_sidebar', function (require) {
|
||||||
method: 'get_access_list_grouped',
|
method: 'get_access_list_grouped',
|
||||||
args: [partner.id],
|
args: [partner.id],
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
console.log("📥 Sidebar: Maschinenfreigaben geladen:", result);
|
|
||||||
var html = QWeb.render('PartnerMachineAccessList', {
|
var html = QWeb.render('PartnerMachineAccessList', {
|
||||||
areas: result || [],
|
areas: result || [],
|
||||||
});
|
});
|
||||||
self.$('.access-content').html(html);
|
self.$('.access-content').html(html);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
bind_order_events: function () {
|
||||||
|
var order = this.pos.get_order();
|
||||||
|
if (!order) return;
|
||||||
|
|
||||||
|
order.unbind('change:client', this);
|
||||||
|
order.bind('change:client', this, function () {
|
||||||
|
this.update_machine_access(order.get_client());
|
||||||
|
});
|
||||||
|
|
||||||
|
this.update_machine_access(order.get_client());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.Chrome.include({
|
chrome.Chrome.include({
|
||||||
build_widgets: function () {
|
build_widgets: function () {
|
||||||
this._super();
|
this._super();
|
||||||
|
|
||||||
var sidebar = new MachineAccessSidebar(this, {});
|
var sidebar = new MachineAccessSidebar(this, {});
|
||||||
this.sidebar_widget = sidebar;
|
this.sidebar_widget = sidebar;
|
||||||
sidebar.appendTo(this.$el);
|
sidebar.appendTo(this.$el);
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
function bind_order_events(order) {
|
|
||||||
if (order) {
|
|
||||||
order.bind('change:client', {}, function () {
|
|
||||||
sidebar.set_partner(order.get_client());
|
|
||||||
});
|
|
||||||
sidebar.set_partner(order.get_client());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.pos.bind('change:selectedOrder', this, function () {
|
|
||||||
bind_order_events(this.pos.get_order());
|
|
||||||
});
|
|
||||||
|
|
||||||
bind_order_events(this.pos.get_order());
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.pos.bind('change:selectedOrder', sidebar.bind_order_events, sidebar);
|
||||||
|
|
||||||
|
if (this.pos.get_order()) {
|
||||||
|
sidebar.bind_order_events();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user