bessere Ansicht in POS der Einweisungen, kompakter
This commit is contained in:
parent
5363620682
commit
de95446686
|
|
@ -15,13 +15,25 @@ class ResPartner(models.Model):
|
||||||
|
|
||||||
@api.depends('machine_access_ids')
|
@api.depends('machine_access_ids')
|
||||||
def _compute_machine_access_html(self):
|
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:
|
for partner in self:
|
||||||
areas = self.env['ows.machine.area'].search([], order="name")
|
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:
|
for area in areas:
|
||||||
html += f"<div class='o_group' style='margin-bottom: 1em;'>"
|
html += f"<div class='o_group' style='margin-bottom: 1em;'>"
|
||||||
html += f"<table class='o_group o_inner_group'>"
|
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")
|
machines = self.env['ows.machine'].search([('area_id', '=', area.id)], order="name")
|
||||||
for machine in machines:
|
for machine in machines:
|
||||||
access = self.env['ows.machine.access'].search([
|
access = self.env['ows.machine.access'].search([
|
||||||
|
|
@ -29,17 +41,20 @@ class ResPartner(models.Model):
|
||||||
('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='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>
|
<tr>
|
||||||
<td class='o_td_label'><label>{}</label></td>
|
<td class='o_td_label'><label>{machine.name}</label></td>
|
||||||
<td class='o_td_field'>{}</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>
|
</tr>
|
||||||
""".format(machine.name, icon)
|
"""
|
||||||
html += "</tbody></table></div>"
|
html += "</tbody></table></div>"
|
||||||
html += "</div>"
|
html += "</div>"
|
||||||
partner.machine_access_html = html
|
partner.machine_access_html = html
|
||||||
|
|
||||||
|
|
||||||
class OwsMachineArea(models.Model):
|
class OwsMachineArea(models.Model):
|
||||||
_name = 'ows.machine.area'
|
_name = 'ows.machine.area'
|
||||||
_table = "ows_machine_area"
|
_table = "ows_machine_area"
|
||||||
|
|
@ -63,6 +78,10 @@ class OwsMachine(models.Model):
|
||||||
|
|
||||||
area_id = fields.Many2one('ows.machine.area', string='Bereich')
|
area_id = fields.Many2one('ows.machine.area', string='Bereich')
|
||||||
|
|
||||||
|
product_ids = fields.One2many('ows.machine.product', 'machine_id', string="Einweisungsprodukte")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
('code_unique', 'unique(code)', 'Maschinencode muss eindeutig sein.')
|
('code_unique', 'unique(code)', 'Maschinencode muss eindeutig sein.')
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1675,6 +1675,13 @@ td {
|
||||||
transition: all 150ms linear;
|
transition: all 150ms linear;
|
||||||
background: rgb(227, 246, 237);
|
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{
|
.pos .clientlist-screen .client-details{
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
border-bottom: solid 5px rgb(110,200,155);
|
border-bottom: solid 5px rgb(110,200,155);
|
||||||
|
|
@ -1782,7 +1789,7 @@ td {
|
||||||
.pos .clientlist-screen .client-detail > .briefinglabel{
|
.pos .clientlist-screen .client-detail > .briefinglabel{
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 250px;
|
|
||||||
text-align: right;
|
text-align: right;
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,24 @@
|
||||||
<templates id="template" xml:space="preserve">
|
<templates id="template" xml:space="preserve">
|
||||||
<t t-name="PartnerMachineAccessList">
|
<t t-name="PartnerMachineAccessList">
|
||||||
|
<div class="client-details-grid">
|
||||||
<t t-foreach="areas" t-as="area">
|
<t t-foreach="areas" t-as="area">
|
||||||
|
|
||||||
<div class='client-details-area' t-att-style="'border: solid 3px ' + area.color_hex + '; margin: 5px;'">
|
<div class='client-details-area' t-att-style="'border: solid 3px ' + area.color_hex + '; margin: 5px;'">
|
||||||
<ul>
|
<ul>
|
||||||
<t t-foreach="area.machines" t-as="machine">
|
<t t-foreach="area.machines" t-as="machine">
|
||||||
<div class='client-detail'>
|
<div class='client-detail'>
|
||||||
<span class='briefinglabel'><t t-esc="machine.name" /></span>
|
<t t-if="!machine.has_access">
|
||||||
<t t-if="machine.has_access"><span class='detail client-details-vvow_briefing'></span></t>
|
<span class='detail client-details-vvow_briefing_error'>❌</span>
|
||||||
<t t-if='!machine.has_access'><span class='detail client-details-vvow_briefing_error'>❌</span></t>
|
</t>
|
||||||
</div>
|
<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>
|
</t>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
|
</div>
|
||||||
</t>
|
</t>
|
||||||
</templates>
|
</templates>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<notebook position="inside">
|
<notebook position="inside">
|
||||||
<page string="Einweisungen">
|
<page string="HOBBYHIMMEL Einweisungen">
|
||||||
<field name="machine_access_html" readonly="1" widget="html"/>
|
<field name="machine_access_html" readonly="1" widget="html"/>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<notebook position="inside">
|
<notebook position="inside">
|
||||||
<page string="Einweisungen">
|
<page string="Einweisungen (Liste)">
|
||||||
<field name="machine_access_ids">
|
<field name="machine_access_ids">
|
||||||
<tree>
|
<tree>
|
||||||
<field name="machine_id"/>
|
<field name="machine_id"/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user