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.

36 lines
1.4 KiB

7 years ago
7 years ago
  1. # Copyright 2011 Raphaël Valyi, Renato Lima, Guewen Baconnier, Sodexis
  2. # Copyright 2017 Akretion (http://www.akretion.com)
  3. # Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
  4. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  5. from odoo import api, fields, models
  6. class ExceptionRuleConfirm(models.AbstractModel):
  7. _name = 'exception.rule.confirm'
  8. related_model_id = fields.Many2one('base.exception',)
  9. exception_ids = fields.Many2many('exception.rule',
  10. string='Exceptions to resolve',
  11. readonly=True)
  12. ignore = fields.Boolean('Ignore Exceptions')
  13. @api.model
  14. def default_get(self, field_list):
  15. res = super(ExceptionRuleConfirm, self).default_get(field_list)
  16. current_model = self._context.get('active_model')
  17. model_except_obj = self.env[current_model]
  18. active_ids = self._context.get('active_ids')
  19. assert len(active_ids) == 1, "Only 1 ID accepted, got %r" % active_ids
  20. active_id = active_ids[0]
  21. related_model_except = model_except_obj.browse(active_id)
  22. exception_ids = [e.id for e in related_model_except.exception_ids]
  23. res.update({'exception_ids': [(6, 0, exception_ids)]})
  24. res.update({'related_model_id': active_id})
  25. return res
  26. @api.multi
  27. def action_confirm(self):
  28. self.ensure_one()
  29. return {'type': 'ir.actions.act_window_close'}