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.

41 líneas
1.3KB

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