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_partner(osv.osv):
36
_name = "report.profit.partner"
37
_description = "Profit by Products and Partner"
40
'partner_id':fields.many2one('res.partner', 'Partner', 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),
48
# where l.quantity != 0 and i.type in ('out_invoice', 'out_refund') and i.state in ('open', 'paid')
51
drop_view_if_exists(cr, 'report_profit_partner')
53
create or replace view report_profit_partner as (
57
SUM(last_cost) as sum_last_cost,
58
SUM(price_subtotal) as sum_price_subtotal,
59
SUM(qty_consol) as sum_qty_consol,
62
group by partner_id,p_uom_c_id
65
report_profit_partner()
68
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: