purchase_fast_confirm.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 PurchaseOrder(models.Model):
  24. _inherit = 'purchase.order'
  25. def action_purchase_confirm(self, cr, uid, ids, context=None):
  26. if not context:
  27. context = {}
  28. assert len(ids) == 1, 'This option should only be used for a single id at a time.'
  29. self.signal_workflow(cr, uid, ids, 'purchase_confirm')
  30. return True
  31. @api.multi
  32. def purchase_process_now(self):
  33. """
  34. Confirms order and creates and validates invoice, confirms pickings.
  35. """
  36. for purchase in self:
  37. # Process order
  38. purchase.action_purchase_confirm()
  39. for picking in purchase.picking_ids:
  40. picking.force_assign()
  41. picking.action_done()