changeset eed42b69db97 in modules/product_cost_warehouse:6.2
details: 
https://hg.tryton.org/modules/product_cost_warehouse?cmd=changeset&node=eed42b69db97
description:
        Require unit price for move between warehouses

        The continental accounting requires a cost for such moves.

        issue11654
        review419681003
        (grafted from fde807953ae4ed854d7c479a86a3230aa50d98ce)
diffstat:

 stock.py                                     |  9 +++++++++
 tests/scenario_account_stock_continental.rst |  1 +
 tests/scenario_product_cost_warehouse.rst    |  2 ++
 3 files changed, 12 insertions(+), 0 deletions(-)

diffs (49 lines):

diff -r afeb514dc626 -r eed42b69db97 stock.py
--- a/stock.py  Sat Jan 01 18:27:10 2022 +0100
+++ b/stock.py  Fri Aug 26 17:49:54 2022 +0200
@@ -65,6 +65,15 @@
         return super().to_warehouse or self.to_location.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)
         if (self.company and self.company.cost_price_warehouse
diff -r afeb514dc626 -r eed42b69db97 
tests/scenario_account_stock_continental.rst
--- a/tests/scenario_account_stock_continental.rst      Sat Jan 01 18:27:10 
2022 +0100
+++ b/tests/scenario_account_stock_continental.rst      Fri Aug 26 17:49:54 
2022 +0200
@@ -113,6 +113,7 @@
     >>> 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 -r afeb514dc626 -r eed42b69db97 tests/scenario_product_cost_warehouse.rst
--- a/tests/scenario_product_cost_warehouse.rst Sat Jan 01 18:27:10 2022 +0100
+++ b/tests/scenario_product_cost_warehouse.rst Fri Aug 26 17:49:54 2022 +0200
@@ -139,6 +139,7 @@
     >>> 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 @@
     >>> move.to_location = shipment.to_location
     >>> move.product = product
     >>> move.quantity = 1
+    >>> move.unit_price = product.cost_price
     >>> shipment.click('wait')
     >>> shipment.state
     'waiting'

Reply via email to