From 743a8a3aba5b0ad9a6daa0960c0e9eb063caab0e Mon Sep 17 00:00:00 2001 From: vnikolayev1 Date: Fri, 27 Oct 2023 18:01:58 +0300 Subject: [PATCH] [IMP] delivery_schenker: configurable submit booking - Added field for schenker delivery carrier, where user can pick if they want to submit booking on schenker site. In case where it is turned off - user has to submit booking manually. --- delivery_schenker/models/delivery_carrier.py | 12 ++++++++++++ delivery_schenker/models/schenker_request.py | 4 ---- delivery_schenker/tests/common.py | 1 + delivery_schenker/views/delivery_schenker_view.xml | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/delivery_schenker/models/delivery_carrier.py b/delivery_schenker/models/delivery_carrier.py index c120091301..0b38c4dd6e 100644 --- a/delivery_schenker/models/delivery_carrier.py +++ b/delivery_schenker/models/delivery_carrier.py @@ -179,6 +179,13 @@ class DeliveryCarrier(models.Model): help="If set, this contact will be sent as invoice address to Schenker." "\nIf Address ID is set, it will be part of it instead of the sender", ) + schenker_submit_booking = fields.Boolean( + string="Submit Booking", + default=True, + help="Submit Booking On Schenker site." + "\nIf set, submits booking on site automatically." + "\nIf not set, user has to submit booking manually.", + ) def _get_schenker_credentials(self): """Access key is mandatory for every request while group and user are @@ -518,6 +525,11 @@ def _prepare_schenker_shipping(self, picking): "homeDelivery": self.schenker_home_delivery, "ownPickup": self.schenker_own_pickup, "pharmaceuticals": self.schenker_pharmaceuticals, + # From the Schenker docs: + # Defines if booking shall be submitted. If false, + # the booking can be edited + # in the frontend and MUST be submitted manually. + "submitBooking": self.schenker_submit_booking, } ) vals.update(self._schenker_measures(picking, vals)) diff --git a/delivery_schenker/models/schenker_request.py b/delivery_schenker/models/schenker_request.py index 1cd0af0ea1..07e0e0e108 100644 --- a/delivery_schenker/models/schenker_request.py +++ b/delivery_schenker/models/schenker_request.py @@ -126,10 +126,6 @@ def _send_shipping(self, picking_vals, method=False): vals = self._shipping_api_credentials() method_wrapper = self._scheneker_shipping_api_wrapper(method) vals[method_wrapper] = picking_vals - # From the Schenker docs: - # Defines if booking shall be submitted. If false, the booking can be edited - # in the frontend and MUST be submitted manually. - vals[method_wrapper].update({"submitBooking": True}) response = self._process_reply( self.client.service[self._shipping_type_method(method)], vals ) diff --git a/delivery_schenker/tests/common.py b/delivery_schenker/tests/common.py index 46c97f1580..0c8ebf3019 100644 --- a/delivery_schenker/tests/common.py +++ b/delivery_schenker/tests/common.py @@ -165,6 +165,7 @@ def _prepare_schenker_shipping(self, picking, vals=None): "homeDelivery": True, "ownPickup": True, "pharmaceuticals": True, + "submitBooking": True, "measureUnitVolume": 1.0, } res.update(vals) diff --git a/delivery_schenker/views/delivery_schenker_view.xml b/delivery_schenker/views/delivery_schenker_view.xml index 887e26c19c..2bf8cd8a02 100644 --- a/delivery_schenker/views/delivery_schenker_view.xml +++ b/delivery_schenker/views/delivery_schenker_view.xml @@ -53,6 +53,7 @@ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> name="schenker_service_land" attrs="{'required': [('delivery_type', '=', 'schenker'), ('schenker_booking_type', '=', 'land')], 'invisible': [('schenker_booking_type', '!=', 'land')]}" /> +