Skip to content
Snippets Groups Projects
Commit 35107443 authored by Adrien Widart (awt)'s avatar Adrien Widart (awt)
Browse files

[FIX] delivery: hide useless length UoM

The dimensions UoM of the carrier packaging is useless: it is not the
one used in the requests and there is not any conversion

To reproduce the issue
(Need delivery_fedex. Use demo data. Enable debug mode)
1. In Shipping Methods, edit 'Fedex US':
    - Package Weight Unit: KG
    - Debug Requests: True
2. Edit its Fedex Package Type:
    - Height: 1m
    - Width: 1m
    - Length: 1m
    - Package Code: YOUR_PACKAGING
3. Create a SO with a US partner and one product
4. On the SO
    - Add Shipping
    - Select 'Fedex US'
    - Click on 'Get Rate'
5. In Logging, open the request sent

Error: the dimensions of the packaging are expressed with "CM" but they
are not converted:
```xml
<ns0:Dimensions>
	<ns0:Length>1</ns0:Length>
	<ns0:Width>1</ns0:Width>
	<ns0:Height>1</ns0:Height>
	<ns0:Units>CM</ns0:Units>
</ns0:Dimensions>
```

When encoding the packaging in the request, the UoM defined on the
packaging (meter) is ignored. Instead, we define a length UoM depending
on the UoM of the weight and we don't convert any dimension:
https://github.com/odoo/enterprise/blob/e4fd13a0e073b9855864b7fabc26bc05b9a5fd19/delivery_fedex/models/fedex_request.py#L172-L178
There is even a `TODO` about the issue.

It will be the same with the other carriers. For instance, with UPS:
https://github.com/odoo/enterprise/blob/c9899f7860cd19c86f215d6dcea89f73b51433f3/delivery_ups/models/ups_request.py#L98-L102


We use the UoM of `ups_package_dimension_unit` and do not convert the
dimensions.

We can't implement the dimensions conversion on stable versions, since
it will break all existing packagings. So, as temporary solution, we can
simply hide the useless UoM defined on the packagings.

OPW-3053048

closes odoo/odoo#105308

Related: odoo/enterprise#33754
Signed-off-by: default avatarArnold Moyaux (arm) <arm@odoo.com>
parent b09b8ef9
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ class ProductPackaging(models.Model):
def _get_default_length_uom(self):
# TODO master delete
return self.env['product.template']._get_length_uom_name_from_ir_config_parameter()
def _get_default_weight_uom(self):
......@@ -21,7 +22,7 @@ class ProductPackaging(models.Model):
shipper_package_code = fields.Char('Package Code')
package_carrier_type = fields.Selection([('none', 'No carrier integration')], string='Carrier', default='none')
weight_uom_name = fields.Char(string='Weight unit of measure label', compute='_compute_weight_uom_name', default=_get_default_weight_uom)
length_uom_name = fields.Char(string='Length unit of measure label', compute='_compute_length_uom_name', default=_get_default_length_uom)
length_uom_name = fields.Char(string='Length unit of measure label', compute='_compute_length_uom_name')
_sql_constraints = [
('positive_height', 'CHECK(height>=0)', 'Height must be positive'),
......@@ -40,8 +41,12 @@ class ProductPackaging(models.Model):
def _compute_length_uom_name(self):
for packaging in self:
packaging.length_uom_name = self.env['product.template']._get_length_uom_name_from_ir_config_parameter()
# FIXME This variable does not impact any logic, it is only used for the packaging display on the form view.
# However, it generates some confusion for the users since this UoM will be ignored when sending the requests
# to the carrier server: the dimensions will be expressed with another UoM and there won't be any conversion.
# For instance, with Fedex, the UoM used with the package dimensions will depend on the UoM of
# `fedex_weight_unit`. With UPS, we will use the UoM defined on `ups_package_dimension_unit`
self.length_uom_name = ""
def _compute_weight_uom_name(self):
for packaging in self:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment