diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index e6d0cb8fa6f..5f569e1964d 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -31,6 +31,13 @@ class stock_move(osv.osv): readonly=True), } + def get_price_unit(self, cr, uid, move, context=None): + """ Returns the unit price to store on the quant """ + if move.purchase_line_id: + return move.price_unit + + return super(stock_move, self).get_price_unit(cr, uid, move, context=context) + def write(self, cr, uid, ids, vals, context=None): if isinstance(ids, (int, long)): ids = [ids] @@ -117,6 +124,13 @@ class stock_move(osv.osv): """ Attribute price to move, important in inter-company moves or receipts with only one partner """ + # The method attribute_price of the parent class sets the price to the standard product + # price if move.price_unit is zero. We don't want this behavior in the case of a purchase + # order since we can purchase goods which are free of charge (e.g. 5 units offered if 100 + # are purchased). + if move.purchase_line_id: + return + code = self.get_code_from_locs(cr, uid, move, context=context) if not move.purchase_line_id and code == 'incoming' and not move.price_unit: partner = move.picking_id and move.picking_id.partner_id or False