Require unit price for move between warehouses

The continental accounting requires a cost for such moves.

issue11654
review419681003
(grafted from fde807953ae4ed854d7c479a86a3230aa50d98ce)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier committed 2022-08-26 17:49:54 +02:00
1 parent ef2d999634
commit c49c9d2b70
3 files changed
+12

No files matched your search

+9
View File
@@ -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)
@@ -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')
@@ -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'