GoodERP
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

68 rindas
2.6KB

  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. class ProfitStatement(models.Model):
  5. """利润表模板
  6. 模板主要用来定义项目的 科目范围,
  7. 然后根据科目的范围得到科目范围内的科目 的利润
  8. """
  9. _name = "profit.statement"
  10. _order = "sequence,id"
  11. _description = '利润表模板'
  12. sequence = fields.Integer('序号')
  13. balance = fields.Char('项目', help='报表的行次的总一个名称')
  14. line_num = fields.Char('行次', help='生成报表的行次')
  15. cumulative_occurrence_balance = fields.Float('本年累计金额', help='本年利润金额')
  16. occurrence_balance_formula = fields.Text(
  17. '科目范围', help='设定本行的利润的科目范围,例如1001~1012999999 结束科目尽可能大一些方便以后扩展')
  18. current_occurrence_balance = fields.Float('本月金额', help='本月的利润的金额')
  19. company_id = fields.Many2one(
  20. 'res.company',
  21. string='公司',
  22. change_default=True,
  23. default=lambda self: self.env.company)
  24. class Dupont(models.Model):
  25. _name = 'dupont'
  26. _description = '企业财务指标'
  27. _rec_name = 'period_id'
  28. _order = 'period_id'
  29. period_id = fields.Many2one('finance.period', '期间', index=True)
  30. kpi = fields.Char('指标')
  31. val = fields.Float('值', digits='Amount')
  32. @api.model
  33. def fill(self, period_id):
  34. if self.search([('period_id', '=', period_id.id)]):
  35. return True
  36. ta = te = income = ni = roe = roa = em = 0.0
  37. for b in self.env['trial.balance'].search(
  38. [('period_id', '=', period_id.id)]):
  39. if b.subject_name_id.costs_types == 'assets':
  40. ta += b.ending_balance_debit - b.ending_balance_credit
  41. if b.subject_name_id.costs_types == 'equity':
  42. te += b.ending_balance_credit - b.ending_balance_debit
  43. if b.subject_name_id.costs_types == 'in':
  44. income += b.current_occurrence_credit
  45. if b.subject_name_id == self.env.user.company_id.profit_account:
  46. ni = b.current_occurrence_credit
  47. roe = te and ni / te * 100
  48. roa = ta and ni / ta * 100
  49. em = te and ta / te * 100
  50. res = {'资产': ta, '权益': te, '收入': income, '净利': ni,
  51. '权益净利率': roe, '资产净利率': roa, '权益乘数': em}
  52. for k in res:
  53. self.create({'period_id': period_id.id, 'kpi': k, 'val': res[k]})
上海开阖软件有限公司 沪ICP备12045867号-1