[IMP] changes in sales dashboard.

bzr revid: vir@tinyerp.com-20100402062334-fgh3r4mhemz9yssr
This commit is contained in:
RCH(Open ERP) 2010-04-02 11:53:34 +05:30 committed by Vir (Open ERP)
parent b09da9b87a
commit 0353f4434c
4 changed files with 269 additions and 16 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,7 +15,7 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

View File

@ -5,7 +5,7 @@
<field name="name">Sales</field>
</record>
<record model="ir.actions.act_window" id="board_crm_case_categ_phone_incoming0">
<!-- <record model="ir.actions.act_window" id="board_crm_case_categ_phone_incoming0">
<field name="res_model">crm.phonecall</field>
<field name="view_type">form</field>
<field name="view_mode">tree,calendar</field>
@ -22,22 +22,24 @@
<field name="domain">[('user_id','=',uid)]</field>
<field name="domain">[('date','&gt;=',time.strftime('%Y-%m-%d')),('date','&lt;=',(datetime.datetime.today() + datetime.timedelta(days=2)).strftime('%Y-%m-%d'))]</field>
<field name="context" eval="{'default_state':'open'}"/>
</record>
</record>-->
<record id="board_sales_manager_form" model="ir.ui.view">
<field name="name">board.sales.manager.form</field>
<field name="model">board.board</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Sales manager board">
<form string="Sales Manager board">
<hpaned position="100">
<child1>
<action colspan="4" height="200" name="%(sale.action_order_tree5)d" string="My quotations" width="510" domain="[('state','=','draft'),('user_id','=',uid)]"/>
<action colspan="4" name="%(board_crm_case_categ_phone_incoming0)d" string="My planned calling calls (IN / OUT)" width="510"/>
<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" />
</child1>
<child2>
<action colspan="4" name="%(crm.crm_case_category_act_oppor11)d" string="My Opportunities" width="510" domain="[('user_id','=',uid)]"/>
<action colspan="4" name="%(board_crm_case_categ_meet)d" String="My Meetings" domain="[('state','=','open')]" width="510"/>
<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" />
</child2>
</hpaned>
</form>

View File

@ -89,3 +89,125 @@ 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 = 'partner'
_columns = {
'total_products': fields.integer('Total Products', readonly=True),
'name': fields.char('Sale order', 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,
count(*) as total_products,
s.name as name
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
s.name
)
""")
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

@ -43,22 +43,22 @@
<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'))]"
<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"
string="This Month"
default="1"
domain="[('month','=',time.strftime('%%m'))]"
domain="[('month','=',time.strftime('%%m'))]"
help="Sales orders of this month"/>
<separator orientation="vertical"/>
<filter icon="terp-sale"
string="Quotations"
string="Quotations"
domain="[('state','=','draft')]"/>
<filter icon="terp-sale"
string="Sales"
string="Sales"
default="1"
domain="[('state','&lt;&gt;','draft'),('state','&lt;&gt;','cancel')]"/>
<separator orientation="vertical"/>
@ -99,5 +99,134 @@
<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"/>
<!-- 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>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Sales order by clients">
<field name="partner_id"/>
<field name="total_orders"/>
</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>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Sales order by clients" type="bar">
<field name="partner_id" />
<field name="total_orders" 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="name"/>
<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="name"/>
<field name="total_products" operator="+"/>
</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>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="view_id" ref="view_product_bought_by_sale_order_tree"/>
</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>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Sales by regions">
<field name="name"/>
<field name="total_sales"/>
</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>
<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>
</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>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="view_id" ref="view_sales_by_regions_tree"/>
</record>
</data>
</openerp>