# -*- coding: utf-8 -*- from openerp import api, models, fields class PurchaseOrder(models.Model): _inherit = 'purchase.order' from_pop = fields.Boolean(string='Created from POP', default=False) def action_purchase_confirm(self, cr, uid, ids, context=None): if not context: context = {} assert len(ids) == 1, 'This option should only be used for a single id at a time' self.signal_workflow(cr, uid, ids, 'purchase_confirm') return True @api.multi def purchase_process_now(self): """ Confirms order and creates and validates invoice, confirms pickings. """ for purchase in self: # Process order purchase.action_purchase_confirm() for picking in purchase.picking_ids: picking.force_assign() picking.action_done() @api.model def action_invoice_create(self): if self.from_pop: return 0 return super(PurchaseOrder, self).action_invoice_create(self.ids)