purchase_order.py 906 B

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