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

        The continental accounting requires a cost for such moves.

        issue11654
        review419681003
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 4731aa88a5b6 -r fde807953ae4 stock.py
--- a/stock.py  Mon May 02 17:20:48 2022 +0200
+++ b/stock.py  Fri Aug 26 17:49:54 2022 +0200
@@ -63,6 +63,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 4731aa88a5b6 -r fde807953ae4 
tests/scenario_account_stock_continental.rst
--- a/tests/scenario_account_stock_continental.rst      Mon May 02 17:20:48 
2022 +0200
+++ 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 4731aa88a5b6 -r fde807953ae4 tests/scenario_product_cost_warehouse.rst
--- a/tests/scenario_product_cost_warehouse.rst Mon May 02 17:20:48 2022 +0200
+++ 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