Merge branch 'imp/11.0/delivery_hibou__sig_req' into '11.0-test'

imp/11.0/delivery_hibou__sig_req into 11.0-test

See merge request hibou-io/hibou-odoo/suite!1173
This commit is contained in:
Hibou Bot
2021-10-28 18:08:32 +00:00
2 changed files with 21 additions and 15 deletions

View File

@@ -230,7 +230,6 @@ class DeliveryFedex(models.Model):
payment_acc_number = superself._get_fedex_payment_account_number()
order_name = superself.get_order_name(picking=picking)
attn = superself.get_attn(picking=picking)
insurance_value = superself.get_insurance_value(picking=picking)
residential = self._get_fedex_recipient_is_residential(recipient)
srm.web_authentication_detail(superself.fedex_developer_key, superself.fedex_developer_password)
@@ -312,7 +311,7 @@ class DeliveryFedex(models.Model):
# package_length=packaging.length,
sequence_number=sequence,
ref=('%s-%d' % (order_name, sequence)),
insurance=insurance_value
insurance=superself.get_insurance_value(picking=picking, package=package)
)
srm.set_master_package(net_weight, package_count, master_tracking_id=master_tracking_id)
request = srm.process_shipment()
@@ -386,7 +385,7 @@ class DeliveryFedex(models.Model):
# package_width=packaging.width,
# package_length=packaging.length,
ref=order_name,
insurance=insurance_value
insurance=superself.get_insurance_value(picking=picking, package=picking_packages[:1])
)
srm.set_master_package(net_weight, 1)
@@ -475,7 +474,7 @@ class DeliveryFedex(models.Model):
acc_number = superself._get_fedex_account_number(order=order, picking=picking)
meter_number = superself._get_fedex_meter_number(order=order, picking=picking)
order_name = superself.get_order_name(order=order, picking=picking)
insurance_value = superself.get_insurance_value(order=order, picking=picking)
insurance_value = superself.get_insurance_value(order=order, picking=picking, package=package)
residential = self._get_fedex_recipient_is_residential(recipient)
date_planned = fields.Datetime.now()
if self.env.context.get('date_planned'):

View File

@@ -177,14 +177,6 @@ class ProviderGSO(models.Model):
request_body['Shipment'].update(self._gso_make_shipper_address(from_, company))
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
labels = {
'thermal': [],
@@ -199,6 +191,20 @@ class ProviderGSO(models.Model):
if picking_packages:
# Every package will be a transaction
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'].update(self._gso_get_package_dimensions(package))
request_body['Shipment']['ShipmentReference'] = package.name
@@ -217,9 +223,10 @@ class ProviderGSO(models.Model):
raise ValidationError(e)
elif not package_carriers:
# 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'].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)
try:
response = service.post_shipment(request_body)
@@ -345,7 +352,7 @@ class ProviderGSO(models.Model):
try:
service = sudoself._get_gso_service()
except HTTPError as e:
_logger.error(e)
# _logger.error(e)
return [{
'success': False,
'price': 0.0,
@@ -389,7 +396,7 @@ class ProviderGSO(models.Model):
result = service.get_rates_and_transit_time(request_body)
# _logger.warn('GSO result:\n%s' % result)
except HTTPError as e:
_logger.error(e)
# _logger.error(e)
return [{
'success': False,
'price': 0.0,