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.

35 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2011 Raphaël Valyi, Renato Lima, Guewen Baconnier, Sodexis
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp import models, fields, api
  5. class SaleExceptionConfirm(models.TransientModel):
  6. _name = 'sale.exception.confirm'
  7. sale_id = fields.Many2one('sale.order', 'Sale')
  8. exception_ids = fields.Many2many('sale.exception',
  9. string='Exceptions to resolve',
  10. readonly=True)
  11. ignore = fields.Boolean('Ignore Exceptions')
  12. @api.model
  13. def default_get(self, field_list):
  14. res = super(SaleExceptionConfirm, self).default_get(field_list)
  15. order_obj = self.env['sale.order']
  16. sale_id = self._context.get('active_ids')
  17. assert len(sale_id) == 1, "Only 1 ID accepted, got %r" % sale_id
  18. sale_id = sale_id[0]
  19. sale = order_obj.browse(sale_id)
  20. exception_ids = [e.id for e in sale.exception_ids]
  21. res.update({'exception_ids': [(6, 0, exception_ids)]})
  22. res.update({'sale_id': sale_id})
  23. return res
  24. @api.one
  25. def action_confirm(self):
  26. if self.ignore:
  27. self.sale_id.ignore_exception = True
  28. return {'type': 'ir.actions.act_window_close'}