From c861c1fbf33a7d97a4379e9bc44e1dac25e195f3 Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Mon, 3 Jun 2019 11:34:51 -0700 Subject: [PATCH 1/2] IMP `connector_walmart` Add the ability to set the Salesperson on imported Walmart orders. --- connector_walmart/__manifest__.py | 2 +- connector_walmart/models/sale_order/importer.py | 5 +++++ connector_walmart/models/walmart_backend/common.py | 2 ++ connector_walmart/views/walmart_backend_views.xml | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/connector_walmart/__manifest__.py b/connector_walmart/__manifest__.py index 33bca3fb..534a6e33 100644 --- a/connector_walmart/__manifest__.py +++ b/connector_walmart/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Walmart Connector', - 'version': '12.0.1.0.0', + 'version': '12.0.1.1.0', 'category': 'Connector', 'depends': [ 'account', diff --git a/connector_walmart/models/sale_order/importer.py b/connector_walmart/models/sale_order/importer.py index adf4c099..f10518d3 100644 --- a/connector_walmart/models/sale_order/importer.py +++ b/connector_walmart/models/sale_order/importer.py @@ -123,6 +123,11 @@ class SaleOrderImportMapper(Component): if self.backend_record.team_id: return {'team_id': self.backend_record.team_id.id} + @mapping + def user_id(self, record): + if self.backend_record.user_id: + return {'user_id': self.backend_record.user_id.id} + @mapping def payment_mode_id(self, record): assert self.backend_record.payment_mode_id, ("Payment mode must be specified.") diff --git a/connector_walmart/models/walmart_backend/common.py b/connector_walmart/models/walmart_backend/common.py index 4f4d60cc..673857f1 100644 --- a/connector_walmart/models/walmart_backend/common.py +++ b/connector_walmart/models/walmart_backend/common.py @@ -59,6 +59,8 @@ class WalmartBackend(models.Model): 'field on the sale order created by the connector.' ) team_id = fields.Many2one(comodel_name='crm.team', string='Sales Team') + user_id = fields.Many2one(comodel_name='res.users', string='Salesperson', + help="Default Salesperson for newly imported orders.") sale_prefix = fields.Char( string='Sale Prefix', help="A prefix put before the name of imported sales orders.\n" diff --git a/connector_walmart/views/walmart_backend_views.xml b/connector_walmart/views/walmart_backend_views.xml index af4c84e6..00814d97 100644 --- a/connector_walmart/views/walmart_backend_views.xml +++ b/connector_walmart/views/walmart_backend_views.xml @@ -30,6 +30,7 @@ + From 63dba9134f588e88b0c53224973b3d907988eadf Mon Sep 17 00:00:00 2001 From: Leighton Pennicott Date: Mon, 23 Nov 2020 19:07:32 -0500 Subject: [PATCH 2/2] [IMP] delivery_gls_nl: update to convert imperial units to metric units For clients with Odoo databases that use imperial units for gross weight and want to create labels to using the gls connector. H4321 --- delivery_gls_nl/models/delivery_gls_nl.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/delivery_gls_nl/models/delivery_gls_nl.py b/delivery_gls_nl/models/delivery_gls_nl.py index 46fcebff..c0694d70 100644 --- a/delivery_gls_nl/models/delivery_gls_nl.py +++ b/delivery_gls_nl/models/delivery_gls_nl.py @@ -232,21 +232,23 @@ class ProviderGLSNL(models.Model): # } if 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: total_rate += rate unit = { 'unitId': package.name, - 'weight': package.shipping_weight, + 'weight': converted_weight } request_body['units'].append(unit) 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: total_rate += rate unit = { 'unitId': picking.name, - 'weight': picking.shipping_weight, + 'weight': converted_weight, } request_body['units'].append(unit) @@ -292,3 +294,11 @@ class ProviderGLSNL(models.Model): picking.write({'carrier_tracking_ref': '', 'carrier_price': 0.0}) except HTTPError as 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