|
@@ -0,0 +1,70 @@
|
|
|
|
+# -*- 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 salegralvariant_report(osv.osv):
|
|
|
|
+ _name = "salegralvariant.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),
|
|
|
|
+ 'att_id': fields.many2one('product.attribute.value', 'Atributo', readonly=True),
|
|
|
|
+ 'fname': fields.char('nombre', readonly=True),
|
|
|
|
+ 'product_brand_id': fields.many2one('product.brand', 'Marca', readonly=True),
|
|
|
|
+ 'product_genre_id': fields.many2one('product.genre', 'Genero', 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, 'salegralvariant_report')
|
|
|
|
+ cr.execute("""
|
|
|
|
+ create or replace view salegralvariant_report as (
|
|
|
|
+ SELECT row_number() over (ORDER BY 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,
|
|
|
|
+ f.name as fname,
|
|
|
|
+ zr.att_id as att_id,
|
|
|
|
+ pt.product_brand_id as product_brand_id,
|
|
|
|
+ pt.product_genre_id as product_genre_id,
|
|
|
|
+ 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 product_brand r on (r.id=pt.product_brand_id)
|
|
|
|
+ left join product_genre z on (z.id=pt.product_genre_id)
|
|
|
|
+ left join sale_order s on (s.id=l.order_id)
|
|
|
|
+ left join product_attribute_value_product_product_rel zr on (p.id=zr.prod_id)
|
|
|
|
+ left join product_attribute_value f on (f.id=zr.att_id)
|
|
|
|
+ where s.state='done'
|
|
|
|
+ group by
|
|
|
|
+ p.id, f.name,f.id,zr.att_id,s.partner_id,l.product_id,s.date_order,pt.product_brand_id,pt.categ_id,pt.product_genre_id)""")
|
|
|
|
+
|
|
|
|
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|