analisis_diariocta.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 diariocta_analisis(osv.osv):
  27. _name = "diariocta.analisis"
  28. _description = "Analisis de Entrada sobre Diario de Cuentas"
  29. _auto = False
  30. _columns = {
  31. 'invoice_id': fields.char('N°Ref Cobro', readonly=True),
  32. 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
  33. 'type': fields.char('Tipo', readonly=True),
  34. 'currency_id': fields.many2one('res.currency', 'Moneda', required=True,readonly=True),
  35. 'amount_entrada': fields.float('Total Entrada', readonly=True),
  36. 'date_x': fields.date('Date Order', readonly=True),
  37. }
  38. _order = 'date_x desc'
  39. def init(self, cr):
  40. tools.sql.drop_view_if_exists(cr, 'diariocta_analisis')
  41. cr.execute("""
  42. CREATE OR REPLACE VIEW diariocta_analisis AS (
  43. SELECT row_number() over (ORDER BY l.id)as id,
  44. r.name as invoice_id,
  45. l.partner_id as partner_id,
  46. l.type as type,
  47. l.payment_rate_currency_id as currency_id,
  48. l.amount AS amount_entrada,
  49. l.date as date_x
  50. FROM account_move r
  51. left join account_voucher l on (r.id=l.move_id)
  52. left join account_voucher_line p on (p.voucher_id=l.id)
  53. WHERE l.state='posted' and l.amount>0 and l.type='receipt'
  54. GROUP BY l.id,r.name,l.partner_id,l.type,l.payment_rate_currency_id ,l.amount,l.date
  55. )
  56. """)
  57. diariocta_analisis()