Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free! Click here to download the new Pastebin App for iOS.
Guest

out_of_stock patch

By: a guest on Jul 28th, 2010  |  syntax: Python  |  size: 0.98 KB  |  hits: 79  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. class sale_order_line(osv.osv):
  2.     _inherit = 'sale.order.line'
  3.  
  4.     def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
  5.             uom=False, qty_uos=0, uos=False, name='', partner_id=False,
  6.             lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False):
  7.         result = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty,
  8.             uom, qty_uos, uos, name, partner_id,
  9.             lang, update_tax, date_order, packaging, fiscal_position, flag)
  10.         if product and self.pool.get('product.product').browse(cr, uid, product, {}).virtual_available < 1:
  11.             if result['warning'] and result['warning']['message']:
  12.                 result['warning']['message'] += "\n\n" + _('Not available in stock!')
  13.             else:
  14.                 result['warning'] = {'title':_('Not available in stock!'),'message':_('Not available in stock!')}
  15.  
  16.         return result
  17.  
  18.  
  19. sale_order_line()