diff --git a/delivery_deliverea/models/delivery_carrier.py b/delivery_deliverea/models/delivery_carrier.py index aefb9be9a6..3dc2725107 100644 --- a/delivery_deliverea/models/delivery_carrier.py +++ b/delivery_deliverea/models/delivery_carrier.py @@ -458,15 +458,16 @@ def _deliverea_check_response(self, response): def deliverea_return_shipping(self, pickings): deliverea_request = DelivereaRequest(self) for picking in pickings: - vals = self._prepare_deliverea_order(picking) - response = deliverea_request.create_return(vals) - self._deliverea_check_response(response) - picking.write( - { - "carrier_tracking_ref": response.get("carrierReference", ""), - "deliverea_reference": response.get("delivereaReference", ""), - } - ) + if picking.picking_type_code == "incoming": + vals = self._prepare_deliverea_order(picking) + response = deliverea_request.create_return(vals) + self._deliverea_check_response(response) + picking.write( + { + "carrier_tracking_ref": response.get("carrierReference", ""), + "deliverea_reference": response.get("delivereaReference", ""), + } + ) return True def deliverea_cancel_shipment(self, pickings): diff --git a/delivery_deliverea/models/stock_picking.py b/delivery_deliverea/models/stock_picking.py index ffc42b4ab4..ae13019598 100644 --- a/delivery_deliverea/models/stock_picking.py +++ b/delivery_deliverea/models/stock_picking.py @@ -21,7 +21,7 @@ def deliverea_get_label(self): def send_to_shipper(self): self.ensure_one() - if self.delivery_type == "deliverea": + if self.delivery_type == "deliverea" and self.carrier_id.deliverea_return_label: self.carrier_id.deliverea_return_shipping(self) self.carrier_id.deliverea_get_return_label(self) return super().send_to_shipper()