sale_fast_confirm.py~ 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # -*- encoding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Odoo, Open Source Management Solution
  5. #
  6. # Author: Andrius Laukavičius. Copyright: JSC NOD Baltic
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU Affero General Public License as
  10. # published by the Free Software Foundation, either version 3 of the
  11. # License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU Affero General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Affero General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. ##############################################################################
  22. from openerp import models, api
  23. class SaleOrder(models.Model):
  24. _inherit = 'sale.order'
  25. @api.multi
  26. def order_process_now(self):
  27. """
  28. Confirms order and creates and validates invoice, confirms pickings.
  29. """
  30. for sale in self:
  31. # Process order
  32. sale.action_button_confirm()
  33. inv_id = sale.action_invoice_create()
  34. if inv_id:
  35. inv = self.env['account.invoice'].browse(inv_id)
  36. # inv.signal_workflow('invoice_open')
  37. for picking in sale.picking_ids:
  38. picking.force_assign()
  39. picking.action_done()