[Backport] Correct handling of offer creation without a range

The workaround for JSON serialisation introduced a bug that was
triggered when the offer contained no range, which is allowed for
certain offer types. In that case range is None, and accessing range.id
threw an error.

Fixes #1167. Thanks to @izidormatusov for reporting.

(cherry picked from commit 1e85821d85068c71d7d5b959fce743f1b7bfe248)