[IMP] Improved sale dashboard.

bzr revid: jni@tinyerp.com-20100622113904-75gojl7iaaxybs23
This commit is contained in:
rch(OpenERP) 2010-06-22 17:09:04 +05:30 committed by Jni (Open ERP)
parent 1e8ea9dd3b
commit bafa49c7b7
3 changed files with 79 additions and 230 deletions

View File

@ -30,12 +30,12 @@
<form string="Sales Manager board">
<hpaned position="100">
<child1>
<action name="%(sale.action_suninvoiced_lines_per_month)d" string="Uninvoiced lines" />
<action name="%(sale.action_product_bought_by_sale_order)d" string="Product bought base on Sale Orders" />
<action name="%(sale.action_quotatio_for_sale)d" string="Quotation For Sale"/>
<action name="%(sale.action_sales_product_total_price_graph)d" string="Sold products and Total Price"/>
</child1>
<child2>
<action name="%(sale.action_sale_order_by_clients)d" string="Sale order by client" />
<action name="%(sale.action_sales_by_regions)d" string="Sales by regions" />
<action name="%(sale.action_sales_by_partner)d" string="Sales By Partner"/>
<action name="%(sale.action_sales_by_salesman)d" string="Sales By Salesman"/>
</child2>
</hpaned>
</form>

View File

@ -112,131 +112,5 @@ class sale_report(osv.osv):
""")
sale_report()
class sale_order_by_clients(osv.osv):
_name = "sale.order.by.clients"
_description = "Sales order by clients"
_auto = False
_rec_name = 'partner'
_columns = {
'total_orders': fields.integer('Total'),
'partner_id':fields.many2one('res.partner', 'Partner', readonly=True)
}
_order = 'total_orders desc'
def init(self, cr):
tools.drop_view_if_exists(cr, 'sale_order_by_clients')
cr.execute("""
create or replace view sale_order_by_clients as (
select
min(s.id) as id,
count(*) as total_orders,
s.partner_id as partner_id
from
sale_order s
where
s.state='manual' or s.state='progress'
group by
s.partner_id
)
""")
sale_order_by_clients()
class uninvoiced_lines_per_month(osv.osv):
_name = "uninvoiced.lines.per.month"
_description = "Uninvoiced lines per month"
_auto = False
_rec_name = 'month'
_columns = {
'number_of_lines': fields.integer('Total Lines', readonly=True),
'year': fields.char('Year', size=10, 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),
}
_order = 'number_of_lines desc'
def init(self, cr):
tools.drop_view_if_exists(cr, 'uninvoiced_lines_per_month')
cr.execute("""
create or replace view uninvoiced_lines_per_month as (
select
min(s.id) as id,
count(*) as number_of_lines,
to_char(s.create_date, 'MM') as month,
to_char(s.create_date, 'YYYY') as year
from
sale_order_line s
where
s.state='draft'
group by
to_char(s.create_date, 'MM'),to_char(s.create_date, 'YYYY')
)
""")
uninvoiced_lines_per_month()
class product_bought_by_sale_order(osv.osv):
_name = "product.bought.by.sale.order"
_description = "Product bought by sale order"
_auto = False
_rec_name = 'month'
_columns = {
'total_products': fields.integer('Total Products', readonly=True),
'product_id':fields.many2one('product.product', 'Product', 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),
'year': fields.char('Year', size=64, readonly=True)
}
_order = 'total_products desc'
def init(self, cr):
tools.drop_view_if_exists(cr, 'product_bought_by_sale_order')
cr.execute("""
create or replace view product_bought_by_sale_order as (
select
min(s.id) as id,
l.product_id as product_id,
to_char(l.create_date, 'MM') as month,
to_char(l.create_date, 'YYYY') as year,
count(*) as total_products
from
sale_order_line l
left join
sale_order s on (s.id=l.order_id)
where
s.state='manual' or s.state='progress'
group by
l.product_id, to_char(l.create_date, 'MM'), to_char(l.create_date, 'YYYY')
)
""")
product_bought_by_sale_order()
class sales_by_regions(osv.osv):
_name = "sales.by.regions"
_description = "Sales by regions"
_auto = False
_rec_name = 'name'
_columns = {
'total_sales': fields.integer('Total Sales', readonly=True),
'name': fields.char('Country', size=64, readonly=True),
}
_order = 'total_sales desc'
def init(self, cr):
tools.drop_view_if_exists(cr, 'sales_by_regions')
cr.execute("""
create or replace view sales_by_regions as (
select
min(s.id) as id,
rc.name as name,
count(s.name) as total_sales
from
sale_order s,res_partner_address p,res_country rc
where
s.partner_id=p.id and
p.country_id=rc.id and
(s.state='manual' or s.state='progress')
group by
rc.name
)
""")
sales_by_regions()

View File

@ -139,137 +139,112 @@
<!--This views used in board_sale module -->
<record id="view_sale_order_by_clients_tree" model="ir.ui.view">
<field name="name">sale.order.by.clients.tree</field>
<field name="model">sale.order.by.clients</field>
<record id="view_sales_by_partner_tree" model="ir.ui.view">
<field name="name">sales.by.partner.tree</field>
<field name="model">sale.report</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Sales order by clients">
<tree string="Sales By Partner">
<field name="partner_id"/>
<field name="total_orders"/>
<field name="price_total"/>
</tree>
</field>
</record>
<record id="view_sale_order_by_clients_graph" model="ir.ui.view">
<field name="name">sale.order.by.clients.graph</field>
<field name="model">sale.order.by.clients</field>
<record id="view_sales_by_partner_graph" model="ir.ui.view">
<field name="name">sales.by.partner.graph</field>
<field name="model">sale.report</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Sales order by clients" type="bar">
<graph string="Sales By Partner" type="bar">
<field name="partner_id" />
<field name="total_orders" operator="+"/>
<field name="price_total" operator="+"/>
</graph>
</field>
</record>
<record id="action_sale_order_by_clients" model="ir.actions.act_window">
<field name="name">Sales Orders</field>
<field name="res_model">sale.order.by.clients</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="view_id" ref="view_sale_order_by_clients_tree"/>
</record>
<record id="view_uninvoiced_lines_per_month_tree" model="ir.ui.view">
<field name="name">uninvoiced.lines.per.month.tree</field>
<field name="model">uninvoiced.lines.per.month</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Uninvoiced lines per month">
<field name="year"/>
<field name="month"/>
<field name="number_of_lines"/>
</tree>
</field>
</record>
<record id="view_uninvoiced_lines_per_month_graph" model="ir.ui.view">
<field name="name">uninvoiced.lines.per.month.graph</field>
<field name="model">uninvoiced.lines.per.month</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Uninvoiced lines per month" type="bar">
<field name="month" />
<field name="number_of_lines" operator="+"/>
</graph>
</field>
</record>
<record id="action_suninvoiced_lines_per_month" model="ir.actions.act_window">
<field name="name">Uninvoiced Lines</field>
<field name="res_model">uninvoiced.lines.per.month</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="view_id" ref="view_uninvoiced_lines_per_month_tree"/>
</record>
<record id="view_product_bought_by_sale_order_tree" model="ir.ui.view">
<field name="name">product.bought.by.sale.order.tree</field>
<field name="model">product.bought.by.sale.order</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Product bought by sale order">
<field name="product_id"/>
<field name="month"/>
<field name="year"/>
<field name="total_products"/>
</tree>
</field>
</record>
<record id="view_product_bought_by_sale_order_graph" model="ir.ui.view">
<field name="name">product.bought.by.sale.order.graph</field>
<field name="model">product.bought.by.sale.order</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Product bought by sale order" type="bar">
<field name="product_id" select="1"/>
<field name="total_products" select="1"/>
<field name="month" group = "True"/>
</graph>
</field>
</record>
<record id="action_product_bought_by_sale_order" model="ir.actions.act_window">
<field name="name">Product bought by sale order</field>
<field name="res_model">product.bought.by.sale.order</field>
<record id="action_sales_by_partner" model="ir.actions.act_window">
<field name="name">Sales By Partner</field>
<field name="res_model">sale.report</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="domain">[('year','=', time.strftime('%Y'))]</field>
<field name="view_id" ref="view_product_bought_by_sale_order_tree"/>
<field name="domain">[('state','in',('manual','progress')),('date','&lt;=', time.strftime('%Y-%m-%d')),('date','&gt;',(datetime.date.today()-datetime.timedelta(days=90)).strftime('%Y-%m-%d'))]</field>
<field name="view_id" ref="view_sales_by_partner_graph"/>
</record>
<record id="view_sales_by_regions_tree" model="ir.ui.view">
<field name="name">sales.by.regions.tree</field>
<field name="model">sales.by.regions</field>
<record id="view_sales_by_salesman_tree" model="ir.ui.view">
<field name="name">sales.by.salesman.tree</field>
<field name="model">sale.report</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Sales by regions">
<field name="name"/>
<field name="total_sales"/>
<tree string="Sales By Salesman">
<field name="user_id"/>
<field name="price_total"/>
</tree>
</field>
</record>
<record id="view_sales_by_regions_graph" model="ir.ui.view">
<field name="name">sales.by.regions.graph</field>
<field name="model">sales.by.regions</field>
<record id="view_sales_by_salesman_graph" model="ir.ui.view">
<field name="name">sales.by.salesman.graph</field>
<field name="model">sale.report</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Sales by regions" type="bar">
<field name="name"/>
<field name="total_sales" operator="+"/>
<graph string="Sales By Salesman" type="bar">
<field name="user_id" />
<field name="price_total" operator="+"/>
</graph>
</field>
</record>
<record id="action_sales_by_regions" model="ir.actions.act_window">
<field name="name">Sales by regions</field>
<field name="res_model">sales.by.regions</field>
<record id="action_sales_by_salesman" model="ir.actions.act_window">
<field name="name">Sales By Salesman</field>
<field name="res_model">sale.report</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="view_id" ref="view_sales_by_regions_tree"/>
<field name="view_mode">graph,tree</field>
<field name="domain">[('state','in',('manual','progress')),('date','&lt;=', time.strftime('%Y-%m-%d')),('date','&gt;',(datetime.date.today()-datetime.timedelta(days=90)).strftime('%Y-%m-%d'))]</field>
<field name="view_id" ref="view_sales_by_salesman_graph"/>
</record>
<record id="view_sales_product_total_price_tree" model="ir.ui.view">
<field name="name">sold.product.total.price.tree</field>
<field name="model">sale.report</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Sold products and Total Price">
<field name="product_id"/>
<field name="price_total"/>
</tree>
</field>
</record>
<record id="view_sales_product_total_price_graph" model="ir.ui.view">
<field name="name">sold.product.total.price.graph</field>
<field name="model">sale.report</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Sold products and Total Price" type="bar">
<field name="product_id" />
<field name="price_total" operator="+"/>
</graph>
</field>
</record>
<record id="action_sales_product_total_price_graph" model="ir.actions.act_window">
<field name="name">Sold product and Total Price</field>
<field name="res_model">sale.report</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="domain">[('state','in',('manual','progress')),('date','&lt;=', time.strftime('%Y-%m-%d')),('date','&gt;',(datetime.date.today()-datetime.timedelta(days=90)).strftime('%Y-%m-%d'))]</field>
<field name="view_id" ref="view_sales_product_total_price_graph"/>
</record>
<record id="action_quotatio_for_sale" model="ir.actions.act_window">
<field name="name">Quotation For Sale</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','draft'),('date_order','&lt;=', time.strftime('%Y-%m-%d')),('date_order','&gt;',(datetime.date.today()-datetime.timedelta(days=90)).strftime('%Y-%m-%d'))]</field>
<field name="view_id" ref="sale.view_order_tree"/>
</record>
</data>