Adding report mrp module
bzr revid: fp@tinyerp.com-d8d41c972a54e39c5b44fd27245f85470016fcee
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: __init__.py 1005 2005-07-25 08:41:42Z nicoe $
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract a Free Software
|
||||
# Service Company
|
||||
#
|
||||
# This program is Free Software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import report_mrp
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name" : "MRP Management - Reporting",
|
||||
"version" : "1.0",
|
||||
"author" : "Tiny",
|
||||
"website" : "http://tinyerp.com/module_mrp.html",
|
||||
"depends" : ["mrp"],
|
||||
"category" : "Generic Modules/Production",
|
||||
"description": "A module that adds new reports based on MRP cases.",
|
||||
"init_xml" : [],
|
||||
"demo_xml" : [],
|
||||
"update_xml" : ["report_mrp_view.xml"],
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
from osv import fields,osv
|
||||
|
||||
|
||||
class report_workcenter_load(osv.osv):
|
||||
_name="report.workcenter.load"
|
||||
_description="Workcenter Load"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'name': fields.char('Week', size=64, required=True),
|
||||
'workcenter_id': fields.many2one('mrp.workcenter', 'Workcenter', required=True),
|
||||
'cycle': fields.float('Nbr of cycle'),
|
||||
'hour': fields.float('Nbr of hour'),
|
||||
}
|
||||
def init(self, cr):
|
||||
cr.execute("""
|
||||
create or replace view report_workcenter_load as (
|
||||
SELECT
|
||||
min(wl.id) as id,
|
||||
to_char(stock_move.create_date,'YYYY:IW') as name,
|
||||
SUM(wl.hour) AS hour,
|
||||
SUM(wl.cycle) AS cycle,
|
||||
wl.workcenter_id as workcenter_id
|
||||
FROM
|
||||
mrp_production_workcenter_line wl
|
||||
GROUP BY
|
||||
wl.workcenter_id,
|
||||
to_char(stock_move.create_date,'YYYY:IW')
|
||||
)""")
|
||||
report_workcenter_load()
|
||||
|
||||
class report_mrp_inout(osv.osv):
|
||||
_name="report.mrp.inout"
|
||||
_description="Stock value variation"
|
||||
_auto = False
|
||||
_rec_name = 'date'
|
||||
_columns = {
|
||||
'date': fields.char('Week', size=64, required=True),
|
||||
'value': fields.float('Stock value', required=True),
|
||||
}
|
||||
def init(self, cr):
|
||||
cr.execute("""
|
||||
create or replace view report_mrp_inout as (
|
||||
select
|
||||
min(sm.id) as id,
|
||||
to_char(sm.date_planned,'YYYY:IW') as date,
|
||||
sum(case when (sl.usage='internal') then
|
||||
pt.standard_price * sm.product_qty
|
||||
else
|
||||
0.0
|
||||
end - case when (sl2.usage='internal') then
|
||||
pt.standard_price * sm.product_qty
|
||||
else
|
||||
0.0
|
||||
end) as value
|
||||
from
|
||||
stock_move sm
|
||||
left join product_product pp
|
||||
on (pp.id = sm.product_id)
|
||||
left join product_template pt
|
||||
on (pt.id = pp.product_tmpl_id)
|
||||
left join stock_location sl
|
||||
on ( sl.id = sm.location_id)
|
||||
left join stock_location sl2
|
||||
on ( sl2.id = sm.location_dest_id)
|
||||
where
|
||||
sm.state in ('waiting','confirmed','assigned')
|
||||
group by
|
||||
to_char(sm.date_planned,'YYYY:IW')
|
||||
)""")
|
||||
report_mrp_inout()
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_workcenter_load_tree">
|
||||
<field name="name">report.workcenter.load.tree</field>
|
||||
<field name="model">report.workcenter.load</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Workcenters load">
|
||||
<field name="name" select="1"/>
|
||||
<field name="workcenter_id" select="1"/>
|
||||
<field name="cycle"/>
|
||||
<field name="hour"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_workcenter_load_graph">
|
||||
<field name="name">report.workcenter.load.graph</field>
|
||||
<field name="model">report.workcenter.load</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Workcenter load" type="bar">
|
||||
<field name="name"/>
|
||||
<field name="cycle" operator="+"/>
|
||||
<field name="hour" operator="+"/>
|
||||
<field name="workcenter_id" group="True"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_workcenter_load_form">
|
||||
<field name="name">report.workcenter.load.form</field>
|
||||
<field name="model">report.workcenter.load</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Workcenter load" type="bar">
|
||||
<field name="name" select="1"/>
|
||||
<field name="workcenter_id" select="1"/>
|
||||
<field name="cycle"/>
|
||||
<field name="hour"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_report_workcenter_load_tree">
|
||||
<field name="res_model">report.workcenter.load</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
</record>
|
||||
<menuitem name="Production/Reporting/Workcenter loads" action="action_report_workcenter_load_tree" id="menu_report_workcenter_load"/>
|
||||
|
||||
=============================
|
||||
stock.move compared to internal location src/dest
|
||||
==============================
|
||||
|
||||
<record model="ir.ui.view" id="view_report_in_out_picking_tree">
|
||||
<field name="name">report.mrp.inout.tree</field>
|
||||
<field name="model">report.mrp.inout</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Stock value variation">
|
||||
<field name="date"/>
|
||||
<field name="value"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_report_in_out_picking_form">
|
||||
<field name="name">report.mrp.inout.form</field>
|
||||
<field name="model">report.mrp.inout</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Stock value variation" type="bar">
|
||||
<field name="date" select="1"/>
|
||||
<field name="value" select="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_report_in_out_picking_graph">
|
||||
<field name="name">report.mrp.inout.graph</field>
|
||||
<field name="model">report.mrp.inout</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Stock value variation" type="bar">
|
||||
<field name="date" />
|
||||
<field name="value" operator="+"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_report_in_out_picking_tree">
|
||||
<field name="res_model">report.mrp.inout</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
</record>
|
||||
<menuitem name="Production/Reporting/Weekly stock value variation" action="action_report_in_out_picking_tree" id="menu_report_in_out_picking"/>
|
||||
|
||||
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user