You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2015 Eficent Business and IT Consulting Services S.L. -
  3. # Jordi Ballester Alomar
  4. # © 2015 Serpent Consulting Services Pvt. Ltd.
  5. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  6. from openerp import models, tools
  7. class AccountEntriesReport(models.Model):
  8. _inherit = "account.entries.report"
  9. def _select(self):
  10. select_str = """
  11. SELECT
  12. l.id as id,
  13. am.date as date,
  14. l.date_maturity as date_maturity,
  15. l.date_created as date_created,
  16. am.ref as ref,
  17. am.state as move_state,
  18. l.state as move_line_state,
  19. l.reconcile_id as reconcile_id,
  20. l.partner_id as partner_id,
  21. l.product_id as product_id,
  22. l.product_uom_id as product_uom_id,
  23. am.company_id as company_id,
  24. am.journal_id as journal_id,
  25. p.fiscalyear_id as fiscalyear_id,
  26. am.period_id as period_id,
  27. l.account_id as account_id,
  28. l.analytic_account_id as analytic_account_id,
  29. a.type as type,
  30. a.user_type as user_type,
  31. 1 as nbr,
  32. l.quantity as quantity,
  33. l.currency_id as currency_id,
  34. l.amount_currency as amount_currency,
  35. l.debit as debit,
  36. l.credit as credit,
  37. coalesce(l.debit, 0.0) - coalesce(l.credit, 0.0) as balance
  38. """
  39. return select_str
  40. def _from(self):
  41. from_str = """
  42. FROM
  43. account_move_line l
  44. left join account_account a on (l.account_id = a.id)
  45. left join account_move am on (am.id=l.move_id)
  46. left join account_period p on (am.period_id=p.id)
  47. """
  48. return from_str
  49. def _where(self):
  50. where_str = """
  51. where l.state != 'draft'
  52. """
  53. return where_str
  54. def _group_by(self):
  55. group_by_str = """
  56. """
  57. return group_by_str
  58. def init(self, cr):
  59. tools.drop_view_if_exists(cr, self._table)
  60. cr.execute("""CREATE or REPLACE VIEW %s as (
  61. %s
  62. %s
  63. %s
  64. %s
  65. )""" % (self._table, self._select(), self._from(), self._where(),
  66. self._group_by()))