bemade_fsm: refactor work order report templates to break them into sub-templates for easier modification.

This commit is contained in:
Marc Durepos 2023-08-21 15:24:54 -04:00
parent 7b5a7b63c2
commit b1ca61ce89

View file

@ -1,31 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<odoo> <odoo>
<data> <data>
<template id="work_order_page"> <template id="workorder_page_sale_order_table">
<div class="page">
<div class="row">
<div t-attf-class="{{'col-6' if report_type == 'pdf' else 'col-md-6 col-12'}}">
<div t-if="doc.user_ids"><strong>Technicians: </strong></div>
<t t-foreach="doc.user_ids" t-as="user">
<div class="mb-3">
<div t-esc="user" t-options='{
"widget": "contact",
"fields": ["name", "address", "phone", "email"]
}'/>
</div>
</t>
</div>
<div t-attf-class="{{('col-6' if report_type == 'pdf' else 'col-md-6 col-12') + ' mb-3'}}">
<t t-if="doc.partner_id">
<div><strong>Customer: </strong></div>
<div t-esc="doc.partner_id" t-options='{
"widget": "contact",
"fields": ["name", "address",]
}'/>
</t>
</div>
</div>
<t t-set="order_lines" t-value="doc.relevant_order_lines"/> <t t-set="order_lines" t-value="doc.relevant_order_lines"/>
<t t-if="order_lines"> <t t-if="order_lines">
<t t-set="visit_lines" t-value="order_lines.mapped('visit_id')"/> <t t-set="visit_lines" t-value="order_lines.mapped('visit_id')"/>
@ -37,7 +13,8 @@
<t t-set="final_tax" t-value="0"/> <t t-set="final_tax" t-value="0"/>
<t t-set="final_total" t-value="0"/> <t t-set="final_total" t-value="0"/>
<t t-set="is_any_total_discount_line" t-value="False"/> <t t-set="is_any_total_discount_line" t-value="False"/>
<t t-set="section_lines" t-value="order_lines.filtered(lambda l: l.display_type == 'line_section')"/> <t t-set="section_lines"
t-value="order_lines.filtered(lambda l: l.display_type == 'line_section')"/>
<t t-foreach="order_lines" t-as="line"> <t t-foreach="order_lines" t-as="line">
<t t-set="final_subtotal" <t t-set="final_subtotal"
t-value="final_subtotal + line.delivered_price_subtotal"/> t-value="final_subtotal + line.delivered_price_subtotal"/>
@ -143,28 +120,59 @@
<div id="total" class="row justify-content-end" name="total"> <div id="total" class="row justify-content-end" name="total">
<div t-attf-class="#{'col-auto' if report_type != 'html' else 'col-sm-2'}"> <div t-attf-class="#{'col-auto' if report_type != 'html' else 'col-sm-2'}">
<table class="table table-sm"> <table class="table table-sm">
<tr t-if="final_tax" class="border-black o_subtotal" style=""> <tr t-if="final_tax" class="border-black o_subtotal"
style="">
<td><strong>Untaxed amount</strong></td> <td><strong>Untaxed amount</strong></td>
<td class="text-right"> <td class="text-right">
<span t-esc="final_subtotal" t-options='{"widget": "monetary", "display_currency": doc.sale_order_id.pricelist_id.currency_id}'/> <span t-esc="final_subtotal"
t-options='{"widget": "monetary", "display_currency": doc.sale_order_id.pricelist_id.currency_id}'/>
</td> </td>
</tr> </tr>
<tr t-if="final_tax"> <tr t-if="final_tax">
<td><strong>Taxes</strong></td> <td><strong>Taxes</strong></td>
<td class="text-right"> <td class="text-right">
<span t-esc="final_tax" t-options='{"widget": "monetary", "display_currency": doc.sale_order_id.pricelist_id.currency_id}'/> <span t-esc="final_tax"
t-options='{"widget": "monetary", "display_currency": doc.sale_order_id.pricelist_id.currency_id}'/>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><strong>Total</strong></td> <td><strong>Total</strong></td>
<td class="text-right"> <td class="text-right">
<span t-esc="final_total" t-options='{"widget": "monetary", "display_currency": doc.sale_order_id.pricelist_id.currency_id}'/> <span t-esc="final_total"
t-options='{"widget": "monetary", "display_currency": doc.sale_order_id.pricelist_id.currency_id}'/>
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</template>
<template id="workorder_page_info_block">
<div class="row">
<div t-attf-class="{{'col-6' if report_type == 'pdf' else 'col-md-6 col-12'}}">
<div t-if="doc.user_ids"><strong>Technicians: </strong></div>
<t t-foreach="doc.user_ids" t-as="user">
<div class="mb-3">
<div t-esc="user" t-options='{
"widget": "contact",
"fields": ["name", "address", "phone", "email"]
}'/>
</div>
</t>
</div>
<div t-attf-class="{{('col-6' if report_type == 'pdf' else 'col-md-6 col-12') + ' mb-3'}}">
<t t-if="doc.partner_id">
<div><strong>Customer: </strong></div>
<div t-esc="doc.partner_id" t-options='{
"widget": "contact",
"fields": ["name", "address",]
}'/>
</t>
</div>
</div>
</template>
<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="
position: absolute; position: absolute;
@ -188,12 +196,20 @@
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" style="page-break-inside: avoid"> <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">
<h5>Signature</h5> <h5>Signature</h5>
<img t-att-src="image_data_uri(doc.worksheet_signature)" style="max-height: 6rem; max-width: 100%; color:black;"/><br/> <img t-att-src="image_data_uri(doc.worksheet_signature)"
style="max-height: 6rem; max-width: 100%; color:black;"/><br/>
<span t-field="doc.worksheet_signed_by"/> <span t-field="doc.worksheet_signed_by"/>
</div> </div>
</div> </div>
</template>
<template id="work_order_page">
<div class="page">
<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_signature_block"/>
</div> </div>
</template> </template>
<template id="work_order"> <template id="work_order">