Pārlūkot izejas kodu

Informe de ranking de productos más vendido

sebas 3 gadi atpakaļ
revīzija
df212d139f

+ 28 - 0
__init__.py

@@ -0,0 +1,28 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#    product_brand for OpenERP                                                  #
+#    Copyright (C) 2009 NetAndCo (<http://www.netandco.net>).                   #
+#    Authors, Mathieu Lemercier, mathieu@netandco.net,                          #
+#             Franck Bret, franck@netandco.net                                  #
+#    Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com>   #
+#                                                                               #
+#    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/>.      #
+#                                                                               #
+#################################################################################
+###################################################################################
+# Product Brand is an Openobject module wich enable Brand management for products #
+###################################################################################
+from . import my_report
+import math

BIN
__init__.pyc


+ 47 - 0
__openerp__.py

@@ -0,0 +1,47 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#    product_features for OpenERP                                                  #
+#    Copyright (C) 2009 NetAndCo (<http://www.netandco.net>).                   #
+#    Authors, Mathieu Lemercier, mathieu@netandco.net,                          #
+#             Franck Bret, franck@netandco.net                                  #
+#    Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com>   #
+#                                                                               #
+#    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/>.      #
+#                                                                               #
+#################################################################################
+###################################################################################
+# Product features is an Openobject module wich enable features management for products #
+###################################################################################
+{
+    'name': 'Listado de Productos más vendido',
+    'version': '0.1',
+    'category': 'Product',
+    'description': """
+Listado de Productos más vendido
+========================================
+
+Genera un Listado de Productos más vendido
+
+    """,
+    'author': 'Eiru/Sebastian Penayo1',
+    'website': 'http://www.paraguayenlaweb.com',
+	'depends': ['sale','sales_team','account_voucher', 'procurement', 'report'],
+    'data': [
+		'informe_productos_masvendido_view.xml',
+		'productos_masvendidos_view.xml',
+		'salevendido_report.xml',
+    ],
+    'installable': True,
+}

+ 67 - 0
informe_productos_masvendido_view.xml

@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<template id="report_productosmasvendido">
+			<t t-call="report.html_container">
+				<t t-call="report.external_layout">
+					<div class="page">
+						<style type="text/css">
+							.crm_tcab{
+							font-size: 3mm;
+							font-family: Arial, Helvetica, sans-serif;
+							}
+
+							.crm_tbody{
+							font-size: 2.8mm;
+							font-family: Arial, Helvetica, sans-serif;
+							}
+
+							.logo1{
+							width: 100%;
+							top: 1.5cm;
+							}
+
+							.total1{
+							font-size: 2.8mm;
+							font-family: Arial, Helvetica, sans-serif;
+							}
+
+						</style>
+						<h4 class="text-center">Listado de Productos más vendido</h4>
+						<div class="logo1" />
+						 
+						  <table class="table table-condensed">
+							<thead class="crm_tcab">
+								<tr class="active">
+									<th>Producto</th>
+									<th class="text-left">Cantidad</th>
+									<th class="text-left">Fecha Ult.Venta</th>
+								</tr>
+							</thead>
+							<t t-foreach="docs" t-as="o">
+							<tbody>			  									
+									<tr>
+										<td class="text-left">
+											<span t-field="o.product_id"/>
+										</td>
+										<td class="text-left">
+											<span t-field="o.suma"/>
+										</td> 
+										<td class="text-left">
+											<span t-field="o.lastdate"/>
+										</td> 
+									</tr>	
+							</tbody>
+							</t>
+						  </table>
+						  
+					</div>
+				</t>
+			</t>
+		</template>
+	</data>
+</openerp> 
+
+                        
+                                       
+                                    

+ 37 - 0
my_report.py

@@ -0,0 +1,37 @@
+#                                                                               #
+#    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.osv import fields,osv
+from openerp import tools
+
+class my_report_model(osv.osv):
+	_name = "my.report.model"
+	_description = "Listado de productos más vendidos"
+	_auto = False
+	_columns = {
+		'product_id': fields.many2one('product.product', string='Producto', required=True, readonly=True),
+		'nombre': fields.char('Nombre', size=128, readonly=True),
+		'suma': fields.float('Cantidad', readonly=True),
+		'lastdate': fields.date('Fecha Ult.Venta', readonly=True)
+	}
+	# _order = 'suma ASC'
+
+	def init(self, cr):
+		tools.sql.drop_view_if_exists(cr, 'my_report_model')
+		cr.execute("""
+            CREATE OR REPLACE VIEW my_report_model AS (
+                SELECT
+					a.id AS id,
+					c.product_id AS product_id,
+					c.nombre AS nombre,
+					c.pos AS suma,
+					c.lastdate
+                FROM product_template a
+                LEFT JOIN(select product_id AS product_id,name AS nombre,SUM(product_uom_qty) AS pos , MAX(create_date) AS lastdate from sale_order_line group by product_id,name) c on c.product_id=a.id
+                WHERE c.pos>0 ORDER BY c.pos DESC
+            )
+        """)
+my_report_model()

BIN
my_report.pyc


+ 44 - 0
productos_masvendidos_view.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <record id="my_report_tree_view" model="ir.ui.view">
+            <field name="name">Producto</field>
+            <field name="model">my.report.model</field>
+            <field name="priority" eval="20"/>
+            <field name="arch" type="xml">
+			    <tree string="Listado de Productos mas vendidos" create="0">
+					<field name="product_id"/>
+					<field name="suma" string="Cantidad"/>
+					<field name="lastdate" string="Fecha Ult. Venta"/>
+				</tree>
+            </field>
+        </record>
+
+		<record model="ir.ui.view" id="view_my_report_form">
+            <field name="name">Listado de productos mas vendidos</field>
+            <field name="model">my.report.model</field>
+            <field eval="20" name="priority"/>
+            <field name="arch" type="xml">
+                <form string="Productos" create="false" edit="false">
+                    <group>
+                        <field name="product_id" on_change="onchange_product_id(product_id)" domain="[('type','!=','service')]"/>
+                        <field name="suma"/>
+					             	<field name="lastdate"/>
+                    </group>
+                </form>
+            </field>
+        </record>
+
+		<record id="action_my_report_tree_view" model="ir.actions.act_window">
+            <field name="name">Listado de productos mas vendidos</field>
+            <field name="res_model">my.report.model</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+
+
+	<menuitem action="action_my_report_tree_view" name="Listado de productos mas vendidos" id="producto_masvendido_menu" parent="base.menu_sales" sequence="30"/>
+
+	</data>
+</openerp>

+ 12 - 0
salevendido_report.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+		<report id="my_report"
+            model="my.report.model"
+            string="Listado de Productos más vendido"
+            report_type="qweb-pdf"
+            name="my_report.report_productosmasvendido"
+            file="my_report.report_productosmasvendido"
+        />
+    </data>
+</openerp>

BIN
static/description/icon.png