diff --git a/connector_opencart/components/api/opencart.py b/connector_opencart/components/api/opencart.py index dafe8327..1c2def31 100644 --- a/connector_opencart/components/api/opencart.py +++ b/connector_opencart/components/api/opencart.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. import requests from urllib.parse import urlencode diff --git a/connector_opencart/components/backend_adapter.py b/connector_opencart/components/backend_adapter.py index cbbcd231..4dbf884a 100644 --- a/connector_opencart/components/backend_adapter.py +++ b/connector_opencart/components/backend_adapter.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. from odoo.addons.component.core import AbstractComponent from odoo.addons.queue_job.exception import RetryableJobError diff --git a/connector_opencart/components/binder.py b/connector_opencart/components/binder.py index b2525fea..cfb5cb66 100644 --- a/connector_opencart/components/binder.py +++ b/connector_opencart/components/binder.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. from odoo.addons.component.core import Component diff --git a/connector_opencart/components/exporter.py b/connector_opencart/components/exporter.py index 21920d7d..183e3a47 100644 --- a/connector_opencart/components/exporter.py +++ b/connector_opencart/components/exporter.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. import logging diff --git a/connector_opencart/components/importer.py b/connector_opencart/components/importer.py index 6a1ef5db..7de2bfc8 100644 --- a/connector_opencart/components/importer.py +++ b/connector_opencart/components/importer.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. """ @@ -100,6 +99,8 @@ class OpencartImporter(AbstractComponent): 'Dependency import of %s(%s) has been ignored.', binding_model._name, external_id ) + # Or the binding may not have its external_id set if you raise an exception. + self.env['base'].flush() 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/components/mapper.py b/connector_opencart/components/mapper.py index f64b1483..be4488bc 100644 --- a/connector_opencart/components/mapper.py +++ b/connector_opencart/components/mapper.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. from odoo.addons.component.core import AbstractComponent diff --git a/connector_opencart/data/connector_opencart_data.xml b/connector_opencart/data/connector_opencart_data.xml index bc703882..70014165 100644 --- a/connector_opencart/data/connector_opencart_data.xml +++ b/connector_opencart/data/connector_opencart_data.xml @@ -26,7 +26,6 @@ Resolution: Check your taxes and fiscal positions configuration and correct them if necessary. 30 sale.order - sale failed = sale.opencart_bind_ids and abs(sale.amount_total - sale.opencart_bind_ids[0].total_amount) >= 0.01 @@ -37,4 +36,12 @@ Check your taxes and fiscal positions configuration and correct them if necessar Opencart Order Comment Reviewer + + Opencart Checkpoint + Opencart checkpoint. + + + trigger + + diff --git a/connector_opencart/models/delivery/common.py b/connector_opencart/models/delivery/common.py index e584ba29..074f9918 100644 --- a/connector_opencart/models/delivery/common.py +++ b/connector_opencart/models/delivery/common.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. from odoo import models, fields, api diff --git a/connector_opencart/models/opencart/backend.py b/connector_opencart/models/opencart/backend.py index 7c3b4f77..a44d231b 100644 --- a/connector_opencart/models/opencart/backend.py +++ b/connector_opencart/models/opencart/backend.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. from logging import getLogger @@ -8,7 +7,6 @@ from datetime import timedelta from odoo import api, fields, models, _ from odoo.exceptions import UserError -from odoo.addons.connector.models.checkpoint import add_checkpoint from ...components.api.opencart import Opencart _logger = getLogger(__name__) @@ -97,7 +95,6 @@ class OpencartBackend(models.Model): backend.scheduler_order_import_running = bool(sched_action.active) @contextmanager - @api.multi def work_on(self, model_name, **kwargs): self.ensure_one() opencart_api = Opencart(self.base_url, self.restadmin_token) @@ -105,28 +102,27 @@ class OpencartBackend(models.Model): with _super.work_on(model_name, opencart_api=opencart_api, **kwargs) as work: yield work - @api.multi def add_checkpoint(self, record): self.ensure_one() record.ensure_one() - return add_checkpoint(self.env, record._name, record.id, - self._name, self.id) + user = self.env.user + if 'user_id' in record and record.user_id: + user = record.user_id + if 'odoo_id' in record: + return record.odoo_id.activity_schedule( + act_type_xmlid='connector_opencart.checkpoint', + user_id=user.id) + return record.activity_schedule( + act_type_xmlid='connector_opencart.checkpoint', + user_id=user.id) - @api.multi def find_checkpoint(self, record): self.ensure_one() record.ensure_one() - checkpoint_model = self.env['connector.checkpoint'] - model_model = self.env['ir.model'] - model = model_model.search([('model', '=', record._name)], limit=1) - return checkpoint_model.search([ - ('backend_id', '=', '%s,%s' % (self._name, self.id)), - ('model_id', '=', model.id), - ('record_id', '=', record.id), - ('state', '=', 'need_review'), - ], limit=1) + if 'odoo_id' in record: + return record.odoo_id.activity_search(act_type_xmlids='connector_opencart.checkpoint') + return record.activity_search(act_type_xmlids='connector_opencart.checkpoint') - @api.multi def synchronize_metadata(self): try: for backend in self: @@ -148,12 +144,10 @@ class OpencartBackend(models.Model): ]) return backends.import_sale_orders() - @api.multi def import_sale_orders(self): self._import_sale_orders_after_date() return True - @api.multi def _import_after_id(self, model_name, after_id_field): for backend in self: after_id = backend[after_id_field] @@ -162,7 +156,6 @@ class OpencartBackend(models.Model): filters={'after_id': after_id} ) - @api.multi def _import_sale_orders_after_date(self): for backend in self: date = backend.date_to_opencart(backend.import_orders_after_date) diff --git a/connector_opencart/models/opencart/backend_importer.py b/connector_opencart/models/opencart/backend_importer.py index 9cf1b2e4..3ad1b502 100644 --- a/connector_opencart/models/opencart/backend_importer.py +++ b/connector_opencart/models/opencart/backend_importer.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. from odoo.addons.component.core import Component diff --git a/connector_opencart/models/opencart/binding.py b/connector_opencart/models/opencart/binding.py index 4273bfec..ef216e0b 100644 --- a/connector_opencart/models/opencart/binding.py +++ b/connector_opencart/models/opencart/binding.py @@ -1,8 +1,6 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. from odoo import api, models, fields -from odoo.addons.queue_job.job import job, related_action class OpencartBinding(models.AbstractModel): @@ -27,8 +25,6 @@ class OpencartBinding(models.AbstractModel): ('opencart_uniq', 'unique(backend_id, external_id)', 'A binding already exists for this Opencart ID.'), ] - @job(default_channel='root.opencart') - @related_action(action='related_action_opencart_link') @api.model def import_batch(self, backend, filters=None): """ Prepare the import of records modified on Opencart """ @@ -38,8 +34,6 @@ class OpencartBinding(models.AbstractModel): importer = work.component(usage='batch.importer') return importer.run(filters=filters) - @job(default_channel='root.opencart') - @related_action(action='related_action_opencart_link') @api.model def import_record(self, backend, external_id, force=False): """ Import a Opencart record """ diff --git a/connector_opencart/models/opencart/store.py b/connector_opencart/models/opencart/store.py index 33b97625..d9f23421 100644 --- a/connector_opencart/models/opencart/store.py +++ b/connector_opencart/models/opencart/store.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. from odoo import api, fields, models from odoo.exceptions import ValidationError diff --git a/connector_opencart/models/opencart/store_importer.py b/connector_opencart/models/opencart/store_importer.py index 79fcf834..c0af5211 100644 --- a/connector_opencart/models/opencart/store_importer.py +++ b/connector_opencart/models/opencart/store_importer.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. from odoo.addons.component.core import Component from odoo.addons.connector.components.mapper import mapping diff --git a/connector_opencart/models/sale_order/common.py b/connector_opencart/models/sale_order/common.py index 3e91b8f6..eb0481f7 100644 --- a/connector_opencart/models/sale_order/common.py +++ b/connector_opencart/models/sale_order/common.py @@ -1,11 +1,9 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. import odoo.addons.decimal_precision as dp from odoo import models, fields, api from odoo.exceptions import ValidationError -from odoo.addons.queue_job.job import job from odoo.addons.component.core import Component from odoo.addons.queue_job.exception import RetryableJobError @@ -32,7 +30,6 @@ class OpencartSaleOrder(models.Model): digits=dp.get_precision('Account') ) - @job(default_channel='root.opencart') @api.model def import_batch(self, backend, filters=None): """ Prepare the import of Sales Orders from Opencart """ diff --git a/connector_opencart/models/sale_order/importer.py b/connector_opencart/models/sale_order/importer.py index a4e834ec..8da37b15 100644 --- a/connector_opencart/models/sale_order/importer.py +++ b/connector_opencart/models/sale_order/importer.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. from copy import copy from html import unescape diff --git a/connector_opencart/models/stock_picking/common.py b/connector_opencart/models/stock_picking/common.py index 71dd204c..da90a1d8 100644 --- a/connector_opencart/models/stock_picking/common.py +++ b/connector_opencart/models/stock_picking/common.py @@ -1,8 +1,6 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. from odoo import api, models, fields, _ -from odoo.addons.queue_job.job import job, related_action from odoo.addons.component.core import Component from odoo.addons.queue_job.exception import RetryableJobError @@ -21,9 +19,6 @@ class OpencartStockPicking(models.Model): string='Opencart Sale Order', ondelete='set null') - @job(default_channel='root.opencart') - @related_action(action='related_action_unwrap_binding') - @api.multi def export_picking_done(self): """ Export a complete or partial delivery order. """ self.ensure_one() diff --git a/connector_opencart/models/stock_picking/exporter.py b/connector_opencart/models/stock_picking/exporter.py index 3951fad0..36c391fd 100644 --- a/connector_opencart/models/stock_picking/exporter.py +++ b/connector_opencart/models/stock_picking/exporter.py @@ -1,5 +1,4 @@ -# © 2019 Hibou Corp. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +# © 2019-2021 Hibou Corp. from odoo.addons.component.core import Component from odoo.addons.queue_job.exception import NothingToDoJob diff --git a/connector_opencart/views/opencart_backend_views.xml b/connector_opencart/views/opencart_backend_views.xml index be7adaad..8245554a 100644 --- a/connector_opencart/views/opencart_backend_views.xml +++ b/connector_opencart/views/opencart_backend_views.xml @@ -102,7 +102,6 @@ Opencart Backends opencart.backend - form tree,form @@ -162,7 +161,6 @@ Opencart Stores opencart.store - form tree,form diff --git a/connector_opencart/views/opencart_product_views.xml b/connector_opencart/views/opencart_product_views.xml index 4cec551f..43a72b07 100644 --- a/connector_opencart/views/opencart_product_views.xml +++ b/connector_opencart/views/opencart_product_views.xml @@ -39,10 +39,24 @@ + + opencart.product.template.search + opencart.product.template + + + + + + + + + + + + Opencart Products opencart.product.template - form tree,form