1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2010 Vauxoo C.A. (http://openerp.com.ve/) All Rights Reserved.
5
# Javier Duran <javier@vauxoo.com>
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
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.
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.
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.
29
##############################################################################
31
from osv import fields,osv
32
from tools.sql import drop_view_if_exists
35
class report_profit_uxp(osv.osv):
36
_name = "report.profit.uxp"
37
_description = "Profit by Products and User and Partner"
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),
49
# where l.quantity != 0 and i.type in ('out_invoice', 'out_refund') and i.state in ('open', 'paid')
52
drop_view_if_exists(cr, 'report_profit_uxp')
54
create or replace view report_profit_uxp as (
56
((user_id*1000000)+partner_id) as 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,
64
group by user_id,partner_id,p_uom_c_id
71
class report_profit_uxc(osv.osv):
72
_name = "report.profit.uxc"
73
_description = "Profit by Products and User and Category"
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),
85
# where l.quantity != 0 and i.type in ('out_invoice', 'out_refund') and i.state in ('open', 'paid')
88
drop_view_if_exists(cr, 'report_profit_uxc')
90
create or replace view report_profit_uxc as (
92
((user_id*1000000)+cat_id) as 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,
100
group by user_id,cat_id,p_uom_c_id
106
class report_profit_pxc(osv.osv):
107
_name = "report.profit.pxc"
108
_description = "Profit by Products and Partner and Category"
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),
120
# where l.quantity != 0 and i.type in ('out_invoice', 'out_refund') and i.state in ('open', 'paid')
123
drop_view_if_exists(cr, 'report_profit_pxc')
125
create or replace view report_profit_pxc as (
127
((cat_id*1000000)+partner_id) as 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,
135
group by partner_id,cat_id,p_uom_c_id
141
class report_profit_upc(osv.osv):
142
_name = "report.profit.upc"
143
_description = "Profit by Products and User,Partner and Category"
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),
156
# where l.quantity != 0 and i.type in ('out_invoice', 'out_refund') and i.state in ('open', 'paid')
159
drop_view_if_exists(cr, 'report_profit_upc')
161
create or replace view report_profit_upc as (
163
((user_id*100000000000)+(cat_id*1000000)+partner_id) as 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,
172
group by user_id,partner_id,cat_id,p_uom_c_id
179
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: