add missing files
bzr revid: fp@tinyerp.com-20100301214458-ps5mzq0n9yi7yvvp
This commit is contained in:
parent
f4548a7bcd
commit
b14d587e09
|
@ -0,0 +1,90 @@
|
|||
# -*- 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import tools
|
||||
from osv import fields,osv
|
||||
|
||||
|
||||
class sale_report(osv.osv):
|
||||
_name = "sale.report"
|
||||
_description = "Sales Orders Statistics"
|
||||
_auto = False
|
||||
_rec_name = 'date'
|
||||
_columns = {
|
||||
'date': fields.date('Date', readonly=True),
|
||||
'year': fields.char('Year', size=4, 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),
|
||||
'product_id':fields.many2one('product.product', 'Product', readonly=True),
|
||||
'product_uom':fields.many2one('product.uom', 'UoM', readonly=True),
|
||||
'product_qty':fields.float('Qty', readonly=True),
|
||||
'partner_id':fields.many2one('res.partner', 'Partner', readonly=True),
|
||||
'shop_id':fields.many2one('sale.shop', 'Shop', readonly=True),
|
||||
'company_id':fields.many2one('res.company', 'Company', readonly=True),
|
||||
'user_id':fields.many2one('res.users', 'Salesman', readonly=True),
|
||||
'price_total':fields.float('Total Price', readonly=True),
|
||||
'price_average':fields.float('Average Price', readonly=True),
|
||||
'nbr':fields.integer('# of Lines', readonly=True),
|
||||
'state': fields.selection([
|
||||
('draft', 'Quotation'),
|
||||
('waiting_date', 'Waiting Schedule'),
|
||||
('manual', 'Manual In Progress'),
|
||||
('progress', 'In Progress'),
|
||||
('shipping_except', 'Shipping Exception'),
|
||||
('invoice_except', 'Invoice Exception'),
|
||||
('done', 'Done'),
|
||||
('cancel', 'Cancelled')
|
||||
], 'Order State', readonly=True),
|
||||
}
|
||||
_order = 'date desc'
|
||||
def init(self, cr):
|
||||
tools.drop_view_if_exists(cr, 'report_sale_order_product')
|
||||
cr.execute("""
|
||||
create or replace view sale_report as (
|
||||
select
|
||||
min(l.id) as id,
|
||||
s.date_order as date,
|
||||
to_char(s.date_order, 'YYYY') as year,
|
||||
to_char(s.date_order, 'MM') as month,
|
||||
l.product_id as product_id,
|
||||
sum(l.product_uom_qty * u.factor) as product_qty,
|
||||
s.partner_id as partner_id,
|
||||
s.user_id as user_id,
|
||||
s.shop_id as shop_id,
|
||||
s.company_id as company_id,
|
||||
sum(l.product_uom_qty*l.price_unit) as price_total,
|
||||
(sum(l.product_uom_qty*l.price_unit)/sum(l.product_uom_qty * u.factor))::decimal(16,2) as price_average,
|
||||
count(*) as nbr,
|
||||
s.state
|
||||
from
|
||||
sale_order_line l
|
||||
left join
|
||||
sale_order s on (s.id=l.order_id)
|
||||
left join product_uom u on (u.id=l.product_uom)
|
||||
group by
|
||||
s.date_order, s.partner_id, l.product_id,
|
||||
l.product_uom, s.user_id, s.state, s.shop_id,
|
||||
s.company_id
|
||||
)
|
||||
""")
|
||||
sale_report()
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_order_product_tree" model="ir.ui.view">
|
||||
<field name="name">sale.report.tree</field>
|
||||
<field name="model">sale.report</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Sales Orders Statistics">
|
||||
<field name="date"/>
|
||||
<field name="user_id"/>
|
||||
<field name="year" invisible="1"/>
|
||||
<field name="month" invisible="1"/>
|
||||
<field name="shop_id" invisible="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="product_id"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="nbr" sum="# of Lines"/>
|
||||
<field name="price_average" avg="Average Price"/>
|
||||
<field name="price_total" sum="Total Price"/>
|
||||
<field name="state" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_order_product_graph" model="ir.ui.view">
|
||||
<field name="name">sale.report.graph</field>
|
||||
<field name="model">sale.report</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Sales Orders Statistics" type="bar">
|
||||
<field name="product_id"/>
|
||||
<field name="price_total"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_order_product_search" model="ir.ui.view">
|
||||
<field name="name">sale.report.search</field>
|
||||
<field name="model">sale.report</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Sale Orders">
|
||||
<filter icon="terp-sale"
|
||||
string="This Year"
|
||||
domain="[('year','=',time.strftime('%%Y'))]"
|
||||
default="1"
|
||||
help="Sales orders of the year"/>
|
||||
<filter icon="terp-sale"
|
||||
string="This Month"
|
||||
default="1"
|
||||
domain="[('month','=',time.strftime('%%m'))]"
|
||||
help="Sales orders of this month"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-sale"
|
||||
string="Quotations"
|
||||
domain="[('state','=','draft')]"/>
|
||||
<filter icon="terp-sale"
|
||||
string="Sales"
|
||||
default="1"
|
||||
domain="[('state','<>','draft'),('state','<>','cancel')]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="product_id"/>
|
||||
<field name="user_id" widget="selection">
|
||||
<filter icon="terp-sale"
|
||||
string="My Sales"
|
||||
domain="[('user_id','=',uid)]"/>
|
||||
</field>
|
||||
<field name="partner_id"/>
|
||||
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
|
||||
|
||||
<newline/>
|
||||
<group expand="1" string="Group By..." colspan="10" col="12">
|
||||
<filter string="Company" icon="terp-sale" context="{'group_by':'company_id'}"/>
|
||||
<filter string="Shop" icon="terp-sale" context="{'group_by':'shop_id'}"/>
|
||||
<filter string="Salesman" icon="terp-sale" context="{'group_by':'user_id'}" default="1"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Product" icon="terp-sale" context="{'group_by':'product_id'}"/>
|
||||
<filter string="Partner" icon="terp-sale" context="{'group_by':'partner_id'}"/>
|
||||
<filter string="State" icon="terp-sale" context="{'group_by':'state'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Month" icon="terp-sale" context="{'group_by':'date'}"/>
|
||||
<filter string="Year" icon="terp-sale" context="{'group_by':'year'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_order_report_all" model="ir.actions.act_window">
|
||||
<field name="name">Sales Orders</field>
|
||||
<field name="res_model">sale.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,graph</field>
|
||||
<field name="search_view_id" ref="view_order_product_search"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="base.next_id_64" name="Reporting" parent="base.menu_base_partner" sequence="8"/>
|
||||
<menuitem action="action_order_report_all" id="menu_report_product_all" parent="base.next_id_64" sequence="3"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue