[IMP] mrp: Allow printing Work Orders

Task: 2683917
Part-of: odoo/odoo#83500
This commit is contained in:
JF Aubert
2022-02-16 11:30:29 +00:00
parent 5163062eca
commit 9a68c2ccb4
4 changed files with 102 additions and 36 deletions
+1
View File
@@ -48,6 +48,7 @@
'report/report_stock_reception.xml',
'report/report_stock_rule.xml',
'report/mrp_zebra_production_templates.xml',
'report/mrp_workorder_templates.xml',
],
'demo': [
'data/mrp_demo.xml',
+38 -36
View File
@@ -65,43 +65,8 @@
</table>
</div>
<h3 t-if="o.move_raw_ids">
<span t-if="o.state == 'done'">
Consumed Products
</span>
<span t-else="">
Products to Consume
</span>
</h3>
<t t-call="mrp.report_mrp_production_components" t-if="o.move_raw_ids"/>
<table class="table table-sm" t-if="o.move_raw_ids">
<t t-set="has_product_barcode" t-value="any(m.product_id.barcode for m in o.move_raw_ids)"/>
<thead>
<tr>
<th>Product</th>
<th t-attf-class="{{ 'text-right' if not has_product_barcode else '' }}">Quantity</th>
<th t-if="has_product_barcode" width="15%" class="text-center">Barcode</th>
</tr>
</thead>
<tbody>
<t t-if="o.move_raw_ids">
<tr t-foreach="o.move_raw_ids" t-as="raw_line">
<td>
<span t-field="raw_line.product_id"/>
</td>
<td t-attf-class="{{ 'text-right' if not has_product_barcode else '' }}">
<span t-field="raw_line.product_uom_qty"/>
<span t-field="raw_line.product_uom" groups="uom.group_uom"/>
</td>
<td t-if="has_product_barcode" width="15%" class="text-center">
<t t-if="raw_line.product_id.barcode">
<div t-field="o.name" t-options="{'widget': 'barcode', 'width': 600, 'height': 100, 'img_style': 'width:100%;height:35px'}"/>
</t>
</td>
</tr>
</t>
</tbody>
</table>
<div class="oe_structure"/>
</div>
</t>
@@ -109,6 +74,43 @@
</t>
</template>
<template id="report_mrp_production_components">
<h3>
<span t-if="o.state == 'done'">
Consumed Products
</span>
<span t-else="">
Products to Consume
</span>
</h3>
<table class="table table-sm">
<t t-set="has_product_barcode" t-value="any(m.product_id.barcode for m in o.move_raw_ids)"/>
<thead>
<tr>
<th>Product</th>
<th t-attf-class="{{ 'text-right' if not has_product_barcode else '' }}">Quantity</th>
<th t-if="has_product_barcode" width="15%" class="text-center">Barcode</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.move_raw_ids" t-as="raw_line">
<td>
<span t-field="raw_line.product_id"/>
</td>
<td t-attf-class="{{ 'text-right' if not has_product_barcode else '' }}">
<span t-field="raw_line.product_uom_qty"/>
<span t-field="raw_line.product_uom" groups="uom.group_uom"/>
</td>
<td t-if="has_product_barcode" width="15%" class="text-center">
<t t-if="raw_line.product_id.barcode">
<div t-field="o.name" t-options="{'widget': 'barcode', 'width': 600, 'height': 100, 'img_style': 'width:100%;height:35px'}"/>
</t>
</td>
</tr>
</tbody>
</table>
</template>
<template id="label_production_view_pdf">
<t t-call="web.basic_layout">
<t t-set='nRows' t-value='12'/>
@@ -41,5 +41,16 @@
<field name="binding_model_id" ref="model_mrp_production"/>
<field name="binding_type">report</field>
</record>
<record id="action_report_workorder" model="ir.actions.report">
<field name="name">Work Order</field>
<field name="model">mrp.workorder</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">mrp.report_mrp_workorder</field>
<field name="report_file">mrp.report.mrp_workorder</field>
<field name="print_report_name">'Work Order - %s' % object.name</field>
<field name="binding_model_id" ref="model_mrp_workorder"/>
<field name="binding_type">report</field>
<field name="multi">True</field>
</record>
</data>
</odoo>
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_mrp_workorder">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="web.internal_layout">
<div class="page">
<div class="oe_structure"/>
<div class="row">
<div class="col-7">
<h2><span t-field="o.name"/></h2>
</div>
<div class="col-5">
<span class="text-right">
<div t-field="o.name" t-options="{'widget': 'barcode', 'width': 600, 'height': 100, 'img_style': 'width:350px;height:60px'}"/>
</span>
</div>
</div>
<br/>
<div class="row mt32 mb32">
<div class="col-3">
<strong>Responsible:</strong><br/>
<span t-field="o.production_id.user_id"/>
</div>
<div class="col-3">
<strong>Manufacturing Order:</strong><br/>
<span t-field="o.production_id.name"/>
</div>
</div>
<br/>
<div class="row mt32 mb32">
<div class="col-3">
<strong>Finished Product:</strong><br/>
<span t-field="o.product_id"/>
</div>
<div class="col-3">
<strong>Quantity to Produce:</strong><br/>
<span t-field="o.qty_production"/>
<span t-field="o.product_uom_id.name" groups="uom.group_uom"/>
</div>
</div>
<br/>
<t t-call="mrp.report_mrp_production_components" t-if="o.move_raw_ids"/>
<div class="oe_structure"/>
</div>
</t>
</t>
</t>
</template>
</odoo>