[ADD] mrp_operations: Added report for workorders analysis.

bzr revid: uco@tinyerp.com-20101015095332-83d1961e34q1odnb
This commit is contained in:
uco (OpenERP) 2010-10-15 15:23:32 +05:30
parent e544840757
commit bfda5197b5
5 changed files with 193 additions and 0 deletions

View File

@ -58,6 +58,7 @@
'mrp_operations_workflow.xml',
'mrp_operations_view.xml',
'mrp_operations_report.xml',
'report/mrp_workorder_analysis_view.xml',
'process/mrp_operation_process.xml'
],
'demo_xml': ['mrp_operation_data.xml'],

View File

@ -21,5 +21,6 @@
import mrp_wc_barcode
import mrp_code_barcode
import mrp_workorder_analysis
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
import tools
class mrp_workorder(osv.osv):
_name = "mrp.workorder"
_description = "Work Order Report"
_auto = False
_columns = {
'year': fields.char('Year', size=64, readonly=True),
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'),
('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True),
'day': fields.char('Day', size=64, readonly=True),
'nbr': fields.integer('# of Lines', readonly=True),
'date': fields.date('Date', readonly=True),
'product_id': fields.many2one('product.product', 'Product', readonly=True),
'product_qty': fields.float('Product Qty', readonly=True),
'state': fields.selection([('draft','Draft'),('startworking', 'In Progress'),('pause','Pause'),('cancel','Cancelled'),('done','Finished')],'State', readonly=True),
'total_hours': fields.float('Total Hours', readonly=True),
'total_cycles': fields.float('Total Cycles', readonly=True),
'delay': fields.float('Delay', readonly=True),
'production_id': fields.many2one('mrp.production', 'Production', readonly=True),
'workcenter_id': fields.many2one('mrp.workcenter', 'Workcenter', readonly=True)
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'mrp_workorder')
cr.execute("""
create or replace view mrp_workorder as (
select
to_date(to_char(wl.date_planned, 'MM-dd-YYYY'),'MM-dd-YYYY') as date,
to_char(wl.date_planned, 'YYYY') as year,
to_char(wl.date_planned, 'MM') as month,
to_char(wl.date_planned, 'YYYY-MM-DD') as day,
min(wl.id) as id,
mp.product_id as product_id,
sum(wl.hour) as total_hours,
avg(wl.delay) as delay,
(w.costs_hour*sum(wl.hour)) as total_cost,
wl.production_id as production_id,
wl.workcenter_id as workcenter_id,
sum(wl.cycle) as total_cycles,
count(*) as nbr,
sum(mp.product_qty) as product_qty,
wl.state as state
from mrp_production_workcenter_line wl
left join mrp_workcenter w on (w.id = wl.workcenter_id)
left join mrp_production mp on (mp.id = wl.production_id)
group by
w.costs_hour, mp.product_id, mp.name, wl.state, wl.date_planned, wl.production_id, wl.workcenter_id
)""")
mrp_workorder()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--
Work Order Report
-->
<record id="view_report_mrp_workorder_tree" model="ir.ui.view">
<field name="name">mrp.workorder.tree</field>
<field name="model">mrp.workorder</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Work Orders">
<field name="date" invisible="1"/>
<field name="product_id" invisible="1"/>
<field name="product_qty" sum="Product Qty"/>
<field name="nbr" string="#Line Orders" sum="#Line Orders"/>
<field name="total_hours" sum="Total Hours"/>
<field name="total_cycles" sum="Total Cycles"/>
<field name="delay" invisible="1"/>
<field name="production_id" invisible="1"/>
<field name="workcenter_id" invisible="1"/>
<field name="state" invisible="1"/>
<field name="day" invisible="1" />
<field name="month" invisible="1" />
<field name="year" invisible="1" />
</tree>
</field>
</record>
<record id="view_report_mrp_workorder_graph" model="ir.ui.view">
<field name="name">mrp.workorder.graph</field>
<field name="model">mrp.workorder</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Work Orders" type="bar">
<field name="state"/>
<field name="nbr" operator="+"/>
</graph>
</field>
</record>
<record id="view_report_mrp_workorder_filter" model="ir.ui.view">
<field name="name">mrp.workorder.select</field>
<field name="model">mrp.workorder</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search">
<group col="16" colspan="6">
<filter icon="terp-go-year" string="Year"
domain="[('year','=',time.strftime('%%Y'))]"
help="Work orders made during current year"/>
<filter icon="terp-go-month" string="Month"
name="month"
domain="[('month','=',time.strftime('%%m'))]"
help="Work orders made during current month"/>
<filter icon="terp-go-week"
string="Month -1"
separator="1"
domain="[('month','=',(datetime.date.today() - datetime.timedelta(365/12)).strftime('%%m'))]"
help="Work orders during last month"/>
<separator orientation="vertical"/>
<filter string="Current" icon="terp-check" domain="[('state','not in',('draft','cancel','done'))]"/>
<filter icon="terp-check" string="Started" domain="[('state','=','startworking')]"/>
<filter icon="terp-dialog-close" string="Done" domain="[('state','=','done')]"/>
<separator orientation="vertical"/>
<field name="product_id" />
<field name="workcenter_id"/>
</group>
<newline/>
<group expand="1" string="Group By...">
<filter string="Product" name="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}" />
<filter string="Workcenter" name="Workcenter" icon="terp-go-home" context="{'group_by':'workcenter_id'}" />
<separator orientation="vertical"/>
<filter string="Production" icon="terp-accessories-archiver" domain="[]" context="{'group_by':'production_id'}"/>
<separator orientation="vertical"/>
<filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
<separator orientation="vertical"/>
<filter string="Day" icon="terp-go-today" context="{'group_by':'day'}" help="Planned Day"/>
<separator orientation="vertical"/>
<filter string="Month" name="terp-go-month" icon="terp-go-month" context="{'group_by':'month'}" help="Planned Month"/>
<separator orientation="vertical"/>
<filter string="Year" icon="terp-go-year" context="{'group_by':'year'}" help="Planned Year"/>
</group>
</search>
</field>
</record>
<record id="action_report_mrp_workorder" model="ir.actions.act_window">
<field name="name">Work Order</field>
<field name="res_model">mrp.workorder</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_report_mrp_workorder_tree"/>
<field name="search_view_id" ref="view_report_mrp_workorder_filter"/>
<field name="context">{'search_default_Workcenter': 1,'search_default_month':1,'group_by_no_leaf':1,'group_by':[]}</field>
</record>
<record model="ir.actions.act_window.view" id="action_report_mrp_workorder_tree">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_report_mrp_workorder_tree"/>
<field name="act_window_id" ref="action_report_mrp_workorder"/>
</record>
<record model="ir.actions.act_window.view" id="action_report_mrp_workorder_graph">
<field name="sequence" eval="2"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_report_mrp_workorder_graph"/>
<field name="act_window_id" ref="action_report_mrp_workorder"/>
</record>
<menuitem name="Work Order Analysis" action="action_report_mrp_workorder" id="menu_report_mrp_workorders_tree" parent="mrp.next_id_77"/>
</data>
</openerp>

View File

@ -7,3 +7,4 @@
"access_mrp_production_manager","mrp_production_manager","model_mrp_production","mrp.group_mrp_manager",1,0,0,0
"access_mrp_production_workcenter_line","mrp.production.workcenter.line","mrp.model_mrp_production_workcenter_line","mrp.group_mrp_user",1,1,1,1
"access_mrp_production_workcenter_line_manager","mrp.production.workcenter.line.manager","mrp.model_mrp_production_workcenter_line","mrp.group_mrp_manager",1,0,0,0
"access_mrp_workorder_manager","mrp.workorder.manager","model_mrp_workorder","mrp.group_mrp_manager",1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
7 access_mrp_production_manager mrp_production_manager model_mrp_production mrp.group_mrp_manager 1 0 0 0
8 access_mrp_production_workcenter_line mrp.production.workcenter.line mrp.model_mrp_production_workcenter_line mrp.group_mrp_user 1 1 1 1
9 access_mrp_production_workcenter_line_manager mrp.production.workcenter.line.manager mrp.model_mrp_production_workcenter_line mrp.group_mrp_manager 1 0 0 0
10 access_mrp_workorder_manager mrp.workorder.manager model_mrp_workorder mrp.group_mrp_manager 1 1 1 1