bemade_fsm: PDF improvements

* Equipment summary added after the sale line summary.
   Fixes Dur-Pro/bemade-addons#60.
 * Different blocks of the document made conditional to content
 * Improved how tasks and subtasks are rendered
This commit is contained in:
Marc Durepos 2023-08-28 16:06:00 -04:00
parent 05ac09014c
commit 22cf91c67c

View file

@ -30,6 +30,7 @@
</t> </t>
<t t-else="" t-set="root_tasks" <t t-else="" t-set="root_tasks"
t-value="doc.root_ancestor"/> t-value="doc.root_ancestor"/>
<div t-if="order_lines.filtered(lambda l: not l.display_type)">
<h2 t-if="order_lines">Time &amp; Material</h2> <h2 t-if="order_lines">Time &amp; Material</h2>
<div t-if="order_lines" class="table-responsive-sm"> <div t-if="order_lines" class="table-responsive-sm">
<table class="table table-sm o_main_table"> <table class="table table-sm o_main_table">
@ -104,7 +105,8 @@
<t t-if="current_section and len(section_lines) > 1 and (line_last or order_lines[line_index+1].display_type == 'line_section')"> <t t-if="current_section and len(section_lines) > 1 and (line_last or order_lines[line_index+1].display_type == 'line_section')">
<tr class="is-subtotal text-right"> <tr class="is-subtotal text-right">
<td colspan="99"> <td colspan="99">
<strong class="mr16">Section Subtotal</strong> <strong class="mr16">Section
Subtotal</strong>
<span <span
t-esc="current_subtotal" t-esc="current_subtotal"
t-options='{"widget": "monetary", "display_currency": doc.sale_order_id.pricelist_id.currency_id}' t-options='{"widget": "monetary", "display_currency": doc.sale_order_id.pricelist_id.currency_id}'
@ -146,6 +148,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<template id="subtask_list"> <template id="subtask_list">
<ul t-if="task.child_ids" class="ml-1 pl-1" style="list-style-type: none;"> <ul t-if="task.child_ids" class="ml-1 pl-1" style="list-style-type: none;">
@ -163,8 +166,8 @@
<t t-set="interventions" t-value="doc.child_ids"/> <t t-set="interventions" t-value="doc.child_ids"/>
<t t-set="timesheets" t-value="doc.timesheet_ids"/> <t t-set="timesheets" t-value="doc.timesheet_ids"/>
<t t-foreach="interventions" t-as="intervention"> <t t-foreach="interventions" t-as="intervention">
<h2 style="page-break-before: always;" <div style="page-break-inside: avoid;">
t-out="str(intervention_index + 1) + '. ' + intervention.name"/> <h2 t-out="str(intervention_index + 1) + '. ' + intervention.name"/>
<h3 t-if="intervention.equipment_ids">Equipment: <h3 t-if="intervention.equipment_ids">Equipment:
<t t-foreach="intervention.equipment_ids" t-as="equipment_id"> <t t-foreach="intervention.equipment_ids" t-as="equipment_id">
<span t-out="equipment_id.complete_name + (', ' if not equipment_id_last else '')"/> <span t-out="equipment_id.complete_name + (', ' if not equipment_id_last else '')"/>
@ -186,7 +189,7 @@
</thead> </thead>
<tbody> <tbody>
<t t-foreach="tasks" t-as="task"> <t t-foreach="tasks" t-as="task">
<tr class="o_line_section p-1 m-1"> <tr class="p-1 m-1">
<td t-out="task.stage_id.name"/> <td t-out="task.stage_id.name"/>
<td> <td>
<span t-out="task.name"/> <span t-out="task.name"/>
@ -210,6 +213,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
</t> </t>
</template> </template>
@ -251,7 +255,8 @@
</t> </t>
</div> </div>
<div t-attf-class="{{'col-6' if report_type == 'pdf' else 'col-md-6 col-12'}}"> <div t-attf-class="{{'col-6' if report_type == 'pdf' else 'col-md-6 col-12'}}">
<div t-if="doc.work_order_contacts"><h6>Work Order Contacts: </h6></div> <div t-if="doc.work_order_contacts"><h6>Work Order
Contacts: </h6></div>
<t t-foreach="doc.work_order_contacts" t-as="contact"> <t t-foreach="doc.work_order_contacts" t-as="contact">
<div class="mb-3"> <div class="mb-3">
<div t-esc="contact" t-options='{ <div t-esc="contact" t-options='{
@ -263,6 +268,43 @@
</div> </div>
</div> </div>
</template> </template>
<template id="workorder_equipment_summary">
<div t-if="doc.equipment_ids and len(doc.child_ids) > 1"
style="page-break-inside: avoid;">
<h3>Equipment Serviced</h3>
<div class="table-responsive-sm">
<table class="table table-sm o_main_table">
<thead>
<tr>
<th>Tag</th>
<th>Name</th>
<th>Application</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<t t-foreach="doc.equipment_ids" t-as="equipment">
<tr>
<td><span t-esc="equipment.pid_tag"/></td>
<td><span t-esc="equipment.name"/></td>
<td>
<t t-foreach="equipment.tag_ids"
t-as="application">
<span t-esc="application.name + (', ' if not application_last else '')"/>
</t>
</td>
<td t-esc="equipment.partner_location_id"
t-options='{
"widget": "contact",
"fields": ["name", "address"]}'
/>
</tr>
</t>
</tbody>
</table>
</div>
</div>
</template>
<template id="workorder_page_signature_block"> <template id="workorder_page_signature_block">
<div t-if="doc.worksheet_signature"> <div t-if="doc.worksheet_signature">
<div t-if="report_type == html" class="ribbon" style=" <div t-if="report_type == html" class="ribbon" style="
@ -287,7 +329,8 @@
Signed Signed
</span> </span>
</div> </div>
<div t-attf-class="#{'col-12 col-lg-3' if report_type != 'html' else 'col-sm-7 col-md-4'} ml-auto text-right" <div t-attf-class="#{' col-12 col-lg-3' if report_type != 'html' else '
col-sm-7 col-md-4'} ml-auto text-right"
style="page-break-inside: avoid"> style="page-break-inside: avoid">
<h5>Signature</h5> <h5>Signature</h5>
<img t-att-src="image_data_uri(doc.worksheet_signature)" <img t-att-src="image_data_uri(doc.worksheet_signature)"
@ -300,6 +343,7 @@
<div class="page"> <div class="page">
<t t-call="bemade_fsm.workorder_page_info_block"/> <t t-call="bemade_fsm.workorder_page_info_block"/>
<t t-call="bemade_fsm.workorder_page_sale_order_table"/> <t t-call="bemade_fsm.workorder_page_sale_order_table"/>
<t t-call="bemade_fsm.workorder_equipment_summary"/>
<t t-call="bemade_fsm.workorder_page_signature_block"/> <t t-call="bemade_fsm.workorder_page_signature_block"/>
<t t-call="bemade_fsm.workorder_page_tasks_table"/> <t t-call="bemade_fsm.workorder_page_tasks_table"/>
</div> </div>