[FIX] purchase: keep PO currency on picking
authorMartin Trigaux <mat@odoo.com>
Fri, 14 Nov 2014 15:51:13 +0000 (16:51 +0100)
committerMartin Trigaux <mat@odoo.com>
Fri, 14 Nov 2014 16:29:40 +0000 (17:29 +0100)
The delivery of a purchase order was not keeping the currency and cost price
from the purchase order for the reception. This was problematic for orders where
the invoice was generated from the picking (Invoicing Control: Based on incoming
shipments). The currency of the purchase order was kept while the cost was the
one in the company's currency.
It's better to keep the currency of the purchase order to make the invoice as
it's usually the one expected (and not convert everything to the currency of the
company). opw 615555

addons/purchase/stock.py

index e8ea8f8..c211f39 100644 (file)
@@ -147,6 +147,16 @@ class stock_partial_picking(osv.osv_memory):
                 return {'cost': cost, 'currency': company_currency}
         return super(stock_partial_picking, self)._product_cost_for_average_update(cr, uid, move)
 
+    def _partial_move_for(self, cr, uid, move, context=None):
+        partial_move = super(stock_partial_picking, self)._partial_move_for(cr, uid, move, context=context)
+        if move.picking_id.purchase_id and move.purchase_line_id:
+            pur_currency = move.purchase_line_id.order_id.currency_id.id
+            partial_move.update({
+                'currency': pur_currency,
+                'cost': move.purchase_line_id.price_unit
+            })
+        return partial_move
+
     def __get_help_text(self, cursor, user, picking_id, context=None):
         picking = self.pool.get('stock.picking').browse(cursor, user, picking_id, context=context)
         if picking.purchase_id: