Skip to content

Commit

Permalink
Fix error in weight validation for services with no max_weight
Browse files Browse the repository at this point in the history
  • Loading branch information
osantana committed Apr 19, 2017
1 parent 699bedb commit 57d0c2e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion correios/models/posting.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,10 @@ def _validate_weight(cls, weight, service=None):
if weight <= 0:
raise exceptions.InvalidMinPackageWeightError("Invalid weight {!r}g".format(weight))

if service and weight > service.max_weight:
if not service or service.max_weight is None:
return

if weight > service.max_weight:
message = "Max weight exceeded for service {!r}: {!r}g (max. {!r}g)".format(
weight,
str(service),
Expand Down

0 comments on commit 57d0c2e

Please sign in to comment.