From 6b64aa2c7a06ca23d6a6969fc79f36f52466013f Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Wed, 24 May 2023 13:10:28 +0200 Subject: [PATCH] [IMP] tms_sale_quick_input: Changes to Fast Order Entry tms_sale_quick_input: - added filter "From now on" - added shipping_lineal_length field TT43391 --- tms_sale_quick_input/models/sale_order.py | 15 +++++++++++++++ .../tests/test_tms_sale_quick_input.py | 4 ++++ tms_sale_quick_input/views/sale_view.xml | 19 ++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/tms_sale_quick_input/models/sale_order.py b/tms_sale_quick_input/models/sale_order.py index a6e6893..3ccfe9d 100644 --- a/tms_sale_quick_input/models/sale_order.py +++ b/tms_sale_quick_input/models/sale_order.py @@ -69,6 +69,13 @@ class SaleOrderLine(models.Model): compute="_compute_shipping_volume", inverse="_inverse_shipping_volume", ) + shipping_lineal_length = fields.Float( + digits="TMS Lineal Length", + string="Lineal Length for Shipping", + compute="_compute_shipping_lineal_length", + inverse="_inverse_shipping_lineal_length", + groups="tms.group_tms_lineal_length", + ) shipping_weight = fields.Float( digits="TMS Weight", string="Weight for Shipping", @@ -158,6 +165,13 @@ def _compute_shipping_volume(self): def _inverse_shipping_volume(self): self.set_field_to_packages("shipping_volume") + @api.depends("tms_package_ids.shipping_lineal_length") + def _compute_shipping_lineal_length(self): + self.get_field_from_packages_numeric("shipping_lineal_length") + + def _inverse_shipping_lineal_length(self): + self.set_field_to_packages("shipping_lineal_length") + @api.depends("tms_package_ids.shipping_weight") def _compute_shipping_weight(self): self.get_field_from_packages_numeric("shipping_weight") @@ -255,6 +269,7 @@ def _update_package(self): "name": "/", "partner_id": self.order_partner_id.id, "pickup_date": self.pickup_date, + "forecast_unload_date": self.forecast_unload_date, } ) packages = packages.create(vals) diff --git a/tms_sale_quick_input/tests/test_tms_sale_quick_input.py b/tms_sale_quick_input/tests/test_tms_sale_quick_input.py index 715bdfc..adf13de 100644 --- a/tms_sale_quick_input/tests/test_tms_sale_quick_input.py +++ b/tms_sale_quick_input/tests/test_tms_sale_quick_input.py @@ -24,6 +24,7 @@ def setUpClass(cls): "shipping_origin_id": cls.shipping_origin.id, "shipping_destination_id": cls.shipping_destination.id, "shipping_volume": 10, + "shipping_lineal_length": 30, "shipping_weight": 20, "number_of_packages": 2, "pallet_qty": 1, @@ -44,6 +45,7 @@ def test_01_computes_work(self): sale_order_line = sale_order_line_form.save() self.assertEqual(sale_order_line.shipping_place_id, self.shipping_origin) self.assertEqual(sale_order_line.shipping_volume, 10) + self.assertEqual(sale_order_line.shipping_lineal_length, 30) self.assertEqual(sale_order_line.shipping_weight, 20) self.assertEqual(sale_order_line.number_of_packages, 2) self.assertEqual(sale_order_line.pallet_qty, 1) @@ -61,6 +63,7 @@ def _test_02_inverse_work(self): sale_order_line_form.tms_package_ids.add(package_2) sale_order_line_form.shipping_place_id = self.shipping_origin sale_order_line_form.shipping_volume = 90 + sale_order_line_form.shipping_lineal_length = 100 sale_order_line_form.shipping_weight = 150 sale_order_line_form.number_of_packages = 30 sale_order_line_form.pallet_qty = 2 @@ -73,6 +76,7 @@ def _test_02_inverse_work(self): sale_order_line.shipping_destination_id, self.shipping_destination ) self.assertEqual(package_2.shipping_volume, 90) + self.assertEqual(package_2.shipping_lineal_length, 100) self.assertEqual(package_2.shipping_weight, 150) self.assertEqual(package_2.number_of_packages, 30) self.assertEqual(package_2.pallet_qty, 2) diff --git a/tms_sale_quick_input/views/sale_view.xml b/tms_sale_quick_input/views/sale_view.xml index a6a9008..7e051df 100644 --- a/tms_sale_quick_input/views/sale_view.xml +++ b/tms_sale_quick_input/views/sale_view.xml @@ -29,6 +29,11 @@ optional="hide" attrs="{'readonly': [('editable_package_rel', '=', False)]}" /> + + @@ -86,7 +92,8 @@ context="{'default_partner_id': order_partner_id, 'default_shipping_origin_id': shipping_origin_id, 'default_shipping_destination_id': shipping_destination_id, - 'default_pickup_date': pickup_date}" + 'default_pickup_date': pickup_date, + 'default_forecast_unload_date': forecast_unload_date}" optional="show" />