Hello guys, we did that for a customer,

here is the following code we put in some module:


class sale_order_line(osv.osv):
    _inherit = 'sale.order.line'

    def product_id_change(self, cr, uid, ids, pricelist, product, 
qty=0,
            uom=False, qty_uos=0, uos=False, 
name='', partner_id=False,
            lang=False, update_tax=True, 
date_order=False, packaging=False, fiscal_position=False, flag=False):
        result = super(sale_order_line, 
self).product_id_change(cr, uid, ids, pricelist, product, qty,
            uom, qty_uos, uos, name, partner_id,
            lang, update_tax, date_order, 
packaging, fiscal_position, flag)
        if product and 
self.pool.get('product.product').browse(cr, uid, product, 
&#123;&#125;&#41;.virtual_available < 1&#58;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if result&#91;'warning'&#93; and 
result&#91;'warning'&#93;&#91;'message'&#93;&#58;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
result&#91;'warning'&#93;&#91;'message'&#93; += "\n\n" + _&#40;'Not available 
in stock!'&#41;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&#58;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
result&#91;'warning'&#93; = &#123;'title'&#58;_&#40;'Not available in 
stock!'&#41;,'message'&#58;_&#40;'Not available in stock!'&#41;&#125;

&nbsp; &nbsp; &nbsp; &nbsp; return result


sale_order_line&#40;&#41;

This will display a warning popup telling the product is out of stock 
eventually when you select it in the sale order interface.

Hope this helps.

------------------------
Raphaël Valyi

CEO and OpenERP consultant at
http://www.akretion.com




-------------------- m2f --------------------

--
http://www.openobject.com/forum/viewtopic.php?p=58980#58980

-------------------- m2f --------------------


_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman2/listinfo/tinyerp-users

Reply via email to