diff --git a/product/ERP5/Document/Movement.py b/product/ERP5/Document/Movement.py index c243068a44489e01afa3e606a62a04348e3a18f9..f6d65f266e608596636e07bb0e8facc82080c6ae 100644 --- a/product/ERP5/Document/Movement.py +++ b/product/ERP5/Document/Movement.py @@ -325,7 +325,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin): DeprecationWarning) local_price = self._baseGetPrice() - if local_price is None: + if local_price is None and evaluate: # We must find a price for this movement local_price = self._getPrice(context=self) return local_price diff --git a/product/ERP5/tests/testSupply.py b/product/ERP5/tests/testSupply.py index 1c5fc9030ea99c0fe3c9dafc60940606621bad64..b019caea1bedde7ed41ecc62579dc85a7af90448 100644 --- a/product/ERP5/tests/testSupply.py +++ b/product/ERP5/tests/testSupply.py @@ -588,6 +588,19 @@ class TestSaleSupply(TestSupplyMixin, SubcontentReindexingWrapper, preference.setPreferredPricingOptimise(False) self._clearCache() + def test_getPriceDoesNotLookupPriceDuringEdit(self): + """Test getPrice does not lookup price during edit. + """ + movement = self._makeRealMovement() + + def methodThatShouldNotBeCalled(*args, **kw): + self.fail("price lookup should not happen") + movement.getPriceCalculationOperandDict = methodThatShouldNotBeCalled + movement._getPrice = methodThatShouldNotBeCalled + + movement.edit(price=10) + self.assertEqual(10, movement.getPrice()) + self.abort() def _createTwoHundredSupplyLineInASupply(self): supply = self._makeSupply(