crm_make_sale.py 824 B

12345678910111213141516171819202122
  1. # -*- coding: utf-8 -*-
  2. # © 2016 Akretion (http://www.akretion.com)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. # @author Alexis de Lattre <alexis.delattre@akretion.com>
  5. from openerp import models, api
  6. class CrmMakeSale(models.TransientModel):
  7. _inherit = 'crm.make.sale'
  8. @api.multi
  9. def makeOrder(self):
  10. # the button to start this wizard is only available in form view
  11. # This code should be updated when we will have a _prepare method
  12. # in the create of the sale order
  13. self.ensure_one()
  14. value = super(CrmMakeSale, self).makeOrder()
  15. if value.get('res_model') == 'sale.order' and value.get('res_id'):
  16. so = self.env['sale.order'].browse(value['res_id'])
  17. so.lead_id = self._context.get('active_id')
  18. return value