Prechádzať zdrojové kódy

Modulo analisis_personal

sebas 8 rokov pred
commit
633d9d1121

+ 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 analisis_personal
+from . import report_personal
+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': 'Analisis de pago de personal',
+    'version': '0.1',
+    'category': 'Product',
+    'description': """
+Analisis de pago de personal
+====================================================
+
+Analisis de pago de personal
+- Cuenta con varios filtros y muestra los siguientes datos: fecha, personal, referencia, monto, fecha
+
+
+    """,
+    'author': 'Eiru/Sebastian Penayo',
+    'website': '',
+	'depends': ['account','hr', 'report'],
+    'data': [
+		'informe_analisis_personal_view.xml',
+        'analisispersonal_filter_view.xml',
+        'informe_personal_por_fecha.xml',
+    ],
+    'installable': True,
+}

+ 68 - 0
analisis_personal.py

@@ -0,0 +1,68 @@
+# -*- 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/>.
+#                                     r.employee_id as         'amount_salida': fields.float('Total Salida', readonly=True),
+#            GROUP BY p.id ,l.partner_id,l.journal_id,l.create_date,l.amount_total,s.total
+
+##############################################################################
+
+from openerp import tools
+from openerp.osv import fields, osv
+from openerp.tools.translate import _
+from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
+
+
+class personal_analisis(osv.osv):
+    _name = "personal.analisis"
+    _description = "Analisis de Pagos a Personal"
+    _auto = False
+
+    _columns = {
+        'slip_id': fields.many2one('hr.payslip', 'N° Nomina', readonly=True),
+        'rnumber': fields.char('Referencia', readonly=True),
+        'name': fields.char('Descripcion', readonly=True),
+        'employee_id': fields.many2one('hr.employee', 'Funcionario', readonly=True),
+        'amount_salida': fields.float('Total Salida', readonly=True),
+        'period_id': fields.many2one('account.period', 'Period', required=True),
+        'date_x': fields.datetime('Date Order', readonly=True),
+    }
+    _order = 'date_x desc'
+
+
+    def init(self, cr):
+            tools.sql.drop_view_if_exists(cr, 'personal_analisis')
+            cr.execute("""
+                CREATE OR REPLACE VIEW personal_analisis AS (
+                      SELECT row_number() over (ORDER BY s.id)as id,
+                           r.id as slip_id,
+                           r.number as rnumber,
+                           r.name as name,
+                           t.id as employee_id,
+                           s.total as amount_salida,
+                           r.period_id as period_id,
+                           r.create_date as date_x
+                    FROM hr_payslip_line s
+                    left join hr_payslip r on (r.id=s.slip_id)
+                         left join account_period z on (z.id=r.period_id)
+                    left join hr_employee t on (t.id=r.employee_id)
+                         left join account_journal p on (p.id=r.journal_id)
+                   where s.total>0 and r.journal_id=15 and s.code<>'BASIC' and s.code<>'GROSS' and r.state='paid'
+                   GROUP BY s.id,r.id,r.number,r.name,t.id,r.create_date,s.total,r.period_id
+                )
+             """)
+personal_analisis()

BIN
analisis_personal.pyc


+ 51 - 0
analisispersonal_filter_view.xml

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+    <!-- Custom reports (aka filters) -->
+
+   <record id="filter_analisis_personal_diario1" model="ir.filters">
+        <field name="name">Por Mes</field>
+        <field name="model_id">personal.analisis</field>
+        <field name="journal_id" eval="False"/>
+        <field name="context">{'group_by': ['date_x:month']}</field>
+    </record>
+
+    <record id="filter_analisis_personal_diario2" model="ir.filters">
+         <field name="name">Por Empleado</field>
+         <field name="model_id">personal.analisis</field>
+         <field name="journal_id" eval="False"/>
+         <field name="context">{'group_by': ['employee_id']}</field>
+     </record>
+
+     <record id="filter_analisis_peeriodo_diario2" model="ir.filters">
+          <field name="name">Por Periodo</field>
+          <field name="model_id">personal.analisis</field>
+          <field name="journal_id" eval="False"/>
+          <field name="context">{'group_by': ['period_id']}</field>
+      </record>
+
+    <record id="view_order_personal_search2" model="ir.ui.view">
+        <field name="name">personal.analisis.search</field>
+        <field name="model">personal.analisis</field>
+        <field name="arch" type="xml">
+            <search string="Analisis de Pago de Personal">
+              <filter string="Este año" name="year" domain="[('date_x','&lt;=', time.strftime('%%Y-12-31')),('date_x','&gt;=',time.strftime('%%Y-01-01'))]"/>
+              <filter string="Año pasado  " domain="[('date_x','&gt;=',(context_today()-relativedelta(years=1)).strftime('%%Y-01-01')),('date_x','&lt;=', time.strftime('%%Y-01-01'))]"/>
+              <filter string="Mes actual" domain="[('date_x','&lt;',(context_today()+relativedelta(months=1)).strftime('%%Y-%%m-01')), ('date_x','&gt;=',time.strftime('%%Y-%%m-01'))]"/>
+              <filter string="Mes pasado" domain="[('date_x','&gt;=',(context_today()-relativedelta(months=1)).strftime('%%Y-%%m-01')),('date_x','&lt;',time.strftime('%%Y-%%m-01'))]"/>
+              <filter string="Hoy" domain="[('date_x', '&gt;=', datetime.datetime.now().strftime('%Y-%m-%d 00:00:00')),('date_x', '&lt;=',datetime.datetime.now().strftime('%Y-%m-%d 23:23:59'))]"/>
+              <filter string=" Ayer " domain="[('date_x','&lt;=', (datetime.date.today()-relativedelta(days=1)).strftime('%%Y-%%m-%%d')),('date_x','&gt;=',(datetime.date.today()-relativedelta(days=1)).strftime('%%Y-%%m-%%d'))]"/>
+              <filter string="Semana anterior" domain="[('date_x', '&gt;=', ((context_today()+relativedelta(weeks=-2, days=1, weekday=0)).strftime('%%Y-%%m-%%d'))),('date_x', '&lt;=', ((context_today()+relativedelta(weeks=-1, weekday=6)).strftime('%%Y-%%m-%%d')))]"/>
+              <filter string="Esta semana" domain="[('date_x', '&gt;=', ((context_today()+relativedelta(weeks=-1, days=1, weekday=0)).strftime('%%Y-%%m-%%d'))),('date_x', '&lt;=', ((context_today()+relativedelta(weeks=0, weekday=6)).strftime('%%Y-%%m-%%d')))]"/>
+                <separator/>
+                <group expand="0" string="Filtros Extendidos">
+                    <filter string="Personal" context="{'group_by':'employee_id'}"/>
+                    <filter string="Mes" context="{'group_by':'date_x:month'}"/>
+                    <filter string="Fecha" context="{'group_by':'date_x:day'}"/>
+
+                </group>
+            </search>
+        </field>
+    </record>
+</data>
+</openerp>

+ 49 - 0
informe_analisis_personal_view.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="personal_analisis_tree_view" model="ir.ui.view">
+            <field name="name">personal.analisis.tree.view</field>
+            <field name="model">personal.analisis</field>
+            <field name="priority" eval="20"/>
+            <field name="arch" type="xml">
+            <tree string="Analisis de Pago de Personal" create="false">
+            <field name="id" invisible="1"/>
+            <field name="employee_id"/>
+            <field name="rnumber"/>
+            <field name="name"/>
+            <field name="amount_salida" sum="totalsal" string="Total Salida"/>
+            <field name="date_x" string="Fecha"/>
+            <field name="period_id"/>
+				</tree>
+            </field>
+        </record>
+
+        <record model="ir.ui.view" id="personal_analisis_form">
+                <field name="name">Detalles Nomina</field>
+                <field name="model">personal.analisis</field>
+                <field name="view_type">form</field>
+                <field eval="20" name="priority"/>
+                <field name="arch" type="xml">
+                    <form string="Detalles Nomina" create="false" edit="false">
+                        <group>
+                            <field name="date_x"/>
+                            <field name="employee_id"/>
+                            <field name="rnumber"/>
+                            <field name="slip_id"/>
+                        </group>
+                    </form>
+                </field>
+      </record>
+
+		<record id="action_personal_analisis_tree_view" model="ir.actions.act_window">
+            <field name="name">Analisis de Pago de Personal</field>
+            <field name="res_model">personal.analisis</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+
+
+    <menuitem id="personal_analisis_menu" name="Analisis de Pago de Personal" parent="hr.menu_hr_reporting" sequence="20" action="action_personal_analisis_tree_view"/>
+
+	</data>
+</openerp>

+ 92 - 0
informe_personal_por_fecha.xml

@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<report id="report_diariopersonal3"
+            model="personal.analisis"
+            string="Listado de Pago de Personal"
+            report_type="qweb-pdf"
+            name="analisis_personal.informe_personal_por_fecha"
+            file="analisis_personal.informe_personal_por_fecha"
+    />
+
+		<template id="informe_personal_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 Pago de Personal</h4>
+						<div class="logo1" />
+
+						  <table class="table table-condenced table-bordered">
+							<thead class="crm_tcab">
+								<tr class="active">
+									<th class="text-center">Personal</th>
+									<th class="text-center">Referencia</th>
+									<th class="text-center">Descripcion</th>
+									<th class="text-center">Salida</th>
+									<th class="text-center">Fecha</th>
+								</tr>
+							</thead>
+							<t t-foreach="docs" t-as="o">
+							<tbody>
+									<tr>
+										<td class="text-left">
+											<span t-esc="o.employee_id.name"/>
+										</td>
+										<td class="text-left">
+											<span t-esc="o.rnumber"/>
+										</td>
+										<td class="text-left">
+											<span t-esc="o.name"/>
+										</td>
+										<td class="text-right success">
+											<span t-esc="'{0:,.0f}'.format(round(float(o.amount_salida), 0))"/>
+										</td>
+										<td class="text-right">
+											<span t-field="o.date_x" t-field-options='{"widget": "date"}'/>
+										</td>
+									</tr>
+							</tbody>
+							</t>
+
+							    <tr>
+												 <td colspan="5"></td>
+														 </tr>
+														 <tr class="border-black">
+																 <td colspan="4">Total:</td>
+																 <td class="text-right danger">
+				 													<strong>
+				 														<t t-set="totalsal" t-value="sum([x.amount_salida for x in docs])"/>
+				 														<span t-esc="'{0:,.0f}'.format(round(float(totalsal), 0))"/>
+				 													</strong>
+				 												</td>
+								 </tr>
+						  </table>
+
+					</div>
+				</t>
+			</t>
+		</template>
+	</data>
+</openerp>

+ 55 - 0
report_personal.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_personal.pyc


BIN
static/description/icon.png