[FIX] When purchase, do not overwrite price
authorJosse Colpaert <jco@odoo.com>
Fri, 5 Sep 2014 10:16:09 +0000 (12:16 +0200)
committerJosse Colpaert <jco@odoo.com>
Fri, 12 Sep 2014 11:49:42 +0000 (13:49 +0200)
addons/purchase/stock.py
addons/stock/stock.py

index 0875ff8..1e26aaa 100644 (file)
@@ -91,7 +91,7 @@ class stock_move(osv.osv):
         """
             Attribute price to move, important in inter-company moves or receipts with only one partner
         """
-        if move.location_id.usage != 'internal' and move.location_dest_id.usage == 'internal' and not move.price_unit:
+        if not move.purchase_line_id and move.location_id.usage != 'internal' and move.location_dest_id.usage == 'internal' and not move.price_unit:
             partner = move.partner_id or (move.picking_id and move.picking_id.partner_id)
             price = False
             # If partner given, search price in its purchase pricelist
@@ -105,7 +105,7 @@ class stock_move(osv.osv):
                                                                                 })[pricelist]
                 if price:
                     self.write(cr, uid, [move.id], {'price_unit': price}, context=context)
-                return True
+                    return True
         super(stock_move, self).attribute_price(cr, uid, move, context=context)
 
 
index 56d525a..f033b4d 100644 (file)
@@ -2018,8 +2018,9 @@ class stock_move(osv.osv):
         """
             Attribute price to move, important in inter-company moves or receipts with only one partner
         """
-        price = move.product_id.standard_price
-        self.write(cr, uid, [move.id], {'price_unit': price})
+        if not move.price_unit:
+            price = move.product_id.standard_price
+            self.write(cr, uid, [move.id], {'price_unit': price})
 
 
     def action_confirm(self, cr, uid, ids, context=None):