mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[IMP] delivery_gso: weight conversion, per-package insurance/sig.req
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
'name': 'Golden State Overnight (gso.com) Shipping',
|
'name': 'Golden State Overnight (gso.com) Shipping',
|
||||||
'summary': 'Send your shippings through gso.com and track them online.',
|
'summary': 'Send your shippings through gso.com and track them online.',
|
||||||
'version': '15.0.1.0.0',
|
'version': '15.0.1.0.1',
|
||||||
'author': "Hibou Corp.",
|
'author': "Hibou Corp.",
|
||||||
'category': 'Warehouse',
|
'category': 'Warehouse',
|
||||||
'license': 'OPL-1',
|
'license': 'OPL-1',
|
||||||
|
|||||||
@@ -196,14 +196,6 @@ class ProviderGSO(models.Model):
|
|||||||
request_body['Shipment'].update(self._gso_make_shipper_address(from_, company))
|
request_body['Shipment'].update(self._gso_make_shipper_address(from_, company))
|
||||||
request_body['Shipment'].update(self._gso_make_ship_address(to))
|
request_body['Shipment'].update(self._gso_make_ship_address(to))
|
||||||
|
|
||||||
# Automatic insurance at $100.0
|
|
||||||
insurance_value = sudoself.get_insurance_value(picking=picking)
|
|
||||||
if insurance_value:
|
|
||||||
request_body['Shipment']['SignatureCode'] = 'SIG_REQD'
|
|
||||||
if insurance_value > 100.0:
|
|
||||||
# Documentation says to set DeclaredValue ONLY if over $100.00
|
|
||||||
request_body['Shipment']['DeclaredValue'] = insurance_value
|
|
||||||
|
|
||||||
cost = 0.0
|
cost = 0.0
|
||||||
labels = {
|
labels = {
|
||||||
'thermal': [],
|
'thermal': [],
|
||||||
@@ -218,6 +210,20 @@ class ProviderGSO(models.Model):
|
|||||||
if picking_packages:
|
if picking_packages:
|
||||||
# Every package will be a transaction
|
# Every package will be a transaction
|
||||||
for package in picking_packages:
|
for package in picking_packages:
|
||||||
|
# Use Sale Order Number or fall back to Picking
|
||||||
|
shipment_ref = (picking.sale_id.name if picking.sale_id else picking.name) + '-' + package.name
|
||||||
|
insurance_value = sudoself.get_insurance_value(picking=picking, package=package)
|
||||||
|
if insurance_value > 100.0:
|
||||||
|
# Documentation says to set DeclaredValue ONLY if over $100.00
|
||||||
|
request_body['Shipment']['DeclaredValue'] = insurance_value
|
||||||
|
elif 'DeclaredValue' in request_body['Shipment']:
|
||||||
|
del request_body['Shipment']['DeclaredValue']
|
||||||
|
|
||||||
|
if sudoself.get_signature_required(picking=picking, package=package):
|
||||||
|
request_body['Shipment']['SignatureCode'] = 'SIG_REQD'
|
||||||
|
else:
|
||||||
|
request_body['Shipment']['SignatureCode'] = 'SIG_NOT_REQD'
|
||||||
|
|
||||||
request_body['Shipment']['Weight'] = self._gso_convert_weight(package.shipping_weight)
|
request_body['Shipment']['Weight'] = self._gso_convert_weight(package.shipping_weight)
|
||||||
request_body['Shipment'].update(self._gso_get_package_dimensions(package))
|
request_body['Shipment'].update(self._gso_get_package_dimensions(package))
|
||||||
request_body['Shipment']['ShipmentReference'] = package.name
|
request_body['Shipment']['ShipmentReference'] = package.name
|
||||||
@@ -236,9 +242,10 @@ class ProviderGSO(models.Model):
|
|||||||
raise ValidationError(e)
|
raise ValidationError(e)
|
||||||
elif not package_carriers:
|
elif not package_carriers:
|
||||||
# ship the whole picking
|
# ship the whole picking
|
||||||
|
shipment_ref = picking.sale_id.name if picking.sale_id else picking.name
|
||||||
request_body['Shipment']['Weight'] = self._gso_convert_weight(picking.shipping_weight)
|
request_body['Shipment']['Weight'] = self._gso_convert_weight(picking.shipping_weight)
|
||||||
request_body['Shipment'].update(self._gso_get_package_dimensions())
|
request_body['Shipment'].update(self._gso_get_package_dimensions())
|
||||||
request_body['Shipment']['ShipmentReference'] = picking.name
|
request_body['Shipment']['ShipmentReference'] = shipment_ref
|
||||||
request_body['Shipment']['TrackingNumber'] = self._gso_create_tracking_number(picking.name)
|
request_body['Shipment']['TrackingNumber'] = self._gso_create_tracking_number(picking.name)
|
||||||
try:
|
try:
|
||||||
response = service.post_shipment(request_body)
|
response = service.post_shipment(request_body)
|
||||||
@@ -393,7 +400,7 @@ class ProviderGSO(models.Model):
|
|||||||
elif not package:
|
elif not package:
|
||||||
est_weight_value = self._gso_convert_weight(picking.shipping_weight)
|
est_weight_value = self._gso_convert_weight(picking.shipping_weight)
|
||||||
else:
|
else:
|
||||||
est_weight_value = package.shipping_weight or package.weight
|
est_weight_value = self._gso_convert_weight(package.shipping_weight or package.weight)
|
||||||
|
|
||||||
request_body = {
|
request_body = {
|
||||||
'AccountNumber': sudoself.gso_account_number,
|
'AccountNumber': sudoself.gso_account_number,
|
||||||
@@ -409,7 +416,7 @@ class ProviderGSO(models.Model):
|
|||||||
result = service.get_rates_and_transit_time(request_body)
|
result = service.get_rates_and_transit_time(request_body)
|
||||||
# _logger.warning('GSO result:\n%s' % result)
|
# _logger.warning('GSO result:\n%s' % result)
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
_logger.error(e)
|
# _logger.error(e)
|
||||||
return [{
|
return [{
|
||||||
'success': False,
|
'success': False,
|
||||||
'price': 0.0,
|
'price': 0.0,
|
||||||
|
|||||||
Reference in New Issue
Block a user