Browse Source

commit sale_report_partner

sebas 8 years ago
commit
db9548e318

+ 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 sale_report_partner
+import math

BIN
__init__.pyc


+ 48 - 0
__openerp__.py

@@ -0,0 +1,48 @@
+# -*- 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 Clientes en Ventas x Monto',
+    'version': '0.1',
+    'category': 'Product',
+    'description': """
+Listado de Clientes en Ventas x Monto
+========================================
+
+Genera un Listado de Productos más vendido en Ventas x Monto
+
+    """,
+    'author': 'Eiru/Sebastian Penayo',
+    'website': '',
+	'depends': ['sale','sales_team','account_voucher', 'base', 'report'],
+    'data': [
+		'sale_report_partner_view.xml',
+		'salepartner_filter_view.xml',
+		'sale_partner_view.xml',
+		'salepartner_report.xml',
+    ],
+    'installable': True,
+}

+ 54 - 0
sale_partner_view.xml

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="my_salepartner_tree_view" model="ir.ui.view">
+            <field name="name">Listado de clientes en ventas con monto</field>
+            <field name="model">sale.partner.model</field>
+            <field name="priority" eval="20"/>
+            <field name="arch" type="xml">
+                <tree string="Listado de clientes en ventas con monto" create="0">
+					<field name="partner_id" invisible="1"/>
+					<field name="name" string="Cliente"/>
+					<field name="street" string="Direccion"/>
+					<field name="email" string="Email"/>
+					<field name="mobile" string="Celular"/>
+					<field name="phone" string="Telefono"/>
+					<field name="total_facturado" string="Monto"/>
+					<field name="date" string="Fecha Ult.Venta"/>
+				</tree>
+            </field>
+        </record>
+
+		<record model="ir.ui.view" id="view_salereportpartner_form">
+            <field name="name">Listado de clientes en ventas con monto</field>
+            <field name="model">sale.partner.model</field>
+            <field eval="20" name="priority"/>
+            <field name="arch" type="xml">
+                <form string="Clientes" create="false" edit="false">
+                    <group>
+                        <field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
+                        <field name="name"/>
+                        <field name="street"/>
+						            <field name="email"/>
+						            <field name="mobile"/>
+                    </group>
+                </form>
+            </field>
+        </record>
+
+		<record id="action_mysalepartner_tree_view" model="ir.actions.act_window">
+            <field name="name">Listado de clientes en ventas con monto</field>
+            <field name="res_model">sale.partner.model</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+
+		<!-- <menuitem name="Listado de Cliente en ventas por Monto" id="menu_sale_ofsalepart"
+            parent="base.menu_base_partner" sequence="5"/>
+
+		<menuitem name="Listado de Cliente en ventas por Monto" id="id_menu_registro_salepartner"
+            parent="menu_sale_ofsalepart" action="action_mysalepartner_tree_view" sequence="1"/> -->
+
+		<menuitem id="menu_sale_ofsalepart" name="Listado de Cliente en ventas por Montos" parent="base.next_id_64" groups="base.group_sale_salesman" sequence="7" action="action_mysalepartner_tree_view"/>
+	</data>
+</openerp>

+ 50 - 0
sale_report_partner.py

@@ -0,0 +1,50 @@
+#                                                                               #
+#    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 sale_partner_model(osv.osv):
+    _name = "sale.partner.model"
+    _description = "Listado de Clientes"
+    _auto = False
+    _columns = {
+		'partner_id': fields.many2one('res.partner', string='Cliente', required=True, readonly=True),
+		'name': fields.char('Nombre', readonly=True),
+		'street': fields.char('Direccion', readonly=True),
+		'email': fields.char('Email', readonly=True),
+		'mobile': fields.char('Celular', readonly=True),
+		'phone': fields.char('Telefono', readonly=True),
+		'total_facturado': fields.float('Facturado', readonly=True),
+		'user_id':fields.many2one('res.users', 'Vendedor', readonly=True),
+		'date': fields.datetime('Fecha', readonly=True),
+    }
+    _order = 'total_facturado asc'
+
+    def init(self, cr):
+        tools.sql.drop_view_if_exists(cr, 'sale_partner_model')
+        cr.execute("""
+            CREATE OR REPLACE VIEW sale_partner_model AS (
+                SELECT 	a.id AS id,
+						c.partner_id AS partner_id,
+						a.name,
+						a.street AS street,
+						a.email AS email,
+						a.mobile AS mobile,
+						a.phone AS phone,
+						c.price_total AS total_facturado,
+						p.user_id as user_id,
+						c.date AS date
+				FROM res_partner a
+                left join sale_order p on p.partner_id=a.id
+				LEFT JOIN(select s.partner_id AS partner_id, sum(l.product_uom_qty * l.price_unit) as price_total, MAX(l.create_date) AS date 
+							from sale_order_line as l
+							left join sale_order s on s.id=l.order_id
+							group by partner_id) c on c.partner_id=a.id
+				WHERE a.customer= True and c.price_total>0
+            )
+        """)
+sale_partner_model()

BIN
sale_report_partner.pyc


+ 83 - 0
sale_report_partner_view.xml

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<template id="report_salexpartner">
+			<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 clientes/ventas con monto</h4>
+						<div class="logo1" />
+						 
+						  <table class="table table-condensed">
+							<thead class="crm_tcab">
+								<tr class="active">
+									<th>Cliente</th>
+									<th>Direccion</th>
+									<th>Email</th>
+									<th>Telefono</th>
+									<th>Celular</th>
+									<th class="text-right">Facturado</th>
+									<th>Ult.Fecha Venta</th>
+								</tr>
+							</thead>
+							<t t-foreach="docs" t-as="o">
+							<tbody>			  									
+									<tr>
+										<td class="text-left">
+											<span t-field="o.name"/>
+										</td>
+										<td class="text-left">
+											<span t-field="o.street"/>
+										</td>
+										<td class="text-left">
+											<span t-field="o.email"/>
+										</td>
+										<td class="text-left">
+											<span t-field="o.phone"/>
+										</td>
+										<td class="text-left">
+											<span t-field="o.mobile"/>
+										</td>
+										<td class="text-right">
+											<span t-field="o.total_facturado"/>
+										</td> 
+										<td class="text-left">
+											<span t-field="o.date"/>
+										</td>
+									</tr>	
+							</tbody>
+							</t>
+						  </table>
+						  
+					</div>
+				</t>
+			</t>
+		</template>
+	</data>
+</openerp> 
+
+                        
+                                       
+                                    

+ 46 - 0
salepartner_filter_view.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+
+    <!-- Custom reports (aka filters) -->
+
+<!--     <record id="filter_tsale_report_salespersons1" model="ir.filters">
+        <field name="name">Por Mes</field>
+        <field name="model_id">sale.partner.model</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by':['date:month']}</field>
+    </record> -->
+
+	<record id="filter_tsale_report_partner1" model="ir.filters">
+        <field name="name">Por Mes/Cliente</field>
+        <field name="model_id">sale.partner.model</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by':['date:month','partner_id']}</field>
+    </record>
+	
+	<record id="filter_tpos_report_salespersons1" model="ir.filters">
+        <field name="name">Por Mes/Vendedor</field>
+        <field name="model_id">sale.partner.model</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by':['date:month','user_id']}</field>
+    </record>
+
+    <record id="view_order_tsale_search1" model="ir.ui.view">
+        <field name="name">sale.partner.search</field>
+        <field name="model">sale.partner.model</field>
+        <field name="arch" type="xml">
+            <search string="Analisis de Ventas">
+                <field name="date"/>
+                <filter string="Este Ano" name="year" invisible="1" domain="[('date','&lt;=', time.strftime('%%Y-12-31')),('date','&gt;=',time.strftime('%%Y-01-01'))]"/>
+                <separator/>
+                <field name="partner_id"/>
+                <group expand="0" string="Agrupar por">
+                    <filter string="Ordenar Mes" context="{'group_by':'date:month'}" help="Ordered date of the sales order"/>
+					<filter string="Vendedor" name="User" context="{'group_by':'user_id'}"/>
+                </group>
+            </search>
+        </field>
+    </record>
+
+</data>
+</openerp>

+ 12 - 0
salepartner_report.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+		<report id="my_report_salepartner"
+            model="sale.partner.model"
+            string="Listado de Cliente en Ventas x Monto"
+            report_type="qweb-pdf"
+            name="sale_report_partner.report_salexpartner"
+            file="sale_report_partner.report_salexpartner"
+        />
+    </data>
+</openerp>

BIN
static/description/icon.png