GoodERP
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

69 linhas
2.5KB

  1. from odoo.exceptions import UserError
  2. from odoo import fields, models, api
  3. MONEY_TYPE = [
  4. ('pay', u'采购'),
  5. ('get', u'销售'),
  6. ('other_pay', u'其他支出'),
  7. ('other_get', u'其他收入'),
  8. ]
  9. class MoneyGetPayWizard(models.Model):
  10. _name = "money.get.pay.wizard"
  11. _description = u"资金收支报表向导"
  12. @api.model
  13. def _get_company_start_date(self):
  14. return self._get_company_start_date_impl()
  15. @api.model
  16. def _get_company_start_date_impl(self):
  17. ''' 获取当前登录用户公司的启用日期 '''
  18. return self.env.user.company_id.start_date
  19. type = fields.Selection(MONEY_TYPE,
  20. string=u'类别',
  21. help=u'按类型筛选')
  22. date_start = fields.Date(string=u'开始日期',
  23. required=True,
  24. default=_get_company_start_date,
  25. help=u'查看本次报表的开始日期') # 默认公司启用日期
  26. date_end = fields.Date(string=u'结束日期',
  27. required=True,
  28. default=lambda self: fields.Date.context_today(
  29. self),
  30. help=u'查看本次报表的结束日期') # 默认当前日期
  31. company_id = fields.Many2one(
  32. 'res.company',
  33. string=u'公司',
  34. change_default=True,
  35. default=lambda self: self.env.company)
  36. def button_confirm(self):
  37. """资金收支报表"""
  38. if self.date_start > self.date_end:
  39. raise UserError(u'结束日期不能小于开始日期\n开始日期:%s 结束日期:%s ' %
  40. (self.date_start, self.date_end))
  41. view = self.env.ref('money.money_get_pay_report_list')
  42. domain = [('date', '>=', self.date_start),
  43. ('date', '<=', self.date_end)]
  44. if self.type:
  45. domain.append(('type', '=', self.type))
  46. return {
  47. 'name': u'资金收支报表',
  48. 'view_mode': 'list',
  49. 'res_model': 'money.get.pay.report',
  50. 'view_id': False,
  51. 'views': [(view.id, 'list')],
  52. 'limit': 65535,
  53. 'type': 'ir.actions.act_window',
  54. 'target': 'main',
  55. 'domain': domain,
  56. 'context': {'search_default_group_date': 1,
  57. 'search_default_group_partner': 1,
  58. 'search_default_group_category_id': 1}
  59. }
上海开阖软件有限公司 沪ICP备12045867号-1