bessere Ansicht in POS der Einweisungen, kompakter

This commit is contained in:
gitea 2025-04-03 18:14:42 +00:00
parent 5363620682
commit de95446686
5 changed files with 47 additions and 15 deletions

View File

@ -15,13 +15,25 @@ class ResPartner(models.Model):
@api.depends('machine_access_ids')
def _compute_machine_access_html(self):
"""
Computes an HTML representation of the machine access permissions for each partner.
The HTML is structured as a grid of machine areas, where each area contains a table
listing the machines and whether the partner has access to them.
- Iterates through all machine areas and their associated machines.
- Checks if the partner has access to each machine.
- Generates an HTML table with a checkmark or cross icon for each machine access status.
- Assigns the generated HTML to the `machine_access_html` field of the partner.
"""
for partner in self:
areas = self.env['ows.machine.area'].search([], order="name")
html = "<div style='display: flex; flex-wrap: wrap; gap: 2rem;'>"
html = """
<div style='display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem;'>
"""
for area in areas:
html += f"<div class='o_group' style='margin-bottom: 1em;'>"
html += f"<table class='o_group o_inner_group'>"
html += f"<thead><tr><th colspan='2' style='border-bottom: 1px solid #ccc;'>{area.name}</th></tr></thead><tbody>"
html += f"<thead><tr><th>{area.name}</th><th></th><th>Datum</th><th>Gültig bis</th></tr></thead><tbody>"
machines = self.env['ows.machine'].search([('area_id', '=', area.id)], order="name")
for machine in machines:
access = self.env['ows.machine.access'].search([
@ -29,17 +41,20 @@ class ResPartner(models.Model):
('machine_id', '=', machine.id),
], limit=1)
icon = "<span class='fa fa-check text-success'></span>" if access else "<span class='fa fa-times text-danger'></span>"
html += """
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 ""
html += f"""
<tr>
<td class='o_td_label'><label>{}</label></td>
<td class='o_td_field'>{}</td>
<td class='o_td_label'><label>{machine.name}</label></td>
<td class='o_td_field'>{icon}</td>
<td class='o_td_field'>{date_granted}</td>
<td class='o_td_field'>{date_expiry}</td>
</tr>
""".format(machine.name, icon)
"""
html += "</tbody></table></div>"
html += "</div>"
partner.machine_access_html = html
class OwsMachineArea(models.Model):
_name = 'ows.machine.area'
_table = "ows_machine_area"
@ -63,6 +78,10 @@ class OwsMachine(models.Model):
area_id = fields.Many2one('ows.machine.area', string='Bereich')
product_ids = fields.One2many('ows.machine.product', 'machine_id', string="Einweisungsprodukte")
_sql_constraints = [
('code_unique', 'unique(code)', 'Maschinencode muss eindeutig sein.')
]

View File

@ -1675,6 +1675,13 @@ td {
transition: all 150ms linear;
background: rgb(227, 246, 237);
}
.pos .clientlist-screen .client-details-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 0px;
}
.pos .clientlist-screen .client-details{
padding: 16px;
border-bottom: solid 5px rgb(110,200,155);
@ -1782,7 +1789,7 @@ td {
.pos .clientlist-screen .client-detail > .briefinglabel{
font-weight: bold;
display: inline-block;
width: 250px;
text-align: right;
margin-right: 8px;
}

View File

@ -1,18 +1,24 @@
<templates id="template" xml:space="preserve">
<t t-name="PartnerMachineAccessList">
<div class="client-details-grid">
<t t-foreach="areas" t-as="area">
<div class='client-details-area' t-att-style="'border: solid 3px ' + area.color_hex + '; margin: 5px;'">
<ul>
<t t-foreach="area.machines" t-as="machine">
<div class='client-detail'>
<span class='briefinglabel'><t t-esc="machine.name" /></span>
<t t-if="machine.has_access"><span class='detail client-details-vvow_briefing'></span></t>
<t t-if='!machine.has_access'><span class='detail client-details-vvow_briefing_error'></span></t>
</div>
<t t-if="!machine.has_access">
<span class='detail client-details-vvow_briefing_error'></span>
</t>
<t t-if="machine.has_access">
<span class='detail client-details-vvow_briefing'></span>
</t>
<span class='briefinglabel'><t t-esc="machine.name" /></span>
</div>
</t>
</ul>
</div>
</t>
</div>
</t>
</templates>

View File

@ -7,7 +7,7 @@
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Einweisungen">
<page string="HOBBYHIMMEL Einweisungen">
<field name="machine_access_html" readonly="1" widget="html"/>
</page>
</notebook>

View File

@ -6,7 +6,7 @@
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Einweisungen">
<page string="Einweisungen (Liste)">
<field name="machine_access_ids">
<tree>
<field name="machine_id"/>