# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # # 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 . # 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()