analisis_salida.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 salida_analisis(osv.osv):
  27. _name = "salida.analisis"
  28. _description = "Analisis de Salida S/ pagos a personal"
  29. _auto = False
  30. _columns = {
  31. 'rnumber': fields.char('Referencia', readonly=True),
  32. 'name': fields.char('Descripcion', readonly=True),
  33. 'partner_id': fields.many2one('res.partner', 'Proveedor', readonly=True),
  34. 'amount_salida': fields.float('Total Salida', readonly=True),
  35. 'date_x': fields.datetime('Date Order', readonly=True),
  36. }
  37. _order = 'date_x desc'
  38. def init(self, cr):
  39. tools.sql.drop_view_if_exists(cr, 'salida_analisis')
  40. cr.execute("""
  41. CREATE OR REPLACE VIEW salida_analisis AS (
  42. SELECT l.id as id,
  43. l.number as rnumber,
  44. r.ref as name,
  45. l.partner_id as partner_id,
  46. l.amount AS amount_salida,
  47. l.create_date as date_x
  48. FROM account_move r
  49. left join account_voucher l on (r.id=l.move_id)
  50. WHERE l.state='posted' and l.type='payment'
  51. GROUP BY l.id,l.number, r.ref,l.partner_id, l.amount,l.create_date
  52. )
  53. """)
  54. salida_analisis()