Selaa lähdekoodia

Modulo report_gralpos1

sebas 8 vuotta sitten
commit
510a093e44

+ 29 - 0
__init__.py

@@ -0,0 +1,29 @@
+# -*- 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 report_gralpos
+from . 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 General de Punto de Venta con product brand',
+    'version': '0.1',
+    'category': 'Product',
+    'description': """
+Listado General de Punto de Venta
+========================================
+
+Genera varios listados de Punto de Venta con product_brand
+- Por productos
+- Por clientes
+- Por fecha
+
+    """,
+    'author': 'Eiru/Sebastian Penayo',
+    'website': '',
+	'depends': ['point_of_sale','sales_team','account_voucher', 'procurement','report','product_brand'],
+    'data': [
+        'informe_pos_general_view.xml',
+		'report/informe_posgral_view.xml',
+		'informe_pos_por_fecha.xml',
+		'informe_pos_por_categoria.xml',
+		'informe_posgralxcliente.xml',
+		'posgral_filter_view.xml',
+		'posgral_report.xml',
+    ],
+    'installable': True,
+}

+ 87 - 0
informe_pos_general_view.xml

@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+
+		<template id="report_posgralxproduct">
+			<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 Pos por producto</h4>
+						<div class="logo1" />
+
+						  <table class="table table-condensed">
+							<thead class="crm_tcab">
+								<tr class="active">
+									<th class="text-left">Producto</th>
+									<th class="text-right">Precio Unit.</th>
+									<th class="text-right">Cantidad</th>
+									<th class="text-right">Sub Total</th>
+									<th class="text-right">Fecha</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-right">
+											<span t-esc="o.price_unit"/>
+										</td>
+										<td class="text-right">
+											<span t-field="o.product_qty"/>
+										</td>
+										<td class="text-right">
+											<span t-field="o.price_total"/>
+										</td>
+										<td class="text-right">
+											<span t-field="o.date"/>
+										</td>
+									</tr>
+							</tbody>
+							</t>
+							<tr>
+                                <td colspan="5"></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>
+
+																<td class="text-right">
+								                                    <t t-set="total1" t-value="sum([r.price_total for r in docs])"/>
+								                                    <span t-esc="total1"/>
+								                </td>
+                            </tr>
+						  </table>
+
+					</div>
+				</t>
+			</t>
+		</template>
+	</data>
+</openerp>

+ 82 - 0
informe_pos_por_categoria.xml

@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<template id="informe_pos_por_categoria">
+			<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 Pos por categoria</h4>
+						<div class="logo1" />
+
+						  <table class="table table-condensed">
+
+							<thead class="crm_tcab">
+								<tr class="active">
+									<th>Producto</th>
+									<th class="text-left">Categoria</th>
+									<th class="text-center">Cantidad</th>
+									<th class="text-right">Sub Total</th>
+								</tr>
+							</thead>
+							<t t-foreach="docs" t-as="o">
+							<tbody>
+									<tr>
+										<td class="text-left">
+											<span t-esc="o.product_id.name"/>
+										</td>
+										<td class="text-left">
+											<span t-field="o.product_categ_id"/>
+										</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>
+																<td class="text-right">
+																<t t-set="total1" t-value="sum([r.product_qty for r in docs])"/>
+																<span t-esc="total1"/>
+																</td>
+                            </tr>
+						  </table>
+
+					</div>
+				</t>
+			</t>
+		</template>
+	</data>
+</openerp>

+ 88 - 0
informe_pos_por_fecha.xml

@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<template id="informe_pos_por_fecha">
+			<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 Pos por fecha</h4>
+						<div class="logo1" />
+
+						  <table class="table table-condensed">
+							<thead class="crm_tcab">
+								<tr class="active">
+									<th>Fecha</th>
+									<th class="text-left">Cliente</th>
+									<th>Producto</th>
+									<th class="text-center">Cantidad</th>
+									<th class="text-right">Sub Total</th>
+								</tr>
+							</thead>
+							<t t-foreach="docs" t-as="o">
+							<tbody>
+									<tr>
+										<td class="text-left">
+											<span t-field="o.date" t-field-options='{"widget": "date"}'/>
+										</td>
+										<td class="text-left">
+											<span t-esc="o.partner_id.name"/>
+										</td>
+										<td class="text-left">
+											<span t-esc="o.product_id.name"/>
+										</td>
+										<td class="text-center">
+											<span t-field="o.product_qty" sum="# of Qty"/>
+										</td>
+										<td class="text-right">
+											<span t-field="o.price_total"/>
+										</td>
+
+									</tr>
+							</tbody>
+							</t>
+
+							      <tr>
+                                <td colspan="5"></td>
+                            </tr>
+                            <tr class="border-black">
+                                <td colspan="3">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>
+
+																<td class="text-right">
+								                                    <t t-set="total1" t-value="sum([r.price_total for r in docs])"/>
+								                                    <span t-esc="total1"/>
+								                </td>
+                            </tr>
+						  </table>
+
+					</div>
+				</t>
+			</t>
+		</template>
+	</data>
+</openerp>

+ 75 - 0
informe_posgralxcliente.xml

@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<template id="report_posgralxcliente">
+			<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 Pos por cliente</h4>
+						<div class="logo1" />
+
+						  <table class="table table-condensed">
+							<thead class="crm_tcab">
+								<tr class="active">
+									<th>Cliente</th>
+									<th class="text-center">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.partner_id"/>
+										</td>
+										<td class="text-center">
+											<span t-field="o.product_qty"/>
+										</td>
+										<td class="text-right">
+											<span t-field="o.price_total"/>
+										</td>
+									</tr>
+							</tbody>
+							</t>
+
+							   <tr>
+										 <td colspan="3"></td>
+								 </tr>
+								 <tr class="border-black">
+										 <td colspan="1">Total:</td>
+										 <td class="text-right">
+												 <t t-set="total" t-value="sum([x.product_uom_qty for x in docs])"/>
+												 <span t-esc="total"/>
+										 </td>
+								 </tr>
+
+						  </table>
+
+					</div>
+				</t>
+			</t>
+		</template>
+	</data>
+</openerp>

+ 129 - 0
posgral_filter_view.xml

@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+
+    <!-- <record id="view_order_product_graph1" model="ir.ui.view">
+         <field name="name">sale.report.graph1</field>
+         <field name="model">sale.reportgral</field>
+         <field name="arch" type="xml">
+             <graph string="Sales Analysis1" type="pivot" stacked="True">
+                 <field name="section_id" type="row"/>
+                 <field name="date" interval="month" type="col"/>
+                 <field name="price_total" type="measure"/>
+             </graph>
+         </field>
+    </record>  -->
+
+    <!-- Custom reports (aka filters) -->
+    <record id="filter_pos_report_sales_funnel1" model="ir.filters">
+        <field name="name">Analisis Pos</field>
+        <field name="model_id">pos.reportgral</field>
+        <field name="domain">['&amp;', ('date','&lt;=', time.strftime('%%Y-12-31')), '&amp;', ('date','&gt;=',time.strftime('%%Y-01-01')), '|', ('state','in',('draft','sent')), ('state','not in',('draft','sent','cancel'))]</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by': ['state'], 'measures': ['price_total']}</field>
+    </record>
+    <record id="filter_pos_report_salespersons1" model="ir.filters">
+        <field name="name">Por Vendedor</field>
+        <field name="model_id">pos.reportgral</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by':['date:month','user_id']}</field>
+    </record>
+
+    <record id="filter_pos_report_mescategmarcacli" model="ir.filters">
+          <field name="name">Por Mes/Categoria/Marca/Cliente</field>
+          <field name="model_id">pos.reportgral</field>
+          <field name="user_id" eval="False"/>
+          <field name="context">{'group_by': ['date:month','product_categ_id','product_brand_id','partner_id']}</field>
+    </record>
+
+    <record id="filter_pos_report_categmes" model="ir.filters">
+        <field name="name">Por Mes/Categoria</field>
+        <field name="model_id">pos.reportgral</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by': ['date:month','product_categ_id']}</field>
+    </record>
+
+    <record id="filter_pos_report_salesteam1" model="ir.filters">
+        <field name="name">Por Categoria</field>
+        <field name="model_id">pos.reportgral</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by': ['product_categ_id']}</field>
+    </record>
+	<record id="filter_pos_report_brand1" model="ir.filters">
+        <field name="name">Por Marca</field>
+        <field name="model_id">pos.reportgral</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by': ['product_brand_id']}</field>
+    </record>
+	<record id="filter_pos_report_brand2" model="ir.filters">
+        <field name="name">Por Mes/Marca</field>
+        <field name="model_id">pos.reportgral</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by': ['date:month','product_brand_id']}</field>
+    </record>
+
+    <record id="filter_pos_report_mescategcli" model="ir.filters">
+          <field name="name">Por Mes/Categoria/Cliente</field>
+          <field name="model_id">pos.reportgral</field>
+          <field name="user_id" eval="False"/>
+          <field name="context">{'group_by': ['date:month','product_categ_id','partner_id']}</field>
+    </record>
+
+	  <record id="filter_pos_report_product1" model="ir.filters">
+        <field name="name">Por Producto</field>
+        <field name="model_id">pos.reportgral</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by': ['product_id']}</field>
+    </record>
+    <record id="filter_pos_report_product2" model="ir.filters">
+        <field name="name">Por Mes/Producto</field>
+        <field name="model_id">pos.reportgral</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by': ['date:month','product_id']}</field>
+    </record>
+	<record id="filter_pos_report_partner1" model="ir.filters">
+        <field name="name">Por Mes/Cliente</field>
+        <field name="model_id">pos.reportgral</field>
+        <field name="user_id" eval="False"/>
+        <field name="context">{'group_by':['date:month','partner_id']}</field>
+    </record>
+
+    <record id="view_order_product_search1" model="ir.ui.view">
+        <field name="name">pos.reportgral.search</field>
+        <field name="model">pos.reportgral</field>
+        <field name="arch" type="xml">
+            <search string="Analisis Pos">
+
+                <filter name="Presupuestos" domain="[('state','in',('draft','sent'))]"/>
+                <filter name="Pos" string="Pos" domain="[('state','not in',('draft','sent','cancel'))]"/>
+                <separator/>
+                <filter string="Mis Pos" help="Mis Pos" domain="[('user_id','=',uid)]"/>
+                <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="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="Ayer" domain="[('date','&lt;=', (datetime.date.today()-relativedelta(days=1)).strftime('%%Y-%%m-%%d')),('date','&gt;=',(datetime.date.today()-relativedelta(days=1)).strftime('%%Y-%%m-%%d'))]"/>
+                <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')))]"/>
+                <group expand="0" string="Filtros Extendidos">
+                    <field name="partner_id" domain="[('partner_id','=',self)]"/>
+                    <field name="product_categ_id"/>
+                    <field name="company_id" groups="base.group_multi_company"/>
+                </group>
+                <group expand="1" string="Agrupados por">
+                    <filter string="Vendedor" name="User" context="{'group_by':'user_id'}"/>
+                    <filter string="Clientes" name="Customer" context="{'group_by':'partner_id'}"/>
+                    <filter string="Ciudad" name="Ciudad" context="{'group_by':'city_id'}"/>
+                    <filter string="Producto" name="Producto" context="{'group_by':'product_id'}"/>
+                    <filter string="Categoria de Productos" name="Category" context="{'group_by':'product_categ_id'}"/>
+                    <filter string="Estado" context="{'group_by':'state'}"/>
+                    <filter string="Genero" name="Genero" context="{'group_by':'product_genre_id'}"/>
+                    <filter string="Compania" groups="base.group_multi_company" context="{'group_by':'company_id'}"/>
+                    <separator/>
+                    <filter string="Por mes" context="{'group_by':'date:month'}" help="Ordenado por mes de las ordenes de ventas"/>
+                    <filter string="Por fecha" context="{'group_by':'date:day'}"/>
+                </group>
+            </search>
+        </field>
+    </record>
+
+</data>
+</openerp>

+ 37 - 0
posgral_report.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+      <report id="report_posgral5"
+              model="pos.reportgral"
+              string="Listado de Pos por producto"
+              report_type="qweb-pdf"
+              name="report_gralpos1.report_posgralxproduct"
+              file="report_gralpos1.report_posgralxproduct"
+      />
+
+		<report id="report_posgral2"
+            model="pos.reportgral"
+            string="Listado de Pos por cliente"
+            report_type="qweb-pdf"
+            name="report_gralpos1.report_posgralxcliente"
+            file="report_gralpos1.report_posgralxcliente"
+        />
+
+		<report id="report_posgral3"
+            model="pos.reportgral"
+            string="Listado de Pos por fecha"
+            report_type="qweb-pdf"
+            name="report_gralpos1.informe_pos_por_fecha"
+            file="report_gralpos1.informe_pos_por_fecha"
+        />
+
+		<report id="report_posgral4"
+            model="pos.reportgral"
+            string="Listado de Pos por categoria"
+            report_type="qweb-pdf"
+            name="report_gralpos1.informe_pos_por_categoria"
+            file="report_gralpos1.informe_pos_por_categoria"
+        />
+    </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_posgral
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
report/__init__.pyc


+ 35 - 0
report/informe_posgral_view.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="report_posgral_tree_view" model="ir.ui.view">
+            <field name="name">report.posgral.tree.view</field>
+            <field name="model">pos.reportgral</field>
+            <field name="priority" eval="20"/>
+            <field name="arch" type="xml">
+                <tree string="Listado General de Punto de Ventas" create="false">
+					<field name="id" invisible="1"/>
+					<field name="date"/>
+					<field name="user_id" invisible="1"/>
+					<field name="company_id" invisible="1" group="base.group_multi_company"/>
+					<field name="partner_id" invisible="1"/>
+					<field name="product_id" string="Producto"/>
+					<field name="product_categ_id" invisible="1"/>
+					<field name="nbr" sum="# of Lines"/>
+					<field name="product_qty" sum="# of Qty" string="Cantidad"/>
+					<field name="price_total" sum="Total" string="Total"/>
+					<field name="state" invisible="1"/>
+          
+				</tree>
+            </field>
+        </record>
+
+		<record id="action_report_posgral_tree_view" model="ir.actions.act_window">
+            <field name="name">Listado General de Punto de Ventas</field>
+            <field name="res_model">pos.reportgral</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree</field>
+        </record>
+
+        <menuitem action="action_report_posgral_tree_view" id="menu_point_of_sale2" parent="point_of_sale.menu_point_rep" sequence="6" />
+	</data>
+</openerp>

+ 95 - 0
report/report_posgral.py

@@ -0,0 +1,95 @@
+# -*- 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 pos_reportgral(osv.osv):
+    _name = "pos.reportgral"
+    _description = "Listado General de Punto de Ventas"
+    _auto = False
+    _rec_name = 'date'
+
+    _columns = {
+        'date': fields.datetime('Date Order', readonly=True),
+		'partner_id':fields.many2one('res.partner', 'Partner', readonly=True),
+        'city_id': fields.many2one('res.country.state', 'City', readonly=True),
+        'city': fields.char('Ciudad', readonly=True),
+		'product_id':fields.many2one('product.product', 'Product', readonly=True),
+		'product_brand_id':fields.many2one('product.brand', 'Brand', readonly=True),
+		'state': fields.selection([('draft', 'New'), ('paid', 'Closed'), ('done', 'Synchronized'), ('invoiced', 'Invoiced'), ('cancel', 'Cancelled')],
+                                  'Status'),
+        'user_id':fields.many2one('res.users', 'Salesperson', readonly=True),
+        'price_unit':fields.float('Total Unit.', readonly=True),
+        'price_total':fields.float('Total Price', readonly=True),
+        'total_discount':fields.float('Total Discount', readonly=True),
+        'average_price': fields.float('Average Price', readonly=True,group_operator="avg"),
+        'location_id':fields.many2one('stock.location', 'Location', readonly=True),
+        'company_id':fields.many2one('res.company', 'Company', readonly=True),
+        'nbr':fields.integer('# of Lines', readonly=True),  # TDE FIXME master: rename into nbr_lines
+        'product_qty':fields.integer('Product Quantity', readonly=True),
+        'journal_id': fields.many2one('account.journal', 'Journal'),
+        'delay_validation': fields.integer('Delay Validation'),
+        'origen': fields.many2one('product.attribute.value' ,string='Origen', readonly=True),
+        'product_categ_id': fields.many2one('product.category', 'Product Category', readonly=True),
+    }
+    _order = 'date desc'
+
+    def init(self, cr):
+        tools.drop_view_if_exists(cr, 'pos_reportgral')
+        cr.execute("""
+            create or replace view pos_reportgral as (
+                select
+					min(l.id) as id,
+					count(*) as nbr,
+					s.date_order as date,
+                    l.price_unit as price_unit,
+					sum(l.qty * u.factor) as product_qty,
+					sum(l.qty * l.price_unit) as price_total,
+					sum((l.qty * l.price_unit) * (l.discount / 100)) as total_discount,
+					(sum(l.qty*l.price_unit)/sum(l.qty * u.factor))::decimal as average_price,
+					sum(cast(to_char(date_trunc('day',s.date_order) - date_trunc('day',s.create_date),'DD') as int)) as delay_validation,
+					s.partner_id as partner_id,
+					s.state as state,
+                    q.id as city_id,
+                    h.name as city,
+					s.user_id as user_id,
+					s.location_id as location_id,
+					s.company_id as company_id,
+					s.sale_journal as journal_id,
+					l.product_id as product_id,
+					pt.product_brand_id as product_brand_id,
+					pt.categ_id as product_categ_id
+                from pos_order_line as l
+					left join pos_order s on (s.id=l.order_id)
+					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_uom u on (u.id=pt.uom_id)
+                    left join res_partner q on (q.id=s.partner_id)
+                        left join res_country_state h on (h.id=q.state_id)
+                group by
+                    s.date_order,q.id,h.name,s.partner_id,s.state,q.city,l.price_unit, pt.categ_id, pt.product_brand_id,
+                    s.user_id,s.location_id,s.company_id,s.sale_journal,l.product_id,s.create_date
+                having
+                    sum(l.qty * u.factor) != 0)""")
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
report/report_posgral.pyc


+ 55 - 0
report_gralpos.py

@@ -0,0 +1,55 @@
+#    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
+
+# class product_product(osv.Model):
+    # _inherit = 'product.product'
+
+    # def _sales_count(self, cr, uid, ids, field_name, arg, context=None):
+        # SaleOrderLine = self.pool['sale.order.line']
+        # return {
+            # product_id: SaleOrderLine.search_count(cr,uid, [('product_id', '=', product_id)], context=context)
+            # for product_id in ids
+        # }
+
+    # _columns = {
+        # 'sales_count': fields.function(_sales_count, string='# Sales', type='integer'),
+
+    # }
+
+# class product_template(osv.Model):
+    # _inherit = 'product.template'
+
+    # def _sales_count(self, cr, uid, ids, field_name, arg, context=None):
+        # res = dict.fromkeys(ids, 0)
+        # for template in self.browse(cr, uid, ids, context=context):
+            # res[template.id] = sum([p.sales_count for p in template.product_variant_ids])
+        # return res
+    
+    # def action_view_sales(self, cr, uid, ids, context=None):
+        # act_obj = self.pool.get('ir.actions.act_window')
+        # mod_obj = self.pool.get('ir.model.data')
+        # product_ids = []
+        # for template in self.browse(cr, uid, ids, context=context):
+            # product_ids += [x.id for x in template.product_variant_ids]
+        # result = mod_obj.xmlid_to_res_id(cr, uid, 'sale.action_order_line_product_tree',raise_if_not_found=True)
+        # result = act_obj.read(cr, uid, [result], context=context)[0]
+        # result['domain'] = "[('product_id','in',[" + ','.join(map(str, product_ids)) + "])]"
+        # return result
+    
+    
+    # _columns = {
+        # 'sales_count': fields.function(_sales_count, string='# Sales', type='integer'),
+
+    # }
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
report_gralpos.pyc


BIN
static/description/icon.png