analisis_personal.py 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. # r.employee_id as 'amount_salida': fields.float('Total Salida', readonly=True),
  20. # GROUP BY p.id ,l.partner_id,l.journal_id,l.create_date,l.amount_total,s.total
  21. ##############################################################################
  22. from openerp import tools
  23. from openerp.osv import fields, osv
  24. from openerp.tools.translate import _
  25. from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
  26. class personal_analisis(osv.osv):
  27. _name = "personal.analisis"
  28. _description = "Analisis de Pagos a Personal"
  29. _auto = False
  30. _columns = {
  31. 'slip_id': fields.many2one('hr.payslip', 'N° Nomina', readonly=True),
  32. 'rnumber': fields.char('Referencia', readonly=True),
  33. 'name': fields.char('Descripcion', readonly=True),
  34. 'employee_id': fields.many2one('hr.employee', 'Funcionario', readonly=True),
  35. 'amount_salida': fields.float('Total Salida', readonly=True),
  36. 'period_id': fields.many2one('account.period', 'Period', required=True),
  37. 'date_x': fields.datetime('Date Order', readonly=True),
  38. }
  39. _order = 'date_x desc'
  40. def init(self, cr):
  41. tools.sql.drop_view_if_exists(cr, 'personal_analisis')
  42. cr.execute("""
  43. CREATE OR REPLACE VIEW personal_analisis AS (
  44. SELECT row_number() over (ORDER BY s.id)as id,
  45. r.id as slip_id,
  46. r.number as rnumber,
  47. r.name as name,
  48. t.id as employee_id,
  49. s.total as amount_salida,
  50. r.period_id as period_id,
  51. r.create_date as date_x
  52. FROM hr_payslip_line s
  53. left join hr_payslip r on (r.id=s.slip_id)
  54. left join account_period z on (z.id=r.period_id)
  55. left join hr_employee t on (t.id=r.employee_id)
  56. left join account_journal p on (p.id=r.journal_id)
  57. where s.total>0 and r.journal_id=15 and s.code<>'BASIC' and s.code<>'GROSS' and r.state='paid'
  58. GROUP BY s.id,r.id,r.number,r.name,t.id,r.create_date,s.total,r.period_id
  59. )
  60. """)
  61. personal_analisis()