From aaa64fcd0ceb6f106654351eb4792d2ff310077d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 24 Feb 2012 11:56:57 +0100 Subject: [PATCH] Update cost_price only from supplier to storage --- CHANGELOG | 2 ++ move.py | 38 ++++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 89f5a5db34..847eb44bf5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Update cost_price only from supplier to storage + Version 2.2.0 - 2011-10-24 * Bug fixes (see mercurial logs for details) diff --git a/move.py b/move.py index cddf8ed84e..266a9350d1 100644 --- a/move.py +++ b/move.py @@ -95,13 +95,15 @@ class Move(ModelSQL, ModelView): from_location = location_obj.browse(vals['from_location']) to_location = location_obj.browse(vals['to_location']) product = product_obj.browse(vals['product']) - if from_location.type == 'supplier' \ - and product.cost_price_method == 'fifo': + if (from_location.type == 'supplier' + and to_location.type == 'storage' + and product.cost_price_method == 'fifo'): self._update_product_cost_price(vals['product'], vals['quantity'], vals['uom'], vals['unit_price'], vals['currency'], effective_date) - if to_location.type == 'supplier' \ - and product.cost_price_method == 'fifo': + if (to_location.type == 'supplier' + and from_location.type == 'storage' + and product.cost_price_method == 'fifo'): self._update_product_cost_price(vals['product'], -vals['quantity'], vals['uom'], vals['unit_price'], vals['currency'], effective_date) @@ -127,29 +129,33 @@ class Move(ModelSQL, ModelView): if 'state' in vals and vals['state'] == 'done': for move in self.browse(ids): if vals['state'] == 'cancel': - if move.from_location.type == 'supplier' \ - and move.state != 'cancel' \ - and move.product.cost_price_method == 'fifo': + if (move.from_location.type == 'supplier' + and move.to_location.type == 'storage' + and move.state != 'cancel' + and move.product.cost_price_method == 'fifo'): self._update_product_cost_price(move.product.id, -move.quantity, move.uom, move.unit_price, move.currency, move.company, effective_date) - if move.to_location.type == 'supplier' \ - and move.state != 'cancel' \ - and move.product.cost_price_method == 'fifo': + if (move.to_location.type == 'supplier' + and move.from_location.type == 'storage' + and move.state != 'cancel' + and move.product.cost_price_method == 'fifo'): self._update_product_cost_price(move.product.id, move.quantity, move.uom, move.unit_price, move.currency, move.company, effective_date) elif vals['state'] == 'done': - if move.from_location.type == 'supplier' \ - and move.state != 'done' \ - and move.product.cost_price_method == 'fifo': + if (move.from_location.type == 'supplier' + and move.to_location.type == 'storage' + and move.state != 'done' + and move.product.cost_price_method == 'fifo'): self._update_product_cost_price(move.product.id, move.quantity, move.uom, move.unit_price, move.currency, move.company, effective_date) - if move.to_location.type == 'supplier' \ - and move.state != 'done' \ - and move.product.cost_price_method == 'fifo': + if (move.to_location.type == 'supplier' + and move.from_location.type == 'storage' + and move.state != 'done' + and move.product.cost_price_method == 'fifo'): self._update_product_cost_price(move.product.id, -move.quantity, move.uom, move.unit_price, move.currency, move.company, effective_date)