GoodERP
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

53 líneas
1.8KB

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