diff --git a/stock.py b/stock.py index ce4a0aa65f..03dcdff3dc 100644 --- a/stock.py +++ b/stock.py @@ -70,6 +70,15 @@ class Move(metaclass=PoolMeta): def cost_warehouse(self): return self.from_cost_warehouse or self.to_cost_warehouse + @fields.depends('company', 'from_location', 'to_location') + def on_change_with_unit_price_required(self, name=None): + required = super().on_change_with_unit_price_required(name=name) + if (self.company and self.company.cost_price_warehouse + and self.from_location and self.to_location + and self.from_warehouse != self.to_warehouse): + required = True + return required + @fields.depends('company', 'from_location', 'to_location') def on_change_with_cost_price_required(self, name=None): required = super().on_change_with_cost_price_required(name=name) diff --git a/tests/scenario_account_stock_continental.rst b/tests/scenario_account_stock_continental.rst index fad51a612e..3528845561 100644 --- a/tests/scenario_account_stock_continental.rst +++ b/tests/scenario_account_stock_continental.rst @@ -113,6 +113,7 @@ Transfer 1 product between warehouses:: >>> move.to_location = shipment.to_location >>> move.product = product >>> move.quantity = 1 + >>> move.unit_price = product.cost_price >>> shipment.click('wait') >>> shipment.click('assign_force') diff --git a/tests/scenario_product_cost_warehouse.rst b/tests/scenario_product_cost_warehouse.rst index 87582c545a..4a16c0d792 100644 --- a/tests/scenario_product_cost_warehouse.rst +++ b/tests/scenario_product_cost_warehouse.rst @@ -139,6 +139,7 @@ Forbid direct move between warehouses:: >>> move.quantity = 1 >>> move.from_location = warehouse1.storage_location >>> move.to_location = warehouse2.storage_location + >>> move.unit_price = product.cost_price >>> move.save() >>> move.click('do') # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): @@ -161,6 +162,7 @@ Transfer 1 product between warehouses:: >>> move.to_location = shipment.to_location >>> move.product = product >>> move.quantity = 1 + >>> move.unit_price = product.cost_price >>> shipment.click('wait') >>> shipment.state 'waiting'