[IMP] replace the Order Analysis tree view by a graph view to use the new Pivot table. Also, removes the Day/Month/Year attributes of the postgres view (addon point_of_sale)

bzr revid: ged@openerp.com-20140130094455-cai7dvvozwhojaff
This commit is contained in:
Gery Debongnie 2014-01-30 10:44:55 +01:00
parent 7fd82bc83b
commit e58efb7361
2 changed files with 18 additions and 41 deletions

View File

@ -28,11 +28,6 @@ class pos_order_report(osv.osv):
_auto = False
_columns = {
'date': fields.date('Date Order', 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),
'day': fields.char('Day', size=128, readonly=True),
'partner_id':fields.many2one('res.partner', 'Partner', readonly=True),
'product_id':fields.many2one('product.product', 'Product', readonly=True),
'state': fields.selection([('draft', 'New'), ('paid', 'Closed'), ('done', 'Synchronized'), ('invoiced', 'Invoiced'), ('cancel', 'Cancelled')],
@ -57,15 +52,12 @@ class pos_order_report(osv.osv):
select
min(l.id) as id,
count(*) as nbr,
to_date(to_char(s.date_order, 'dd-MM-YYYY'),'dd-MM-YYYY') as date,
s.date_order as date,
sum(l.qty * u.factor) as product_qty,
sum(l.qty * l.price_unit) as price_total,
sum((l.qty * l.price_unit) * (l.discount / 100)) as total_discount,
(sum(l.qty*l.price_unit)/sum(l.qty * u.factor))::decimal(16,2) as average_price,
sum(cast(to_char(date_trunc('day',s.date_order) - date_trunc('day',s.create_date),'DD') as int)) as delay_validation,
to_char(s.date_order, 'YYYY') as year,
to_char(s.date_order, 'MM') as month,
to_char(s.date_order, 'YYYY-MM-DD') as day,
s.partner_id as partner_id,
s.state as state,
s.user_id as user_id,
@ -78,8 +70,7 @@ class pos_order_report(osv.osv):
left join product_template pt on (pt.id=l.product_id)
left join product_uom u on (u.id=pt.uom_id)
group by
to_char(s.date_order, 'dd-MM-YYYY'),to_char(s.date_order, 'YYYY'),to_char(s.date_order, 'MM'),
to_char(s.date_order, 'YYYY-MM-DD'), s.partner_id,s.state,
s.date_order, s.partner_id,s.state,
s.user_id,s.warehouse_id,s.company_id,s.sale_journal,l.product_id,s.create_date
having
sum(l.qty * u.factor) != 0)""")

View File

@ -1,29 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_report_pos_order_tree" model="ir.ui.view">
<field name="name">report.pos.order.tree</field>
<record id="view_report_pos_order_graph" model="ir.ui.view">
<field name="name">report.pos.order.graph</field>
<field name="model">report.pos.order</field>
<field name="arch" type="xml">
<tree string="Point of Sale Analysis" create="false">
<field name="date" invisible="1"/>
<field name="user_id" invisible="1"/>
<field name="year" invisible="1"/>
<field name="day" invisible="1"/>
<field name="month" invisible="1"/>
<field name="partner_id" invisible="1"/>
<field name="product_id" invisible="1"/>
<field name="warehouse_id" invisible="1"/>
<!--<field name="journal_id" invisible="1"/>-->
<field name="company_id" invisible="1" groups="base.group_multi_company"/>
<field name="nbr" sum="# of Lines"/>
<field name="product_qty" sum="# of Qty"/>
<field name="average_price" sum="Average Price"/>
<field name="total_discount" sum="Total Discount"/>
<field name="price_total" sum="Total Price"/>
<field name="delay_validation"/>
<!--<field name="state" invisible="1"/>-->
</tree>
<graph string="Point of Sale Analysis" type="pivot">
<field name="date" interval="day" type="row"/>
<field name="nbr" type="measure"/>
<field name="product_qty" type="measure"/>
<field name="average_price" type="measure"/>
<field name="total_discount" type="measure"/>
<field name="price_total" type="measure"/>
</graph>
</field>
</record>
@ -36,10 +25,7 @@
<filter icon="terp-dolar" string="Invoiced" domain="[('state','=',('invoiced'))]"/>
<filter icon="terp-dolar" string="Not Invoiced" domain="[('state','=',('paid'))]"/>
<separator/>
<filter icon="terp-go-year" string="Year" name="year" domain="[('year','=',time.strftime('%%Y'))]" help="POS ordered created during current year"/>
<separator/>
<filter icon="terp-go-today" string="Today" name="today" domain="[('date','=', time.strftime('%%Y-%%m-%%d'))]"
help="POS ordered created by today"/>
<filter icon="terp-go-year" string="Year" name="year" domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-01-01'))]" help="POS ordered created during current year"/>
<separator/>
<filter icon="terp-personal" string="My Sales" help="My Sales" domain="[('user_id','=',uid)]"/>
<field name="partner_id"/>
@ -50,9 +36,9 @@
<filter string="Salesperson" icon="terp-personal" name="User" context="{'group_by':'user_id'}"/>
<filter string="Customer" icon="terp-personal" context="{'group_by':'partner_id'}"/>
<filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
<filter string="Day" icon="terp-go-today" context="{'group_by':'day'}" help="Day of order date"/>
<filter string="Month" icon="terp-go-month" context="{'group_by':'month'}" help="Month of order date"/>
<filter string="Year" icon="terp-go-year" context="{'group_by':'year'}" help="Year of order date"/>
<filter string="Order Date (day)" icon="terp-go-today" context="{'group_by':'date:day'}" help="Day of order date"/>
<filter string="Order Date (month)" icon="terp-go-month" context="{'group_by':'date:month'}" help="Month of order date"/>
<filter string="Order Date (year)" icon="terp-go-year" context="{'group_by':'date:year'}" help="Year of order date"/>
</group>
</search>
</field>
@ -62,9 +48,9 @@
<field name="name">Orders Analysis</field>
<field name="res_model">report.pos.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="view_mode">graph</field>
<field name="search_view_id" ref="view_report_pos_order_search"/>
<field name="context">{'search_default_year':1,'search_default_today':1,'group_by_no_leaf':1,'group_by':['product_id']}</field>
<field name="context">{'search_default_year':1, 'group_by_no_leaf':1,'group_by':['product_id']}</field>
</record>
<menuitem action="action_report_pos_order_all" id="menu_report_pos_order_all" parent="menu_point_rep" sequence="3"/>