[IMP] open_workshop: add machine access overview to partner form
Added a read-only HTML view to the contact form showing all available machines grouped by area, including the access status, grant date, and expiry date for the selected partner. The overview provides a complete matrix view, even for machines without existing access records.
This commit is contained in:
parent
b749464fde
commit
3057f0cf80
|
|
@ -168,24 +168,21 @@ class ResPartner(models.Model):
|
||||||
def _compute_machine_access_html(self):
|
def _compute_machine_access_html(self):
|
||||||
areas = self.env['ows.machine.area'].search([], order="name")
|
areas = self.env['ows.machine.area'].search([], order="name")
|
||||||
for partner in self:
|
for partner in self:
|
||||||
html = "<div class='tab-content'><div class='tab-pane active' id='machine_access_tab'>"
|
html = ""
|
||||||
html += "<div class='o_group'>"
|
|
||||||
|
|
||||||
for area in areas:
|
for area in areas:
|
||||||
html += "<table class='o_group o_inner_group o_group_col_6'><tbody>"
|
|
||||||
|
|
||||||
# Bereichsüberschrift
|
|
||||||
html += f"""
|
html += f"""
|
||||||
|
<div class="o_form_sheet">
|
||||||
|
<h3 class="o_form_label">{area.name}</h3>
|
||||||
|
<table class="table table-sm table-bordered o_form_table">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3" style="width: 100%;">
|
<th>Maschine</th>
|
||||||
<div class="o_horizontal_separator">{area.name}</div>
|
<th>Status</th>
|
||||||
</td>
|
<th>Datum</th>
|
||||||
</tr>
|
<th>Gültig bis</th>
|
||||||
<tr>
|
|
||||||
<td class="o_td_label"><label class="o_form_label"></label></td>
|
|
||||||
<td class="o_td_label"><label class="o_form_label">Datum</label></td>
|
|
||||||
<td class="o_td_label"><label class="o_form_label">Gültig bis</label></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
machines = self.env['ows.machine'].search([('area_id', '=', area.id)], order="name")
|
machines = self.env['ows.machine'].search([('area_id', '=', area.id)], order="name")
|
||||||
|
|
@ -195,25 +192,26 @@ class ResPartner(models.Model):
|
||||||
('partner_id', '=', partner.id),
|
('partner_id', '=', partner.id),
|
||||||
('machine_id', '=', machine.id),
|
('machine_id', '=', machine.id),
|
||||||
], limit=1)
|
], limit=1)
|
||||||
icon = "<span class='fa fa-check text-success'></span>" if access else "<span class='fa fa-times text-danger'></span>"
|
icon = '<span class="text-success fa fa-check"/>' if access else '<span class="text-danger fa fa-times"/>'
|
||||||
date_granted = access.date_granted.strftime('%Y-%m-%d') if access and access.date_granted else "-"
|
date_granted = access.date_granted.strftime('%Y-%m-%d') if access and access.date_granted else "-"
|
||||||
date_expiry = access.date_expiry.strftime('%Y-%m-%d') if access and access.date_expiry else "-"
|
date_expiry = access.date_expiry.strftime('%Y-%m-%d') if access and access.date_expiry else "-"
|
||||||
|
|
||||||
html += f"""
|
html += f"""
|
||||||
<tr>
|
<tr>
|
||||||
<td class="o_td_label"><label class="o_form_label">{icon} {machine.name}</label></td>
|
<td>{machine.name}</td>
|
||||||
<td class="o_td_field">{date_granted}</td>
|
<td>{icon}</td>
|
||||||
<td class="o_td_field">{date_expiry}</td>
|
<td>{date_granted}</td>
|
||||||
|
<td>{date_expiry}</td>
|
||||||
</tr>
|
</tr>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
html += "</tbody></table>"
|
html += "</tbody></table></div>"
|
||||||
|
|
||||||
html += "</div></div></div>"
|
|
||||||
partner.machine_access_html = html
|
partner.machine_access_html = html
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def migrate_existing_partners(self):
|
def migrate_existing_partners(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
<field name="machine_id"/>
|
<field name="machine_id"/>
|
||||||
<field name="training_id" domain="[('categ_id.name', '=', 'Einweisungen')]"/>
|
<field name="training_id" domain="[('categ_id.name', 'in', ['Einweisungen', 'Kurse'])]"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
<page string="Einweisungsprodukte">
|
<page string="Einweisungsprodukte">
|
||||||
<field name="training_ids" context="{'default_machine_id': active_id}">
|
<field name="training_ids" context="{'default_machine_id': active_id}">
|
||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
<field name="training_id" domain="[('categ_id.name', '=', 'Einweisungen')]" />
|
<field name="training_id" domain="[('categ_id.name', 'in', ['Einweisungen', 'Kurse'])]" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
|
|
|
||||||
|
|
@ -7,28 +7,16 @@
|
||||||
<field name="priority" eval="10"/>
|
<field name="priority" eval="10"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//page[@name='sales_purchases']" position="before">
|
<xpath expr="//page[@name='sales_purchases']" position="before">
|
||||||
|
<page name="ows_machine_access" string="Offene Werkstatt (Hobbyhimmel)">
|
||||||
<!-- Tab 1: HOBBYHIMMEL Basis -->
|
<!-- EINWEISUNG: Zwei Felder nebeneinander -->
|
||||||
<page name="ows_basic" string="HOBBYHIMMEL Basis">
|
<group name="container_row_2" string="Sicherheitseinweisung" col="2">
|
||||||
<group name="container_row_2">
|
|
||||||
<group string="Sicherheit">
|
|
||||||
<field name="security_briefing"/>
|
<field name="security_briefing"/>
|
||||||
<field name="security_id"/>
|
<field name="security_id"/>
|
||||||
</group>
|
</group>
|
||||||
<group string="Zugang">
|
|
||||||
<field name="rfid_card"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
</page>
|
|
||||||
|
|
||||||
<!-- Tab 2: HOBBYHIMMEL Einweisungen (HTML) -->
|
<!-- MASCHINENFREIGABEN: Volle Breite -->
|
||||||
<page name="ows_machine_access_html" string="HOBBYHIMMEL Einweisungen">
|
<group string="Maschinenfreigaben" col="2">
|
||||||
<field name="machine_access_html" readonly="1" widget="html"/>
|
<field name="machine_access_ids" colspan="2" context="{'default_partner_id': id}" nolabel="1">
|
||||||
</page>
|
|
||||||
|
|
||||||
<!-- Tab 3: Einweisungen (Liste) -->
|
|
||||||
<page name="ows_machine_access_list" string="Einweisungen (Liste)">
|
|
||||||
<field name="machine_access_ids">
|
|
||||||
<tree>
|
<tree>
|
||||||
<field name="machine_id"/>
|
<field name="machine_id"/>
|
||||||
<field name="date_granted"/>
|
<field name="date_granted"/>
|
||||||
|
|
@ -36,8 +24,13 @@
|
||||||
<field name="granted_by_pos"/>
|
<field name="granted_by_pos"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</group>
|
||||||
|
|
||||||
|
<!-- ÜBERSICHT: Volle Breite -->
|
||||||
|
<group string="Maschinenfreigaben Übersicht" >
|
||||||
|
<field name="machine_access_html" colspan="2" readonly="1" widget="html" nolabel="1"/>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user