mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
WIP from 12
This commit is contained in:
67
connector_opencart/components/backend_adapter.py
Normal file
67
connector_opencart/components/backend_adapter.py
Normal file
@@ -0,0 +1,67 @@
|
||||
# © 2019 Hibou Corp.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.addons.component.core import AbstractComponent
|
||||
from odoo.addons.queue_job.exception import RetryableJobError
|
||||
from odoo.addons.connector.exception import NetworkRetryableError
|
||||
from .api.opencart import Opencart
|
||||
from logging import getLogger
|
||||
from lxml import etree
|
||||
|
||||
_logger = getLogger(__name__)
|
||||
|
||||
|
||||
class BaseOpencartConnectorComponent(AbstractComponent):
|
||||
""" Base Opencart Connector Component
|
||||
|
||||
All components of this connector should inherit from it.
|
||||
"""
|
||||
_name = 'base.opencart.connector'
|
||||
_inherit = 'base.connector'
|
||||
_collection = 'opencart.backend'
|
||||
|
||||
|
||||
class OpencartAdapter(AbstractComponent):
|
||||
|
||||
_name = 'opencart.adapter'
|
||||
_inherit = ['base.backend.adapter', 'base.opencart.connector']
|
||||
|
||||
_opencart_model = None
|
||||
|
||||
def search(self, filters=None):
|
||||
""" Search records according to some criterias
|
||||
and returns a list of ids """
|
||||
raise NotImplementedError
|
||||
|
||||
def read(self, id, attributes=None):
|
||||
""" Returns the information of a record """
|
||||
raise NotImplementedError
|
||||
|
||||
def search_read(self, filters=None):
|
||||
""" Search records according to some criterias
|
||||
and returns their information"""
|
||||
raise NotImplementedError
|
||||
|
||||
def create(self, data):
|
||||
""" Create a record on the external system """
|
||||
raise NotImplementedError
|
||||
|
||||
def write(self, id, data):
|
||||
""" Update records on the external system """
|
||||
raise NotImplementedError
|
||||
|
||||
def delete(self, id):
|
||||
""" Delete a record on the external system """
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def api_instance(self):
|
||||
try:
|
||||
opencart_api = getattr(self.work, 'opencart_api')
|
||||
except AttributeError:
|
||||
raise AttributeError(
|
||||
'You must provide a opencart_api attribute with a '
|
||||
'Opencart instance to be able to use the '
|
||||
'Backend Adapter.'
|
||||
)
|
||||
return opencart_api
|
||||
Reference in New Issue
Block a user