purchase_order.py 824 B

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. from openerp import api, models
  3. class PurchaseOrder(models.Model):
  4. _inherit = 'purchase.order'
  5. '''
  6. '''
  7. def action_purchase_confirm(self, cr, uid, ids, context=None):
  8. if not context:
  9. context = {}
  10. assert len(ids) == 1, 'This option should only be used for a single id at a time'
  11. self.signal_workflow(cr, uid, ids, 'purchase_confirm')
  12. return True
  13. @api.multi
  14. def purchase_process_now(self):
  15. """
  16. Confirms order and creates and validates invoice, confirms pickings.
  17. """
  18. for purchase in self:
  19. # Process order
  20. purchase.action_purchase_confirm()
  21. for picking in purchase.picking_ids:
  22. picking.force_assign()
  23. picking.action_done()