~vauxoo/addons-vauxoo/7.0-project_issue_conf-dev_luis

« back to all changes in this revision

Viewing changes to report_profit/report_profit_category.py

  • Committer: Javier Duran
  • Date: 2012-01-30 16:55:47 UTC
  • Revision ID: javier@squezee-vir-20120130165547-8bn2rxdgxzplqpfy
[ADD] se agrega el modulo report profit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
# Copyright (c) 2010 Vauxoo C.A. (http://openerp.com.ve/) All Rights Reserved.
 
5
#                    Javier Duran <javier@vauxoo.com>
 
6
 
7
#
 
8
# WARNING: This program as such is intended to be used by professional
 
9
# programmers who take the whole responsability of assessing all potential
 
10
# consequences resulting from its eventual inadequacies and bugs
 
11
# End users who are looking for a ready-to-use solution with commercial
 
12
# garantees and support are strongly adviced to contract a Free Software
 
13
# Service Company
 
14
#
 
15
# This program is Free Software; you can redistribute it and/or
 
16
# modify it under the terms of the GNU General Public License
 
17
# as published by the Free Software Foundation; either version 2
 
18
# of the License, or (at your option) any later version.
 
19
#
 
20
# This program is distributed in the hope that it will be useful,
 
21
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
23
# GNU General Public License for more details.
 
24
#
 
25
# You should have received a copy of the GNU General Public License
 
26
# along with this program; if not, write to the Free Software
 
27
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
28
#
 
29
##############################################################################
 
30
 
 
31
from osv import fields,osv
 
32
from tools.sql import drop_view_if_exists
 
33
 
 
34
 
 
35
class report_profit_category(osv.osv):
 
36
    _name = "report.profit.category"
 
37
    _description = "Profit by Products and Category"
 
38
    _auto = False
 
39
    _columns = {
 
40
        'cat_id':fields.many2one('product.category', 'Category', readonly=True, select=True),
 
41
        'sum_last_cost': fields.float('Last Cost Sum', readonly=True),
 
42
        'sum_price_subtotal': fields.float('Subtotal Price Sum', readonly=True),
 
43
        'sum_qty_consol': fields.float('Consolidate qty Sum', readonly=True),
 
44
        'p_uom_c_id':fields.many2one('product.uom.consol', 'Consolidate Unit', readonly=True),
 
45
    }
 
46
 
 
47
 
 
48
#            where l.quantity != 0 and i.type in ('out_invoice', 'out_refund') and i.state in ('open', 'paid')
 
49
 
 
50
    def init(self, cr):
 
51
        drop_view_if_exists(cr, 'report_profit_category')
 
52
        cr.execute("""
 
53
            create or replace view report_profit_category as (
 
54
            select
 
55
                cat_id as id,
 
56
                cat_id,        
 
57
                SUM(last_cost) as sum_last_cost,
 
58
                SUM(price_subtotal) as sum_price_subtotal,
 
59
                SUM(qty_consol) as sum_qty_consol,
 
60
                p_uom_c_id
 
61
            from report_profit p
 
62
            group by cat_id,p_uom_c_id
 
63
            )
 
64
        """)
 
65
report_profit_category()
 
66
 
 
67
 
 
68
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
69