1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- # -*- coding: utf-8 -*-
- ##############################################################################
- #
- # OpenERP, Open Source Management Solution
- # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Affero General Public License as
- # published by the Free Software Foundation, either version 3 of the
- # License, or (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU Affero General Public License for more details.
- #
- # You should have received a copy of the GNU Affero General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- ##############################################################################
- from openerp import tools
- from openerp.osv import fields, osv
- class salegralsinvariant_report(osv.osv):
- _name = "salegralsinvariant.report"
- _description = "Listado General de Ventas por variantes"
- _auto = False
- _rec_name = 'date'
- _columns = {
- 'date': fields.datetime('Date Order', readonly=True),
- 'partner_id':fields.many2one('res.partner', 'Cliente', readonly=True),
- 'product_id':fields.many2one('product.product', 'Producto', readonly=True),
- 'product_qty':fields.integer('Product Quantity', readonly=True),
- 'product_categ_id': fields.many2one('product.category', 'Categoria', readonly=True),
- }
- _order = 'date desc'
- def init(self, cr):
- tools.drop_view_if_exists(cr, 'salegralsinvariant_report')
- cr.execute("""
- create or replace view salegralsinvariant_report as (
- SELECT
- min(p.id) as id,
- s.date_order as date,
- s.partner_id as partner_id,
- l.product_id as product_id,
- sum(l.product_uom_qty) as product_qty,
- pt.categ_id as product_categ_id
- from sale_order_line l
- left join product_product p on (p.id=l.product_id)
- left join product_template pt on (pt.id=p.product_tmpl_id)
- left join sale_order s on (s.id=l.order_id)
- where s.state='done'
- group by
- s.partner_id,l.product_id,s.date_order,pt.categ_id)""")
- # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|