From 35bb0b551d884bc1c422472a388043df41f517a1 Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Mon, 13 Mar 2023 21:05:05 +0000 Subject: [PATCH] [FIX] connector_opencart: ux and curious SOL computation --- connector_opencart/__manifest__.py | 2 +- connector_opencart/components/importer.py | 2 +- connector_opencart/models/opencart/backend.py | 4 +- .../models/sale_order/common.py | 8 +++ .../views/opencart_backend_views.xml | 72 ++++++++----------- 5 files changed, 43 insertions(+), 45 deletions(-) diff --git a/connector_opencart/__manifest__.py b/connector_opencart/__manifest__.py index 324e8593..b8b9c980 100644 --- a/connector_opencart/__manifest__.py +++ b/connector_opencart/__manifest__.py @@ -2,7 +2,7 @@ { 'name': 'Opencart Connector', - 'version': '15.0.1.0.0', + 'version': '16.0.1.0.0', 'category': 'Connector', 'depends': [ 'account', diff --git a/connector_opencart/components/importer.py b/connector_opencart/components/importer.py index 7de2bfc8..319f1312 100644 --- a/connector_opencart/components/importer.py +++ b/connector_opencart/components/importer.py @@ -100,7 +100,7 @@ class OpencartImporter(AbstractComponent): binding_model._name, external_id ) # Or the binding may not have its external_id set if you raise an exception. - self.env['base'].flush() + self.env.flush_all() return True if binding_model == 'opencart.product.template' and record.backend_id.so_require_product_setup: # Though this is not the "right" place to do this, diff --git a/connector_opencart/models/opencart/backend.py b/connector_opencart/models/opencart/backend.py index c347c254..9a1ab711 100644 --- a/connector_opencart/models/opencart/backend.py +++ b/connector_opencart/models/opencart/backend.py @@ -177,8 +177,8 @@ class OpencartBackend(models.Model): return self._date_plus_hours(date, -(self.server_offset_hours or 0)) def _date_plus_hours(self, date, hours): + if date and isinstance(date, str): + date = fields.Datetime.from_string(date) if not hours: return date - if isinstance(date, str): - date = fields.Datetime.from_string(date) return date + timedelta(hours=hours) diff --git a/connector_opencart/models/sale_order/common.py b/connector_opencart/models/sale_order/common.py index eb0481f7..fbe2dcde 100644 --- a/connector_opencart/models/sale_order/common.py +++ b/connector_opencart/models/sale_order/common.py @@ -84,6 +84,14 @@ class SaleOrderLine(models.Model): inverse_name='odoo_id', string="Opencart Bindings", ) + + def _get_display_price(self): + # WARNING do NOT remove the line to read the currency_id + # in 16.0 as of 2023-03-13 + # this fixes a res.currency bug on computing price + # the statement has very little effect other than that + self.read(['currency_id']) + return super()._get_display_price() class SaleOrderAdapter(Component): diff --git a/connector_opencart/views/opencart_backend_views.xml b/connector_opencart/views/opencart_backend_views.xml index 8245554a..40952b96 100644 --- a/connector_opencart/views/opencart_backend_views.xml +++ b/connector_opencart/views/opencart_backend_views.xml @@ -18,15 +18,11 @@ - - - - - - - - - + + + + + @@ -50,38 +46,32 @@ - - -

- By clicking on the buttons, - you will initiate the synchronizations - with Opencart. - Note that the import or exports - won't be done directly, - they will create 'Jobs' - executed as soon as possible. -

-

- Once imported, - some types of records, - like the products or categories, - need a manual review. - You will find the list - of the new records to review - in the menu 'Connectors > Checkpoint'. -

- - - -