Skip to content

Commit a2d86a3

Browse files
[IMP] delivery_gls_asm: raise UserError when validating picking with a PickUp Service
Also raise UserError if trying to send pickup with a non PickUp Service
1 parent ff7c7e2 commit a2d86a3

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

delivery_gls_asm/models/delivery_carrier.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,17 @@ def gls_asm_send_shipping(self, pickings):
269269
result = []
270270
for picking in pickings:
271271
if picking.carrier_id.gls_is_pickup_service:
272-
continue
272+
service_name = dict(
273+
picking.carrier_id._fields["gls_asm_service"].selection
274+
).get(picking.carrier_id.gls_asm_service)
275+
raise UserError(
276+
_(
277+
"The service %s is a pickup service. "
278+
"If you want to record a pickup, please first use the "
279+
"'Send Pickup' button in the picking."
280+
)
281+
% service_name
282+
)
273283
vals = self._prepare_gls_asm_shipping(picking)
274284
if len(vals.get("referencia_c", "")) > 15:
275285
raise UserError(
@@ -339,7 +349,12 @@ def gls_asm_send_pickup(self, pickings):
339349
result = []
340350
for picking in pickings:
341351
if not picking.carrier_id.gls_is_pickup_service:
342-
continue
352+
service_name = dict(
353+
picking.carrier_id._fields["gls_asm_service"].selection
354+
).get(picking.carrier_id.gls_asm_service)
355+
raise UserError(
356+
_("The service %s is not a pickup service.") % service_name
357+
)
343358
vals = self._prepare_gls_asm_pickup(picking)
344359
vals.update({"tracking_number": False, "exact_price": 0})
345360
response = gls_request._send_pickup(vals)

0 commit comments

Comments
 (0)