Ver Fonte

commit my_report_partner

sebas há 8 anos atrás
commit
233a0678d7

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

BIN
__init__.pyc


+ 49 - 0
__openerp__.py

@@ -0,0 +1,49 @@
+# -*- 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 x Monto x ultima compra',
+    'version': '0.1',
+    'category': 'Product',
+    'description': """
+Listado de Clientes x Monto x ultima compra
+========================================
+
+Genera un Listado de cliente por ventas acumuladas con la fecha de su ultima compra
+
+    """,
+    'author': 'Eiru/Sebastian Penayo',
+    'website': 'http://www.paraguayenlaweb.com',
+	'depends': ['point_of_sale','sales_team','account_voucher', 'base', 'report'],
+    'data': [
+		'my_report_partner_view.xml',
+        'my_report_partnerfecha_view.xml',
+        'mypospartner_filter_view.xml',
+		'pos_partner_view.xml',
+		'pospartner_report.xml',
+    ],
+    'installable': True,
+}

+ 50 - 0
my_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 my_partner_model(osv.osv):
+    _name = "my.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 = 'date asc'
+
+    def init(self, cr):
+        tools.sql.drop_view_if_exists(cr, 'my_partner_model')
+        cr.execute("""
+            CREATE OR REPLACE VIEW my_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,
+                        c.user_id as user_id,
+						c.date AS date
+				FROM res_partner a
+				LEFT JOIN(select s.partner_id AS partner_id, sum(l.qty * l.price_unit) as price_total, MAX(l.create_date) AS date, s.user_id AS user_id
+							from pos_order_line as l
+							left join pos_order s on s.id=l.order_id
+							group by s.partner_id, s.user_id) c on c.partner_id=a.id
+				WHERE a.customer= True and c.price_total>0
+                ORDER BY c.date
+            )
+        """)
+my_partner_model()

BIN
my_report_partner.pyc


+ 59 - 0
my_report_partner_view.xml

@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<template id="report_posxpartner">
+			<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 con monto</h4>
+						<div class="logo1" />
+
+						  <table class="table table-condensed">
+							<thead class="crm_tcab">
+								<tr class="active">
+									<th>Cliente</th>
+									<th class="text-left">Facturado</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-right">
+											<span t-field="o.total_facturado"/>
+										</td>
+									</tr>
+							</tbody>
+							</t>
+						  </table>
+
+					</div>
+				</t>
+			</t>
+		</template>
+	</data>
+</openerp>

+ 59 - 0
my_report_partnerfecha_view.xml

@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<template id="report_posxpartnerfecha">
+			<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 por fecha</h4>
+						<div class="logo1" />
+
+						  <table class="table table-condensed">
+							<thead class="crm_tcab">
+								<tr class="active">
+									<th>Cliente</th>
+									<th class="text-left">Facturado</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.date"/>
+										</td>
+									</tr>
+							</tbody>
+							</t>
+						  </table>
+
+					</div>
+				</t>
+			</t>
+		</template>
+	</data>
+</openerp>

+ 47 - 0
mypospartner_filter_view.xml

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+
+    <!-- Custom reports (aka filters) -->
+	 <record id="filter_tpos_report_sales_funnel" model="ir.filters">
+        <field name="name">Por Cliente</field>
+        <field name="model_id">my.partner.model</field>
+        <field name="domain">['&amp;', ('date','&lt;=', time.strftime('%%Y-12-31')), '&amp;', ('date','&gt;=',time.strftime('%%Y-01-01'))]</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by': ['partner_id']}</field>
+    </record>
+
+    <!--<record id="filter_tpos_report_salespersons3" model="ir.filters">
+        <field name="name">Por Mes/Vendedor</field>
+        <field name="model_id">my.partner.model</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by':['date:month','user_id']}</field>
+    </record> -->
+
+	<record id="filter_tpos_report_partner2" model="ir.filters">
+        <field name="name">Por Mes</field>
+        <field name="model_id">my.partner.model</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by':['date:month']}</field>
+    </record>
+
+    <record id="view_order_tpos_search2" model="ir.ui.view">
+        <field name="name">pos.partner.search2</field>
+        <field name="model">my.partner.model</field>
+        <field name="arch" type="xml">
+            <search string="Analisis de Ventas">
+                <field name="date"/>
+                <filter string="Este ano" name="year" 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="Mes/Cliente" context="{'group_by':'date:month'}" help="Ordered date of the sales order"/>
+					          <filter string="Vendedor" name="User" context="{'group_by':'user_id'}"/>
+                    <filter string="Cliente" name="Cliente" context="{'group_by':'partner_id'}"/>
+                </group>
+            </search>
+        </field>
+    </record>
+
+</data>
+</openerp>

+ 53 - 0
pos_partner_view.xml

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="my_pospartner_tree_view" model="ir.ui.view">
+            <field name="name">Listado de clientes con monto</field>
+            <field name="model">my.partner.model</field>
+            <field name="priority" eval="20"/>
+            <field name="arch" type="xml">
+                <tree string="Listado de clientes con monto" create="0">
+					<field name="partner_id" invisible="1"/>
+					<field name="name" string="Cliente"/>
+					<field name="street" string="Direccion"/>
+					<field name="mobile" string="Celular"/>
+					<field name="phone" string="Telefono"/>
+          <field name="user_id" string="Vendedor"/>
+					<field name="total_facturado" string="Monto"/>
+					<field name="date" string="Fecha Ult.Pos"/>
+				</tree>
+            </field>
+        </record>
+
+		<record model="ir.ui.view" id="view_myreportpartner_form">
+            <field name="name">Listado de clientes con monto</field>
+            <field name="model">my.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="phone"/>
+						            <field name="mobile"/>
+                    </group>
+                </form>
+            </field>
+        </record>
+
+		<record id="action_mypospartner_tree_view" model="ir.actions.act_window">
+            <field name="name">Listado de clientes con monto</field>
+            <field name="res_model">my.partner.model</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+
+		<menuitem name="Listado de Cliente por Monto" id="menu_point_ofsalepart"
+            parent="point_of_sale.menu_point_root" sequence="25"/>
+
+		<menuitem name="Listado de Cliente por Monto" id="id_menu_registro_pospartner"
+            parent="menu_point_ofsalepart" action="action_mypospartner_tree_view" sequence="1"/>
+
+	</data>
+</openerp>

+ 21 - 0
pospartner_report.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+		<report id="my_report_pospartner"
+            model="my.partner.model"
+            string="Listado de Cliente x Monto"
+            report_type="qweb-pdf"
+            name="my_report_partner.report_posxpartner"
+            file="my_report_partner.report_posxpartner"
+        />
+
+
+    <report id="my_report_fecha"
+            model="my.partner.model"
+            string="Listado de Cliente por ultima fecha"
+            report_type="qweb-pdf"
+            name="my_report_partner.report_posxpartnerfecha"
+            file="my_report_partner.report_posxpartnerfecha"
+        />
+    </data>
+</openerp>

BIN
static/description/icon.png