mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Merge branch 'imp/12.0/delivery_gls_nl' into '12.0'
imp/12.0/delivery_gls_nl into 12.0 See merge request hibou-io/hibou-odoo/suite!698
This commit is contained in:
@@ -232,21 +232,23 @@ class ProviderGLSNL(models.Model):
|
|||||||
# }
|
# }
|
||||||
if picking.package_ids:
|
if picking.package_ids:
|
||||||
for package in picking.package_ids:
|
for package in picking.package_ids:
|
||||||
rate = self._gls_nl_rate(to.country_id.code, package.shipping_weight or 0.0)
|
converted_weight = self._gls_convert_weight(package.shipping_weight)
|
||||||
|
rate = self._gls_nl_rate(to.country_id.code, converted_weight or 0.0)
|
||||||
if rate and rate != self.GLS_NL_COUNTRY_NOT_FOUND:
|
if rate and rate != self.GLS_NL_COUNTRY_NOT_FOUND:
|
||||||
total_rate += rate
|
total_rate += rate
|
||||||
unit = {
|
unit = {
|
||||||
'unitId': package.name,
|
'unitId': package.name,
|
||||||
'weight': package.shipping_weight,
|
'weight': converted_weight
|
||||||
}
|
}
|
||||||
request_body['units'].append(unit)
|
request_body['units'].append(unit)
|
||||||
else:
|
else:
|
||||||
rate = self._gls_nl_rate(to.country_id.code, picking.shipping_weight or 0.0)
|
converted_weight = self._gls_convert_weight(picking.shipping_weight)
|
||||||
|
rate = self._gls_nl_rate(to.country_id.code, converted_weight or 0.0)
|
||||||
if rate and rate != self.GLS_NL_COUNTRY_NOT_FOUND:
|
if rate and rate != self.GLS_NL_COUNTRY_NOT_FOUND:
|
||||||
total_rate += rate
|
total_rate += rate
|
||||||
unit = {
|
unit = {
|
||||||
'unitId': picking.name,
|
'unitId': picking.name,
|
||||||
'weight': picking.shipping_weight,
|
'weight': converted_weight,
|
||||||
}
|
}
|
||||||
request_body['units'].append(unit)
|
request_body['units'].append(unit)
|
||||||
|
|
||||||
@@ -292,3 +294,11 @@ class ProviderGLSNL(models.Model):
|
|||||||
picking.write({'carrier_tracking_ref': '', 'carrier_price': 0.0})
|
picking.write({'carrier_tracking_ref': '', 'carrier_price': 0.0})
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
raise ValidationError(e)
|
raise ValidationError(e)
|
||||||
|
|
||||||
|
def _gls_convert_weight(self, weight):
|
||||||
|
get_param = self.env['ir.config_parameter'].sudo().get_param
|
||||||
|
product_weight_in_lbs_param = get_param('product.weight_in_lbs')
|
||||||
|
if product_weight_in_lbs_param == '1':
|
||||||
|
return weight / 2.20462
|
||||||
|
else:
|
||||||
|
return weight
|
||||||
|
|||||||
Reference in New Issue
Block a user