~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to report_profit/tmp/report_profit_var.py

  • Committer: Jose Antonio
  • Date: 2012-04-22 20:38:11 UTC
  • mto: This revision was merged to the branch mainline in revision 212.
  • Revision ID: jose@vauxoo.com-20120422203811-ahks9nmn4pck8bl8

[ADD] Added news modules to cancel invoices with withholding income and vat 

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_uxp(osv.osv):
 
36
    _name = "report.profit.uxp"
 
37
    _description = "Profit by Products and User and Partner"
 
38
    _auto = False
 
39
    _columns = {
 
40
        'user_id':fields.many2one('res.users', 'User', readonly=True, select=True),
 
41
        'partner_id':fields.many2one('res.partner', 'Partner', readonly=True, select=True),
 
42
        'sum_last_cost': fields.float('Last Cost Sum', readonly=True),
 
43
        'sum_price_subtotal': fields.float('Subtotal Price Sum', readonly=True),
 
44
        'sum_qty_consol': fields.float('Consolidate qty Sum', readonly=True),
 
45
        'p_uom_c_id':fields.many2one('product.uom.consol', 'Consolidate Unit', readonly=True),
 
46
    }
 
47
 
 
48
 
 
49
#            where l.quantity != 0 and i.type in ('out_invoice', 'out_refund') and i.state in ('open', 'paid')
 
50
 
 
51
    def init(self, cr):
 
52
        drop_view_if_exists(cr, 'report_profit_uxp')
 
53
        cr.execute("""
 
54
            create or replace view report_profit_uxp as (
 
55
            select
 
56
                ((user_id*1000000)+partner_id) as id,
 
57
                user_id,
 
58
                partner_id,        
 
59
                SUM(last_cost) as sum_last_cost,
 
60
                SUM(price_subtotal) as sum_price_subtotal,
 
61
                SUM(qty_consol) as sum_qty_consol,
 
62
                p_uom_c_id
 
63
            from report_profit p
 
64
            group by user_id,partner_id,p_uom_c_id
 
65
            )
 
66
        """)
 
67
report_profit_uxp()
 
68
 
 
69
 
 
70
 
 
71
class report_profit_uxc(osv.osv):
 
72
    _name = "report.profit.uxc"
 
73
    _description = "Profit by Products and User and Category"
 
74
    _auto = False
 
75
    _columns = {
 
76
        'user_id':fields.many2one('res.users', 'User', readonly=True, select=True),
 
77
        'cat_id':fields.many2one('product.category', 'Category', readonly=True, select=True),
 
78
        'sum_last_cost': fields.float('Last Cost Sum', readonly=True),
 
79
        'sum_price_subtotal': fields.float('Subtotal Price Sum', readonly=True),
 
80
        'sum_qty_consol': fields.float('Consolidate qty Sum', readonly=True),
 
81
        'p_uom_c_id':fields.many2one('product.uom.consol', 'Consolidate Unit', readonly=True),
 
82
    }
 
83
 
 
84
 
 
85
#            where l.quantity != 0 and i.type in ('out_invoice', 'out_refund') and i.state in ('open', 'paid')
 
86
 
 
87
    def init(self, cr):
 
88
        drop_view_if_exists(cr, 'report_profit_uxc')
 
89
        cr.execute("""
 
90
            create or replace view report_profit_uxc as (
 
91
            select
 
92
                ((user_id*1000000)+cat_id) as id,
 
93
                user_id,
 
94
                cat_id,        
 
95
                SUM(last_cost) as sum_last_cost,
 
96
                SUM(price_subtotal) as sum_price_subtotal,
 
97
                SUM(qty_consol) as sum_qty_consol,
 
98
                p_uom_c_id
 
99
            from report_profit p
 
100
            group by user_id,cat_id,p_uom_c_id
 
101
            )
 
102
        """)
 
103
report_profit_uxc()
 
104
 
 
105
 
 
106
class report_profit_pxc(osv.osv):
 
107
    _name = "report.profit.pxc"
 
108
    _description = "Profit by Products and Partner and Category"
 
109
    _auto = False
 
110
    _columns = {
 
111
        'partner_id':fields.many2one('res.partner', 'Partner', readonly=True, select=True),
 
112
        'cat_id':fields.many2one('product.category', 'Category', readonly=True, select=True),
 
113
        'sum_last_cost': fields.float('Last Cost Sum', readonly=True),
 
114
        'sum_price_subtotal': fields.float('Subtotal Price Sum', readonly=True),
 
115
        'sum_qty_consol': fields.float('Consolidate qty Sum', readonly=True),
 
116
        'p_uom_c_id':fields.many2one('product.uom.consol', 'Consolidate Unit', readonly=True),
 
117
    }
 
118
 
 
119
 
 
120
#            where l.quantity != 0 and i.type in ('out_invoice', 'out_refund') and i.state in ('open', 'paid')
 
121
 
 
122
    def init(self, cr):
 
123
        drop_view_if_exists(cr, 'report_profit_pxc')
 
124
        cr.execute("""
 
125
            create or replace view report_profit_pxc as (
 
126
            select
 
127
                ((cat_id*1000000)+partner_id) as id,
 
128
                partner_id,
 
129
                cat_id,        
 
130
                SUM(last_cost) as sum_last_cost,
 
131
                SUM(price_subtotal) as sum_price_subtotal,
 
132
                SUM(qty_consol) as sum_qty_consol,
 
133
                p_uom_c_id
 
134
            from report_profit p
 
135
            group by partner_id,cat_id,p_uom_c_id
 
136
            )
 
137
        """)
 
138
report_profit_pxc()
 
139
 
 
140
 
 
141
class report_profit_upc(osv.osv):
 
142
    _name = "report.profit.upc"
 
143
    _description = "Profit by Products and User,Partner and Category"
 
144
    _auto = False
 
145
    _columns = {
 
146
        'user_id':fields.many2one('res.users', 'User', readonly=True, select=True),
 
147
        'partner_id':fields.many2one('res.partner', 'Partner', readonly=True, select=True),
 
148
        'cat_id':fields.many2one('product.category', 'Category', readonly=True, select=True),
 
149
        'sum_last_cost': fields.float('Last Cost Sum', readonly=True),
 
150
        'sum_price_subtotal': fields.float('Subtotal Price Sum', readonly=True),
 
151
        'sum_qty_consol': fields.float('Consolidate qty Sum', readonly=True),
 
152
        'p_uom_c_id':fields.many2one('product.uom.consol', 'Consolidate Unit', readonly=True),
 
153
    }
 
154
 
 
155
 
 
156
#            where l.quantity != 0 and i.type in ('out_invoice', 'out_refund') and i.state in ('open', 'paid')
 
157
 
 
158
    def init(self, cr):
 
159
        drop_view_if_exists(cr, 'report_profit_upc')
 
160
        cr.execute("""
 
161
            create or replace view report_profit_upc as (
 
162
            select
 
163
                ((user_id*100000000000)+(cat_id*1000000)+partner_id) as id,
 
164
                user_id,
 
165
                partner_id,
 
166
                cat_id,        
 
167
                SUM(last_cost) as sum_last_cost,
 
168
                SUM(price_subtotal) as sum_price_subtotal,
 
169
                SUM(qty_consol) as sum_qty_consol,
 
170
                p_uom_c_id
 
171
            from report_profit p
 
172
            group by user_id,partner_id,cat_id,p_uom_c_id
 
173
            )
 
174
        """)
 
175
report_profit_upc()
 
176
 
 
177
 
 
178
 
 
179
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
180