changeset 4ad69cbbe49d in modules/stock:default
details: https://hg.tryton.org/modules/stock?cmd=changeset&node=4ad69cbbe49d
description:
        Remove default currency on stock move

        issue11512
        review433171003
diffstat:

 CHANGELOG                                                        |  1 +
 move.py                                                          |  8 --------
 tests/scenario_stock_average_cost_price.rst                      |  4 +---
 tests/scenario_stock_product_quantities_by_warehouse.rst         |  4 ++++
 tests/scenario_stock_recompute_average_cost_price.rst            |  4 ++++
 tests/scenario_stock_recompute_average_cost_price_production.rst |  2 ++
 tests/scenario_stock_reporting_margin.rst                        |  5 +++++
 tests/scenario_stock_shipment_in_same_storage_input.rst          |  1 +
 tests/scenario_stock_shipment_out_same_storage_output.rst        |  1 +
 tests/test_module.py                                             |  9 ++++++++-
 10 files changed, 27 insertions(+), 12 deletions(-)

diffs (274 lines):

diff -r becc2c65395d -r 4ad69cbbe49d CHANGELOG
--- a/CHANGELOG Wed Sep 28 09:47:03 2022 +0200
+++ b/CHANGELOG Thu Sep 29 09:08:06 2022 +0200
@@ -1,3 +1,4 @@
+* Remove default currency on move
 * Allow cancelling move done
 * Support warehouse pickup
 * Allow resetting packed customer shipments
diff -r becc2c65395d -r 4ad69cbbe49d move.py
--- a/move.py   Wed Sep 28 09:47:03 2022 +0200
+++ b/move.py   Thu Sep 29 09:08:06 2022 +0200
@@ -392,14 +392,6 @@
     def default_unit_price_updated(cls):
         return True
 
-    @staticmethod
-    def default_currency():
-        Company = Pool().get('company.company')
-        company = Transaction().context.get('company')
-        if company:
-            company = Company(company)
-            return company.currency.id
-
     @fields.depends('product', 'uom')
     def on_change_product(self):
         if self.product:
diff -r becc2c65395d -r 4ad69cbbe49d tests/scenario_stock_average_cost_price.rst
--- a/tests/scenario_stock_average_cost_price.rst       Wed Sep 28 09:47:03 
2022 +0200
+++ b/tests/scenario_stock_average_cost_price.rst       Thu Sep 29 09:08:06 
2022 +0200
@@ -190,12 +190,12 @@
     >>> outgoing_move.uom = unit
     >>> outgoing_move.quantity = 1
     >>> outgoing_move.unit_price = Decimal('28')
+    >>> outgoing_move.currency = company.currency
     >>> outgoing_move.from_location = storage_loc
     >>> outgoing_move.to_location = supplier_loc
     >>> outgoing_move.planned_date = today
     >>> outgoing_move.effective_date = today
     >>> outgoing_move.company = company
-    >>> outgoing_move.currency = company.currency
     >>> outgoing_move.click('do')
 
 Cost price should stay 5::
@@ -209,7 +209,6 @@
     >>> incoming_move.product = negative_product
     >>> incoming_move.uom = unit
     >>> incoming_move.quantity = 1
-    >>> outgoing_move.unit_price = Decimal('28')
     >>> incoming_move.from_location = supplier_loc
     >>> incoming_move.to_location = storage_loc
     >>> incoming_move.planned_date = today
@@ -231,7 +230,6 @@
     >>> incoming_move.product = negative_product
     >>> incoming_move.uom = unit
     >>> incoming_move.quantity = 2
-    >>> outgoing_move.unit_price = Decimal('28')
     >>> incoming_move.from_location = supplier_loc
     >>> incoming_move.to_location = storage_loc
     >>> incoming_move.planned_date = today
diff -r becc2c65395d -r 4ad69cbbe49d 
tests/scenario_stock_product_quantities_by_warehouse.rst
--- a/tests/scenario_stock_product_quantities_by_warehouse.rst  Wed Sep 28 
09:47:03 2022 +0200
+++ b/tests/scenario_stock_product_quantities_by_warehouse.rst  Thu Sep 29 
09:08:06 2022 +0200
@@ -57,6 +57,7 @@
    >>> move.quantity = 10
    >>> move.effective_date = yesterday
    >>> move.unit_price = Decimal('10')
+   >>> move.currency = company.currency
    >>> move.click('do')
 
 Forecast some moves::
@@ -69,6 +70,7 @@
    >>> move.quantity = 6
    >>> move.planned_date = tomorrow
    >>> move.unit_price = Decimal('20')
+   >>> move.currency = company.currency
    >>> move.save()
 
    >>> move = Move()
@@ -79,6 +81,7 @@
    >>> move.quantity = 5
    >>> move.planned_date = tomorrow
    >>> move.unit_price = Decimal('10')
+   >>> move.currency = company.currency
    >>> move.save()
 
    >>> move = Move()
@@ -89,6 +92,7 @@
    >>> move.quantity = 3
    >>> move.planned_date = tomorrow
    >>> move.unit_price = Decimal('20')
+   >>> move.currency = company.currency
    >>> move.save()
 
 
diff -r becc2c65395d -r 4ad69cbbe49d 
tests/scenario_stock_recompute_average_cost_price.rst
--- a/tests/scenario_stock_recompute_average_cost_price.rst     Wed Sep 28 
09:47:03 2022 +0200
+++ b/tests/scenario_stock_recompute_average_cost_price.rst     Thu Sep 29 
09:08:06 2022 +0200
@@ -55,6 +55,7 @@
     ...     from_location=supplier_loc,
     ...     to_location=storage_loc,
     ...     unit_price=Decimal('100'),
+    ...     currency=company.currency,
     ...     effective_date=today - dt.timedelta(days=2)).click('do')
     >>> StockMove(
     ...     product=product,
@@ -62,6 +63,7 @@
     ...     from_location=storage_loc,
     ...     to_location=customer_loc,
     ...     unit_price=Decimal('300'),
+    ...     currency=company.currency,
     ...     effective_date=today - dt.timedelta(days=1)).click('do')
     >>> StockMove(
     ...     product=product,
@@ -69,6 +71,7 @@
     ...     from_location=supplier_loc,
     ...     to_location=storage_loc,
     ...     unit_price=Decimal('120'),
+    ...     currency=company.currency,
     ...     effective_date=today - dt.timedelta(days=1)).click('do')
     >>> StockMove(
     ...     product=product,
@@ -76,6 +79,7 @@
     ...     from_location=supplier_loc,
     ...     to_location=storage_loc,
     ...     unit_price=Decimal('100'),
+    ...     currency=company.currency,
     ...     effective_date=today).click('do')
 
     >>> [m.cost_price for m in StockMove.find([])]
diff -r becc2c65395d -r 4ad69cbbe49d 
tests/scenario_stock_recompute_average_cost_price_production.rst
--- a/tests/scenario_stock_recompute_average_cost_price_production.rst  Wed Sep 
28 09:47:03 2022 +0200
+++ b/tests/scenario_stock_recompute_average_cost_price_production.rst  Thu Sep 
29 09:08:06 2022 +0200
@@ -65,6 +65,7 @@
     ...     from_location=production_loc,
     ...     to_location=storage_loc,
     ...     unit_price=Decimal('40.0000'),
+    ...     currency=company.currency,
     ...     effective_date=today).click('do')
 
     >>> [m.cost_price for m in StockMove.find([])]
@@ -90,6 +91,7 @@
     ...     from_location=supplier_loc,
     ...     to_location=storage_loc,
     ...     unit_price=Decimal('20.0000'),
+    ...     currency=company.currency,
     ...     effective_date=yesterday).click('do')
 
 Recompute cost price::
diff -r becc2c65395d -r 4ad69cbbe49d tests/scenario_stock_reporting_margin.rst
--- a/tests/scenario_stock_reporting_margin.rst Wed Sep 28 09:47:03 2022 +0200
+++ b/tests/scenario_stock_reporting_margin.rst Thu Sep 29 09:08:06 2022 +0200
@@ -70,6 +70,7 @@
     >>> move.to_location = storage_loc
     >>> move.quantity = 8
     >>> move.unit_price = Decimal('20')
+    >>> move.currency = company.currency
     >>> move.effective_date = yesterday
     >>> move.click('do')
 
@@ -79,6 +80,7 @@
     >>> move.to_location = customer_loc
     >>> move.quantity = 2
     >>> move.unit_price = Decimal('40')
+    >>> move.currency = company.currency
     >>> move.effective_date = yesterday
     >>> move.click('do')
 
@@ -88,6 +90,7 @@
     >>> move.to_location = customer_loc
     >>> move.quantity = 4
     >>> move.unit_price = Decimal('30')
+    >>> move.currency = company.currency
     >>> move.effective_date = today
     >>> move.click('do')
 
@@ -97,6 +100,7 @@
     >>> move.to_location = storage_loc
     >>> move.quantity = 1
     >>> move.unit_price = Decimal('30')
+    >>> move.currency = company.currency
     >>> move.effective_date = today
     >>> move.click('do')
 
@@ -106,6 +110,7 @@
     >>> move.to_location = customer_loc
     >>> move.quantity = 2
     >>> move.unit_price = Decimal('50')
+    >>> move.currency = company.currency
     >>> move.effective_date = today
     >>> move.click('do')
 
diff -r becc2c65395d -r 4ad69cbbe49d 
tests/scenario_stock_shipment_in_same_storage_input.rst
--- a/tests/scenario_stock_shipment_in_same_storage_input.rst   Wed Sep 28 
09:47:03 2022 +0200
+++ b/tests/scenario_stock_shipment_in_same_storage_input.rst   Thu Sep 29 
09:08:06 2022 +0200
@@ -64,6 +64,7 @@
     >>> move.uom = unit
     >>> move.quantity = 1
     >>> move.unit_price = Decimal('5')
+    >>> move.currency = company.currency
     >>> move.from_location = supplier_loc
     >>> move.to_location = storage1
     >>> shipment_in.save()
diff -r becc2c65395d -r 4ad69cbbe49d 
tests/scenario_stock_shipment_out_same_storage_output.rst
--- a/tests/scenario_stock_shipment_out_same_storage_output.rst Wed Sep 28 
09:47:03 2022 +0200
+++ b/tests/scenario_stock_shipment_out_same_storage_output.rst Thu Sep 29 
09:08:06 2022 +0200
@@ -60,6 +60,7 @@
     >>> move.uom = unit
     >>> move.quantity = 1
     >>> move.unit_price = Decimal('5')
+    >>> move.currency = company.currency
     >>> move.from_location = storage_loc
     >>> move.to_location = customer_loc
     >>> shipment_out.save()
diff -r becc2c65395d -r 4ad69cbbe49d tests/test_module.py
--- a/tests/test_module.py      Wed Sep 28 09:47:03 2022 +0200
+++ b/tests/test_module.py      Thu Sep 29 09:08:06 2022 +0200
@@ -624,7 +624,8 @@
                         'to_location': storage.id,
                         'effective_date': date,
                         'company': company.id,
-                        'unit_price': 10.0
+                        'unit_price': 10.0,
+                        'currency': company.currency.id,
                         }, {
                         'product': product.id,
                         'uom': unit.id,
@@ -1573,6 +1574,7 @@
                         'from_location': supplier.id,
                         'to_location': storage.id,
                         'unit_price': Decimal('5'),
+                        'currency': company.currency.id,
                         'company': company.id,
                         }, {
                         'product': product2.id,
@@ -1581,6 +1583,7 @@
                         'from_location': supplier.id,
                         'to_location': storage.id,
                         'unit_price': Decimal('5'),
+                        'currency': company.currency.id,
                         'company': company.id,
                         }])
             with self.assertRaises(UserWarning):
@@ -1593,6 +1596,7 @@
                         'from_location': storage.id,
                         'to_location': supplier.id,
                         'unit_price': Decimal('5'),
+                        'currency': company.currency.id,
                         'company': company.id,
                         }, {
                         'product': product2.id,
@@ -1601,6 +1605,7 @@
                         'from_location': storage.id,
                         'to_location': supplier.id,
                         'unit_price': Decimal('5'),
+                        'currency': company.currency.id,
                         'company': company.id,
                         }])
             Product.write(products, {'active': False})
@@ -1635,6 +1640,7 @@
                         'from_location': supplier.id,
                         'to_location': storage.id,
                         'unit_price': Decimal('5'),
+                        'currency': company.currency.id,
                         'company': company.id,
                         }])
             with self.assertRaises(UserWarning):
@@ -1647,6 +1653,7 @@
                         'from_location': storage.id,
                         'to_location': supplier.id,
                         'unit_price': Decimal('5'),
+                        'currency': company.currency.id,
                         'company': company.id,
                         }])
             Product.write(products, {'active': False})

Reply via email to