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.

39 lines
1.2KB

  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
  4. from odoo import fields
  5. class CommonDialogWizard(models.TransientModel):
  6. _name = 'common.dialog.wizard'
  7. _description = '警告窗口'
  8. message = fields.Text(
  9. string='消息',
  10. default=lambda self: self.env.context.get('message')
  11. )
  12. def do_confirm(self):
  13. '''' 用户点击确认按钮后执行对应的方法 '''
  14. active_model = self.env.context.get('active_model')
  15. active_ids = self.env.context.get('active_ids')
  16. if active_ids and active_model:
  17. model = self.env[active_model].browse(active_ids)
  18. func = getattr(model, self.env.context.get('func'), None)
  19. if not func:
  20. raise ValueError(
  21. '错误, 模型(%s)中找不到定义的函数%s' %
  22. (active_model, self.env.context.get('func'))
  23. )
  24. args = self.env.context.get('args') or []
  25. kwargs = self.env.context.get('kwargs') or {}
  26. return func(*args, **kwargs)
  27. else:
  28. raise ValueError('错误, 向导中找不到调用方信息')
上海开阖软件有限公司 沪ICP备12045867号-1