purchase_order.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. def action_purchase_confirm(self, cr, uid, ids, context=None):
  7. if not context:
  8. context = {}
  9. assert len(ids) == 1, 'This option should only be used for a single id at a time'
  10. self.signal_workflow(cr, uid, ids, 'purchase_confirm')
  11. return True
  12. @api.multi
  13. def purchase_process_now(self):
  14. """
  15. Confirms order and creates and validates invoice, confirms pickings.
  16. """
  17. for purchase in self:
  18. # Process order
  19. purchase.action_purchase_confirm()
  20. for picking in purchase.picking_ids:
  21. picking.force_assign()
  22. picking.action_done()
  23. @api.model
  24. def action_invoice_create(self):
  25. if self.from_pop:
  26. return 0
  27. return super(PurchaseOrder, self).action_invoice_create(self.ids)