Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD][vms_order_template]-PDF for MO in VMS #51

Open
wants to merge 1 commit into
base: 10.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions vms/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'views/vms_task_view.xml',
'views/vms_order_line_view.xml',
'views/vms_order_view.xml',
'views/vms_order_template.xml',
'views/fleet_vehicle_view.xml',
'views/operating_unit_view.xml',
'wizards/vms_wizard_maintenance_order_view.xml',
Expand Down
6 changes: 4 additions & 2 deletions vms/models/vms_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class VmsOrder(models.Model):
program_id = fields.Many2one(
'vms.program',
string='Program')
sequence = fields.Integer()
report_ids = fields.Many2many(
'vms.report',
string='Report(s)')
Expand Down Expand Up @@ -167,7 +166,6 @@ def _onchange_type(self):
if rec.type == 'preventive':
rec.program_id = rec.unit_id.program_id
rec.current_odometer = rec.unit_id.odometer
rec.sequence = rec.unit_id.sequence
rec.order_line_ids = False
else:
rec.program_id = False
Expand Down Expand Up @@ -231,3 +229,7 @@ def _prepare_procurement_group(self):
'name': self.name,
'move_type': 'direct',
}

@api.multi
def print_mo(self):
return self.env['report'].get_action(self, 'vms.report_maintenance')
85 changes: 85 additions & 0 deletions vms/views/vms_order_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="report_maintenance">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.external_layout">
<div class="page">
<div class="row">
<div class="col-xs-6">
<strong>Base:</strong>
<span t-field="o.operating_unit_id.name"/>
<br/>
<strong>Unit:</strong>
<span t-field="o.unit_id.name"/>
<br/>
<strong>Maintenance Type</strong>
<span t-field="o.type"/>
</div>
<div class="col-xs-5 col-xs-offset-1">
<strong>Date:</strong>
<span t-field="o.date"/>
<br/>
<strong>Warehouse:</strong>
<span t-field="o.warehouse_id.name"/>
<br/>
<strong>Supervisor:</strong>
<span t-field="o.supervisor_id.name"/>
<br/>
</div>
</div>
<h2 t-if="o.state != 'draft'">Maintenance Order Confirmation #
<span t-field="o.name"/>
</h2>
<h2 t-if="o.state == 'draft'">Request for Maintenance Order #
<span t-field="o.name"/>
</h2>
<div class="row">
<div t-if="o.start_date" class="col-xs-6">
<strong>Schedule Start</strong>
<span t-esc="o.start_date"/>
</div>
<div t-if="o.end_date" class="col-xs-6">
<strong>Schedule End</strong>
<span t-esc="o.end_date"/>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<table class="table table-striped" style="font-size:9px;">
<tr>
<th width="6%" class="text-center" style="padding-top: 0.3em; padding-bottom: 0.3em;background-color: #848484;color: #ffffff;"><span>R</span></th>
<th width="16%" class="text-center" style="padding-top: 0.3em; padding-bottom: 0.3em;background-color: #848484;color: #ffffff;"><span>TASK</span></th>
<th width="12%" class="text-center" style="padding-top: 0.3em; padding-bottom: 0.3em;background-color: #848484;color: #ffffff;"><span>SPARE PARTS</span></th>
<th width="52%" class="text-center" style="padding-top: 0.3em; padding-bottom: 0.3em;background-color: #848484;color: #ffffff;"><span>QTY</span></th>
<th width="14%" class="text-center" style="padding-top: 0.3em; padding-bottom: 0.3em;background-color: #848484;color: #ffffff;"><span>UOM</span></th>
</tr>
<t t-set="row_count" t-value="1"/>
<t t-foreach="o.order_line_ids" t-as="concepts">
<tr class="text-center" t-foreach="concepts.spare_part_ids" t-as="concept">
<td style="padding-top: 0.3em; padding-bottom: 0.3em;" class="text-center"><span t-esc="row_count"></span></td>
<td style="padding-top: 0.3em; padding-bottom: 0.3em;" class="text-center"><span t-esc="concepts.task_id.name"></span></td>
<td style="padding-top: 0.3em; padding-bottom: 0.3em;" class="text-center"><span t-esc="concept.product_id.name"></span></td>
<td style="padding-top: 0.3em; padding-bottom: 0.3em;" class="text-center"><span t-esc="concept.product_qty"></span></td>
<td style="padding-top: 0.3em; padding-bottom: 0.3em;" class="text-center"><span t-esc="concept.product_uom_id.name"></span></td>
<t t-set="row_count" t-value="row_count+1"/>
</tr>
</t>
</table>
</div>
</div>
</div>
</t>
</t>
</t>
</template>

<report
id="report_maintenances"
model="vms.order"
string="Maintenance Order"
report_type="qweb-pdf"
name="vms.report_maintenance"
file="vms.report_maintenance"/>

</odoo>
4 changes: 1 addition & 3 deletions vms/views/vms_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
<button icon="fa-arrow-right" class="oe_highlight" name="action_open" states="draft" string="Open" type="object"/>
<button icon="fa-check-square-o" class="oe_highlight" name="action_released" states="open" string="Released" type="object"/>
<button icon="fa-times" name="action_cancel" states="draft,open" string="Cancel" type="object" confirm="Are you sure to cancel this order? All the task(s) will cancel too."/>
<button icon="fa-pencil-square-o" name="print_mo" string="Print MO" type="object" states="draft,open" class="oe_highlight"/>
<field name="state" statusbar_visible="draft,open,released" widget="statusbar"/>
</header>
<sheet>
Expand Down Expand Up @@ -69,8 +69,6 @@
<field name="current_odometer"/>
<newline/>
<field name="program_id"/>
<newline/>
<field name="sequence"/>
</group>
</page>
<page string="Driver Reports Solved" attrs="{'invisible':[('type','in',(False,'preventive'))]}">
Expand Down