POS funktioniert nun mit dynamischen Einweisungen aus open_workshop
This commit is contained in:
parent
b52efaf563
commit
bbdca32b59
|
|
@ -1 +1,2 @@
|
||||||
from . import models
|
from . import models
|
||||||
|
from . import controllers # <- hinzufügen
|
||||||
|
|
@ -10,12 +10,20 @@
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'views/menu_views.xml',
|
'views/menu_views.xml',
|
||||||
'views/machine_area_views.xml',
|
'views/machine_area_views.xml',
|
||||||
'views/machine_views.xml', # <--- diese Zeile hinzufügen
|
'views/machine_views.xml',
|
||||||
'views/res_partner_view.xml',
|
'views/res_partner_view.xml',
|
||||||
|
'views/assets.xml',
|
||||||
|
'data/demo_data.xml',
|
||||||
],
|
],
|
||||||
'demo': [
|
'qweb': [
|
||||||
'demo/demo_data.xml', # <--- DEMO-DATEN HINZUGEFÜGT
|
'static/src/xml/partner_access_popup.xml',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
'assets': {
|
||||||
|
'point_of_sale.assets': [
|
||||||
|
'static/src/js/partner_access_popup.js',
|
||||||
|
'static/src/js/debug.js',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
controllers/__init__.py
Normal file
3
controllers/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Datei: open_workshop/controllers/__init__.py
|
||||||
|
|
||||||
|
from . import pos_access
|
||||||
11
controllers/pos_access.py
Normal file
11
controllers/pos_access.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Datei: controllers/pos_access.py
|
||||||
|
|
||||||
|
from odoo import http
|
||||||
|
from odoo.http import request
|
||||||
|
|
||||||
|
class OpenWorkshopPOSController(http.Controller):
|
||||||
|
|
||||||
|
@http.route('/open_workshop/partner_access', type='json', auth='user')
|
||||||
|
def get_partner_machine_access(self, partner_id):
|
||||||
|
Machine = request.env['ows.machine'].sudo()
|
||||||
|
return Machine.get_access_list_grouped(partner_id)
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<odoo noupdate="1">
|
<odoo>
|
||||||
|
|
||||||
<!-- Bereiche -->
|
<!-- Bereiche -->
|
||||||
<record id="area_fablab" model="ows.machine.area">
|
<record id="area_fablab" model="ows.machine.area">
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
from odoo import models, fields
|
from odoo import models, fields, api
|
||||||
|
import logging
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
_logger.info("✅ ows_models.py geladen")
|
||||||
|
|
||||||
class OwsMachineArea(models.Model):
|
class OwsMachineArea(models.Model):
|
||||||
_name = 'ows.machine.area'
|
_name = 'ows.machine.area'
|
||||||
|
|
@ -29,6 +32,27 @@ class OwsMachine(models.Model):
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
return [(rec.id, f"{rec.name} ({rec.code})") for rec in self]
|
return [(rec.id, f"{rec.name} ({rec.code})") for rec in self]
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def get_access_list_grouped(self, partner_id):
|
||||||
|
areas = self.env['ows.machine.area'].search([], order="name")
|
||||||
|
_logger.info("🔍 Maschinenbereiche: %s", areas.mapped('name'))
|
||||||
|
_logger.info("🔍 Partner_id: %s", partner_id)
|
||||||
|
res = []
|
||||||
|
for area in areas:
|
||||||
|
machines = self.search([('area_id', '=', area.id)], order="name")
|
||||||
|
machine_list = []
|
||||||
|
for machine in machines:
|
||||||
|
has_access = bool(self.env['ows.machine.access'].search([
|
||||||
|
('partner_id', '=', partner_id),
|
||||||
|
('machine_id', '=', machine.id),
|
||||||
|
], limit=1))
|
||||||
|
machine_list.append({
|
||||||
|
'name': machine.name,
|
||||||
|
'has_access': has_access,
|
||||||
|
})
|
||||||
|
res.append({'area': area.name, 'machines': machine_list})
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
class OwsMachineAccess(models.Model):
|
class OwsMachineAccess(models.Model):
|
||||||
_name = 'ows.machine.access'
|
_name = 'ows.machine.access'
|
||||||
|
|
|
||||||
32
static/src/js/debug.js
Normal file
32
static/src/js/debug.js
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
odoo.define('open_workshop.debug', function (require) {
|
||||||
|
"use strict";
|
||||||
|
var models = require('point_of_sale.models');
|
||||||
|
var screens = require('point_of_sale.screens');
|
||||||
|
|
||||||
|
// Laden der zusätzlichen Felder
|
||||||
|
models.load_fields('res.partner', [
|
||||||
|
'vvow_document_id'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Erweiterung von ClientListScreenWidget, um die Kundendetails anzuzeigen
|
||||||
|
screens.ClientListScreenWidget.include({
|
||||||
|
display_client_details: function(partner, clickpos) {
|
||||||
|
this._super(partner, clickpos);
|
||||||
|
console.log('ClientListScreenWidget Partner Daten:', partner);
|
||||||
|
if (partner.vvow_document_id) {
|
||||||
|
console.log('vvow_document_id:', partner.vvow_document_id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Erweiterung von ClientDetailsWidget, um die Kundendetails anzuzeigen
|
||||||
|
screens.ClientDetailsWidget.include({
|
||||||
|
show: function() {
|
||||||
|
this._super();
|
||||||
|
console.log('ClientDetailsWidget Showing client details:', this.partner);
|
||||||
|
if (this.partner && this.partner.vvow_document_id) {
|
||||||
|
console.log('vvow_document_id:', this.partner.vvow_document_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
39
static/src/js/partner_access_popup.js
Normal file
39
static/src/js/partner_access_popup.js
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
|
||||||
|
|
||||||
|
odoo.define('open_workshop.partner_access_popup', function (require) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var screens = require('point_of_sale.screens');
|
||||||
|
var rpc = require('web.rpc');
|
||||||
|
var core = require('web.core');
|
||||||
|
var QWeb = core.qweb;
|
||||||
|
console.log("✅ partner_access_popup.js wurde geladen");
|
||||||
|
|
||||||
|
|
||||||
|
screens.ClientListScreenWidget.include({
|
||||||
|
renderElement: function () {
|
||||||
|
this._super();
|
||||||
|
var self = this;
|
||||||
|
var client = this.pos.get_order().get_client();
|
||||||
|
|
||||||
|
if (!client) {
|
||||||
|
console.log("⚠️ Kein Kunde ausgewählt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("👤 client Objekt:", client);
|
||||||
|
console.log("🆔 client.id:", client && client.id);
|
||||||
|
rpc.query({
|
||||||
|
model: 'ows.machine',
|
||||||
|
method: 'get_access_list_grouped',
|
||||||
|
args: [client.id],
|
||||||
|
}).then(function (result) {
|
||||||
|
console.log("✅ Maschinenfreigaben vom Server:", result);
|
||||||
|
|
||||||
|
const html = QWeb.render('PartnerMachineAccessList', {
|
||||||
|
areas: result || [],
|
||||||
|
});
|
||||||
|
self.$('.client-details-right').append(html);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
21
static/src/xml/partner_access_popup.xml
Normal file
21
static/src/xml/partner_access_popup.xml
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<templates id="template" xml:space="preserve">
|
||||||
|
<t t-name="PartnerMachineAccessList">
|
||||||
|
<div class="client-detail">
|
||||||
|
<h3>Maschinenfreigaben</h3>
|
||||||
|
<t t-foreach="areas" t-as="area">
|
||||||
|
<div class="access-area">
|
||||||
|
<strong><t t-esc="area.area"/></strong>
|
||||||
|
<ul>
|
||||||
|
<t t-foreach="area.machines" t-as="machine">
|
||||||
|
<li>
|
||||||
|
<t t-esc="machine.name" />
|
||||||
|
<t t-if="machine.has_access"> ✅</t>
|
||||||
|
<t t-if="!machine.has_access"> ❌</t>
|
||||||
|
</li>
|
||||||
|
</t>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</templates>
|
||||||
10
views/assets.xml
Normal file
10
views/assets.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<odoo>
|
||||||
|
<template id="assets" inherit_id="point_of_sale.assets">
|
||||||
|
<xpath expr="." position="inside">
|
||||||
|
<script type="text/javascript" src="/open_workshop/static/src/js/partner_access_popup.js"/>
|
||||||
|
<script type="text/javascript" src="/open_workshop/static/src/js/debug.js"/>
|
||||||
|
<template id="machine_access_template" name="Maschinenfreigaben Template"
|
||||||
|
src="/open_workshop/static/src/xml/partner_access_popup.xml"/>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</odoo>
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
<!-- machine_area_views.xml -->
|
||||||
<odoo>
|
<odoo>
|
||||||
<!-- Action zum Anzeigen der Bereiche -->
|
<!-- Action zum Anzeigen der Bereiche -->
|
||||||
<record id="action_machine_area_list" model="ir.actions.act_window">
|
<record id="action_machine_area_list" model="ir.actions.act_window">
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
<!-- machine_views.xml -->
|
||||||
<odoo>
|
<odoo>
|
||||||
<!-- Maschinen Listenansicht -->
|
<!-- Maschinen Listenansicht -->
|
||||||
<record id="view_machine_tree" model="ir.ui.view">
|
<record id="view_machine_tree" model="ir.ui.view">
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
<!-- menu_views.xml -->
|
||||||
<odoo>
|
<odoo>
|
||||||
<!-- Maschinenliste -->
|
<!-- Maschinenliste -->
|
||||||
<record id="action_machine_list" model="ir.actions.act_window">
|
<record id="action_machine_list" model="ir.actions.act_window">
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
<!-- res_partner_view.xml -->
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="view_partner_form_inherit_open_workshop" model="ir.ui.view">
|
<record id="view_partner_form_inherit_open_workshop" model="ir.ui.view">
|
||||||
<field name="name">res.partner.form.ows.machine.access</field>
|
<field name="name">res.partner.form.ows.machine.access</field>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user