Преглед на файлове

Modulo report_analisiscabventa

sebas преди 8 години
ревизия
ae3476fa84

+ 30 - 0
__init__.py

@@ -0,0 +1,30 @@
+# -*- 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 #
+###################################################################################
+
+import report_cabventa
+import report
+import math

BIN
__init__.pyc


+ 54 - 0
__openerp__.py

@@ -0,0 +1,54 @@
+# -*- 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 ventas',
+    'version': '0.1',
+    'category': 'Product',
+    'description': """
+Listado de ventas
+========================================
+
+Listado de ventas
+- Por contabilidad
+- Por moneda
+- Por tipo
+- Por cliente
+- Por fecha
+
+    """,
+    'author': 'Eiru/Sebastian Penayo',
+    'website': '',
+	'depends': ['sale','report','base'],
+    'data': [
+		'informe_cab_venta_view.xml',
+		'report/informe_cabventa_view.xml',
+        'informe_cabventa_por_fecha.xml',
+		'cabventa_report.xml',
+		'cabventa_filter_view.xml',
+    ],
+    'installable': True,
+}

+ 75 - 0
cabventa_filter_view.xml

@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+
+  <!-- Custom reports (aka filters) -->
+  <record id="filter_report_gastos_funnel" model="ir.filters">
+      <field name="name">Cliente</field>
+      <field name="model_id">cabventa.report</field>
+      <field name="domain">[]</field>
+      <field name="user_id" eval="False"/>
+      <field name="context">{'group_by': ['partner_id']}</field>
+  </record>
+
+  <record id="filter_cabventa_salespersons1" model="ir.filters">
+      <field name="name">Por vendedores</field>
+      <field name="model_id">cabventa.report</field>
+      <field name="domain">[]</field>
+      <field name="user_id" eval="False"/>
+      <field name="context">{'group_by': ['date:month', 'user_id']}</field>
+  </record>
+  <record id="filter_cabventa_product1" model="ir.filters">
+      <field name="name">Por mes/cliente</field>
+      <field name="model_id">cabventa.report</field>
+      <field name="domain">[]</field>
+      <field name="user_id" eval="False"/>
+      <field name="context">{'group_by': ['date:month', 'partner_id']}</field>
+  </record>
+  <record id="filter_cab_venta" model="ir.filters">
+      <field name="name">Por Factura Venta</field>
+      <field name="model_id">cabventa.report</field>
+      <field name="domain">[]</field>
+      <field name="user_id" eval="False"/>
+      <field name="context">{'group_by': ['date:month']}</field>
+  </record>
+
+  <record id="view_account_cabventa_report_search1" model="ir.ui.view">
+      <field name="name">invoice.cabventa.report.search</field>
+      <field name="model">cabventa.report</field>
+      <field name="arch" type="xml">
+          <search string="Analisis de Ventas">
+              <field name="date"/>
+              <filter string="Este año" name="thisyear" domain="['|', ('date', '=', False), '&amp;',('date','&lt;=', time.strftime('%%Y-12-31')),('date','&gt;=',time.strftime('%%Y-01-01'))]" help="Journal invoices with period in current year"/>
+              <separator/>
+              <filter string="Para facturar" domain="[('state','=','draft')]" help = "Draft Invoices"/>
+              <filter string="Pro-forma" domain="['|', ('state','=','proforma'),('state','=','proforma2')]"/>
+              <filter string="Facturado" name="current" domain="[('state','not in', ('draft','cancel','proforma','proforma2'))]"/>
+              <filter string="Por Servicio de Internet" domain="[('origin', 'like', 'AA')]" help = "Internet"/>
+              <filter string="Servicio Tecnico/Ventas" domain="[('origin', 'not ilike', 'AA')]" help = "Servicio/Ventas"/>
+              <filter string="Este año" name="year" invisible="1" domain="[('date','&lt;=', time.strftime('%%Y-12-31')),('date','&gt;=',time.strftime('%%Y-01-01'))]"/>
+              <filter string=" Ayer " domain="[('date_order','&lt;=', (datetime.date.today()-relativedelta(days=1)).strftime('%%Y-%%m-%%d')),('date_order','&gt;=',(datetime.date.today()-relativedelta(days=1)).strftime('%%Y-%%m-%%d'))]"/>
+              <filter string="Hoy" domain="[('date', '&gt;=', datetime.datetime.now().strftime('%Y-%m-%d 00:00:00')),('date', '&lt;=',datetime.datetime.now().strftime('%Y-%m-%d 23:23:59'))]"/>
+              <filter string="Ultimos 15 dias atras" domain="[('date','&lt;=',time.strftime('%%d/%%m/%%Y')),('date','&gt;=',((context_today()-relativedelta(days=15)).strftime('%%d/%%m/%%Y')))]"/>
+              <filter string="Semana anterior" domain="[('date', '&gt;=', ((context_today()+relativedelta(weeks=-2, days=1, weekday=0)).strftime('%%Y-%%m-%%d'))),('date', '&lt;=', ((context_today()+relativedelta(weeks=-1, weekday=6)).strftime('%%Y-%%m-%%d')))]"/>
+              <filter string="Esta semana" domain="[('date', '&gt;=', ((context_today()+relativedelta(weeks=-1, days=1, weekday=0)).strftime('%%Y-%%m-%%d'))),('date', '&lt;=', ((context_today()+relativedelta(weeks=0, weekday=6)).strftime('%%Y-%%m-%%d')))]"/>
+              <separator/>
+              <field name="partner_id" operator="child_of"/>
+              <group expand="1" string="Agrupar por">
+                  <filter string="Cliente" name="partner_id" context="{'group_by':'partner_id'}"/>
+                  <filter string="Vendedor" name='user' context="{'group_by':'user_id'}"/>
+                  <filter string="Diario" name='journal_id' context="{'group_by':'journal_id'}"/>
+                  <filter string="Sucursal" name='warehouse_id' context="{'group_by':'warehouse_id'}"/>
+                  <filter string="Moneda" name='currency_id' context="{'group_by':'currency_id'}"/>
+                  <filter string="Estado" context="{'group_by':'state'}"/>
+                  <filter string="Compania" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
+                  <separator orientation="vertical" />
+                  <filter string="Mes de Factura" context="{'group_by':'date:month'}"/>
+                  <filter string="Por dia" context="{'group_by':'date:day'}"/>
+              </group>
+          </search>
+      </field>
+  </record>
+
+
+</data>
+</openerp>

+ 18 - 0
cabventa_report.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+		<!-- <report id="report_invoicegral5"
+            model="invoice.reportgral"
+            string="Listado de Gasto por producto"
+            report_type="qweb-pdf"
+            name="report_gralinvoice.report_invoicegral6"
+            file="report_gralinvoice.report_invoicegral6"
+        />-->
+
+
+
+		
+
+
+    </data>
+</openerp>

+ 77 - 0
informe_cab_venta_view.xml

@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<template id="report_cabgral6">
+			<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 Gastos</h4>
+						<div class="logo1" />
+
+						  <table class="table table-condensed">
+							<thead class="crm_tcab">
+								<tr class="active">
+									<th class="text-center">Producto</th>
+									<th class="text-right">Precio Unit.</th>
+									<th class="text-right">Cantidad</th>
+									<th class="text-right">Sub Total</th>
+								</tr>
+							</thead>
+							<t t-foreach="docs" t-as="o">
+							<tbody>
+									<tr>
+										<td>
+											<span t-field="o.product_id"/>
+										</td>
+										<td class="text-right">
+											<span t-esc="o.amount_total"/>
+										</td>
+										<td class="text-right">
+											<span t-field="o.product_qty"/>
+										</td>
+										<td class="text-right">
+											<span t-field="o.price_total"/>
+										</td>
+									</tr>
+							</tbody>
+							</t>
+							<tr>
+                            <td colspan="4"></td>
+                            </tr>
+                            <tr class="border-black">
+                                <td colspan="2">Total:</td>
+								                <td class="text-right">
+                                    <t t-set="total" t-value="sum([x.product_qty for x in docs])"/>
+                                    <span t-esc="total"/>
+                                </td>
+                            </tr>
+						  </table>
+
+					</div>
+				</t>
+			</t>
+		</template>
+	</data>
+</openerp>

+ 81 - 0
informe_cabventa_por_fecha.xml

@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<report id="report_cabventa3"
+            model="cabventa.report"
+            string="Listado de Ventas"
+            report_type="qweb-pdf"
+            name="report_analisiscabventa.informe_cabventa_por_fecha"
+            file="report_analisiscabventa.informe_cabventa_por_fecha"
+    />
+
+		<template id="informe_cabventa_por_fecha">
+			<t t-call="report.html_container">
+				<t t-call="report.external_layout">
+					<div class="page">
+						<div class="row">
+							<div class="col-xs-12 col-sm-12">
+								<div class="panel panel-info">
+									<div class="panel-heading text-center">
+						          <h4 class="text-center">Listado de Ventas</h4>
+								 </div>
+										<table class="table table-condenced table-bordered">
+
+							           <thead>
+								            <tr class="active">
+									              <th class="text-center">Fecha</th>
+									              <th class="text-center">Nro Venta</th>
+									              <th class="text-center">Cliente</th>
+									              <th class="text-center">Total Gs</th>
+																<th class="text-center">Total $</th>
+									              <th class="text-center">Moneda</th>
+									              <th class="text-center">Sucursal</th>
+								             </tr>
+							            </thead>
+													<tbody>
+							               <t t-foreach="docs" t-as="o">
+									                  <tr>
+										                  <td class="text-left">
+											                   <span t-field="o.date" t-field-options='{"widget": "date"}'/>
+									                  	</td>
+										                  <td class="text-left">
+											                   <span t-esc="o.origin"/>
+										                  </td>
+										                  <td class="text-left">
+											                   <span t-esc="o.partner_id.name"/>
+										                  </td>
+										                  <td class="text-right success">
+																				  <span t-esc="'{0:,.0f}'.format(round(float(o.amount_total), 0))"/>
+										                  </td>
+																			<td class="text-right success">
+																				  <span t-esc="'{0:,.2f}'.format(round(float(o.amount_totald), 0))"/>
+										                  </td>
+										                  <td class="text-center">
+											                    <span t-field="o.currency_id"/>
+										                  </td>
+										                  <td class="text-left">
+											                    <span t-field="o.section_id"/>
+										                  </td>
+									                </tr>
+														 </t>
+							            </tbody>
+						           </table>
+											 <div class="panel-footer text-right">
+		 										<strong>Total Gs. : <t t-set="tsaldo" t-value="sum([x.amount_total for x in docs])"/>
+		 										<span t-esc="'{0:,.0f}'.format(round(float(tsaldo), 0))"/>
+		 										</strong>
+		 									</div>
+											<div class="panel-footer text-right">
+											 <strong>Total $.: <t t-set="tsaldod" t-value="sum([x.amount_totald for x in docs])"/>
+											 <span t-esc="'{0:,.2f}'.format(round(float(tsaldod), 0))"/>
+											 </strong>
+										 </div>
+										</div>
+									</div>
+							  </div>
+							</div>
+					</t>
+				</t>
+		</template>
+	</data>
+</openerp>

+ 79 - 0
informe_cabventaxcli.xml

@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<report id="report_cabgral2"
+						model="cabventa.report"
+						string="Listado de Gasto por cliente"
+						report_type="qweb-pdf"
+						name="report_analisiscabventa.report_cabventaxcliente"
+						file="report_analisiscabventa.report_cabventaxcliente"
+		/>
+
+		<template id="report_cabventaxcliente">
+			<t t-call="report.html_container">
+				<t t-call="report.internal_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 Gastos</h4>
+						<div class="logo1" />
+
+						  <table class="table table-condensed">
+							<thead class="crm_tcab">
+								<tr class="active">
+									<th>Proveedor</th>
+									<th class="text-center">N° de Factura</th>
+									<th class="text-center">Cantidad</th>
+									<th class="text-center">Sub Total</th>
+									<th class="text-center">Fecha</th>
+								</tr>
+							</thead>
+							<t t-foreach="docs" t-as="o">
+							<tbody>
+									<tr>
+										<td>
+											<span t-field="o.partner_id.name"/>
+										</td>
+										<td class="text-left">
+											<span t-esc="o.supplier_invoice_number"/>
+										</td>
+										<td class="text-center">
+											<span t-field="o.product_qty"/>
+										</td>
+										<td class="text-right">
+											<span t-field="o.amount_total"/>
+										</td>
+										<td class="text-left">
+											<span t-field="o.date" t-field-options='{"widget": "date"}'/>
+										</td>
+									</tr>
+							</tbody>
+							</t>
+						  </table>
+
+					</div>
+				</t>
+			</t>
+		</template>
+	</data>
+</openerp>

+ 24 - 0
report/__init__.py

@@ -0,0 +1,24 @@
+# -*- 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/>.
+#
+##############################################################################
+
+import report_cabventa
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
report/__init__.pyc


+ 49 - 0
report/informe_cabventa_view.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+  <data>
+      <record id="report_cabventa_tree_view" model="ir.ui.view">
+          <field name="name">report.cabventa.tree.view</field>
+          <field name="model">cabventa.report</field>
+          <field name="priority" eval="20"/>
+          <field name="arch" type="xml">
+        <tree string="Listado de Ventas" create="false">
+        <field name="date"/>
+        <field name="sale_id" on_change="onchange_invoice_id(sale_id)"/>
+        <field name="origin"/>
+        <field name="partner_id"/>
+        <field name="user_id"/>
+        <field name="company_id" invisible="1" group="base.group_multi_company"/>
+        <field name="amount_total" sum="Total" string="Total Gs"/>
+        <field name="amount_totald" sum="Totald" string="Total $"/>
+        <field name="state"/>
+        </tree>
+          </field>
+      </record>
+
+      <record model="ir.ui.view" id="cabventa_analisis_form">
+              <field name="name">Listado de Ventas</field>
+              <field name="model">cabventa.report</field>
+              <field name="view_type">form</field>
+              <field eval="20" name="priority"/>
+              <field name="arch" type="xml">
+                  <form string="Listado de Ventas" create="false" edit="false">
+                      <group>
+                          <field name="date"/>
+                          <field name="partner_id"/>
+                          <field name="sale_id" on_change="onchange_invoice_id(sale_id)"/>
+                      </group>
+                  </form>
+              </field>
+    </record>
+
+  <record id="action_report_cabventa_tree_view" model="ir.actions.act_window">
+          <field name="name">Listado de Ventas</field>
+          <field name="res_model">cabventa.report</field>
+          <field name="view_type">form</field>
+          <field name="view_mode">tree,form</field>
+  </record>
+
+  <menuitem name="Listado de Ventas" action="action_report_cabventa_tree_view" id="menu_action_account_cab_report_all1" parent="base.next_id_64" sequence="18"/>
+
+  </data>
+</openerp>

+ 82 - 0
report/report_cabventa.py

@@ -0,0 +1,82 @@
+# -*- 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
+from datetime import datetime
+
+
+class cabventa_report(osv.osv):
+    _name = "cabventa.report"
+    _description = "Ventas - Informe"
+    _auto = False
+    _rec_name = 'date'
+
+    _columns = {
+        'sale_id': fields.many2one('sale.order', 'N° Venta', readonly=True),
+        'date': fields.datetime('Fecha', readonly=True),
+        'origin': fields.char('Referencia', readonly=True),
+        'partner_id': fields.many2one('res.partner', 'Cliente', readonly=True),
+        'amount_total': fields.float('Total Gs.', readonly=True),
+        'amount_totald': fields.float('Total $.', readonly=True),
+        'company_id': fields.many2one('res.company', 'Compañia', readonly=True),
+        'currency_id': fields.many2one('res.currency', 'Moneda',readonly=True),
+        'user_id': fields.many2one('res.users', 'Vendedor', readonly=True),
+        'state': fields.selection([
+            ('cancel', 'Cancelado'),
+            ('draft', 'Borrador'),
+            ('confirmed', 'Confirmado'),
+            ('exception', 'Excepcion'),
+            ('done', 'Realizado')], 'Estado', readonly=True),
+        'warehouse_id': fields.many2one('stock.warehouse', 'Sucursal'),
+        'section_id': fields.many2one('crm.case.section', 'Sales Team'),
+    }
+    _order = 'date desc'
+
+    def init(self, cr):
+            tools.drop_view_if_exists(cr, 'cabventa_report')
+            cr.execute("""
+                create or replace view cabventa_report as (
+    				SELECT row_number() over (ORDER BY so.id) as id,
+                        so.id as sale_id,
+    					so.date_order AS date,
+                        so.partner_id AS partner_id,
+                        so.origin AS origin,
+                        rc.id as currency_id,
+                        so.company_id,
+                        so.user_id,
+                        so.state,
+                        (case when so.amount_total>0 and rc.id=166 then so.amount_total else 0 end) as amount_total,
+                        (case when so.amount_total>0 and rc.id=3 then so.amount_total else 0 end) as amount_totald,
+                        so.warehouse_id as warehouse_id,
+                        so.section_id as section_id
+                    from sale_order so
+                    JOIN res_partner rp ON so.partner_id = rp.id
+                    LEFT JOIN product_pricelist pl ON pl.id = so.pricelist_id
+                         LEFT JOIN res_currency rc ON rc.id = pl.currency_id
+                    GROUP BY so.date_order ,so.id, so.origin,
+                        so.partner_id, so.warehouse_id,so.amount_total,
+                        so.user_id, so.company_id, so.state, rc.id,
+                        so.amount_total, so.section_id)
+                    """)
+
+
+    # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
report/report_cabventa.pyc


+ 12 - 0
report_cabventa.py

@@ -0,0 +1,12 @@
+#    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 datetime import datetime, timedelta
+import time
+from openerp.osv import fields, osv
+from openerp.tools.translate import _
+from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
+import openerp.addons.decimal_precision as dp
+from openerp import workflow

BIN
report_cabventa.pyc


BIN
report_facturaventa.pyc


BIN
static/description/icon.png