GoodERP
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.

55 lines
1.9KB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 上海开阖软件有限公司 (http://www.osbzr.com)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from odoo import _
  5. from odoo import models, fields, api
  6. from odoo import tools
  7. class ReportAuxiliaryAccounting(models.Model):
  8. _name = 'report.auxiliary.accounting'
  9. _auto = False
  10. _description = '辅助核算余额表'
  11. account_id = fields.Many2one('finance.account', '会计科目')
  12. auxiliary_id = fields.Many2one(
  13. 'auxiliary.financing', '辅助核算', ondelete='restrict')
  14. debit = fields.Float('借方金额', digits='Amount')
  15. credit = fields.Float('贷方金额', digits='Amount')
  16. balance = fields.Float('余额', digits='Amount')
  17. def view_voucher_line_detail(self):
  18. return {
  19. 'type': 'ir.actions.act_window',
  20. 'res_model': 'voucher.line',
  21. 'name': _("%s - %s 明细行") % (
  22. self.account_id.name, self.auxiliary_id.name),
  23. 'view_mode': 'list',
  24. 'domain': [
  25. ('account_id', '=', self.account_id.id),
  26. ('auxiliary_id', '=', self.auxiliary_id.id)],
  27. }
  28. def init(self):
  29. cr = self._cr
  30. tools.drop_view_if_exists(cr, 'report_auxiliary_accounting')
  31. cr.execute(
  32. """
  33. create or replace view report_auxiliary_accounting as (
  34. SELECT min(line.id) as id,
  35. line.account_id as account_id,
  36. line.auxiliary_id as auxiliary_id,
  37. sum(line.debit) as debit,
  38. sum(line.credit) as credit,
  39. sum(COALESCE(line.debit,0) - COALESCE(line.credit,0)) as balance
  40. FROM voucher_line line
  41. WHERE line.voucher_id is NOT NULL AND
  42. line.auxiliary_id IS NOT NULL and
  43. line.state = 'done' AND
  44. (line.debit !=0 OR
  45. line.credit !=0)
  46. GROUP BY line.account_id, line.auxiliary_id
  47. )
  48. """)
上海开阖软件有限公司 沪ICP备12045867号-1