mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[MIG] connector_opencart: to Odoo 15.0
Added checkpoint activity and search views.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo.addons.component.core import AbstractComponent
|
from odoo.addons.component.core import AbstractComponent
|
||||||
from odoo.addons.queue_job.exception import RetryableJobError
|
from odoo.addons.queue_job.exception import RetryableJobError
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo.addons.component.core import Component
|
from odoo.addons.component.core import Component
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -100,6 +99,8 @@ class OpencartImporter(AbstractComponent):
|
|||||||
'Dependency import of %s(%s) has been ignored.',
|
'Dependency import of %s(%s) has been ignored.',
|
||||||
binding_model._name, external_id
|
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
|
return True
|
||||||
if binding_model == 'opencart.product.template' and record.backend_id.so_require_product_setup:
|
if binding_model == 'opencart.product.template' and record.backend_id.so_require_product_setup:
|
||||||
# Though this is not the "right" place to do this,
|
# Though this is not the "right" place to do this,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo.addons.component.core import AbstractComponent
|
from odoo.addons.component.core import AbstractComponent
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ Resolution:
|
|||||||
Check your taxes and fiscal positions configuration and correct them if necessary.</field>
|
Check your taxes and fiscal positions configuration and correct them if necessary.</field>
|
||||||
<field name="sequence">30</field>
|
<field name="sequence">30</field>
|
||||||
<field name="model">sale.order</field>
|
<field name="model">sale.order</field>
|
||||||
<field name="rule_group">sale</field>
|
|
||||||
<field name="code">failed = sale.opencart_bind_ids and abs(sale.amount_total - sale.opencart_bind_ids[0].total_amount) >= 0.01</field>
|
<field name="code">failed = sale.opencart_bind_ids and abs(sale.amount_total - sale.opencart_bind_ids[0].total_amount) >= 0.01</field>
|
||||||
<field name="active" eval="True"/>
|
<field name="active" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
@@ -37,4 +36,12 @@ Check your taxes and fiscal positions configuration and correct them if necessar
|
|||||||
<field name="name">Opencart Order Comment Reviewer</field>
|
<field name="name">Opencart Order Comment Reviewer</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="checkpoint" model="mail.activity.type">
|
||||||
|
<field name="name">Opencart Checkpoint</field>
|
||||||
|
<field name="summary">Opencart checkpoint.</field>
|
||||||
|
<!-- TODO maybe add something like this in connector -->
|
||||||
|
<!-- <field name="category">checkpoint</field>-->
|
||||||
|
<field name="chaining_type">trigger</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
|
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
@@ -8,7 +7,6 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from odoo import api, fields, models, _
|
from odoo import api, fields, models, _
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
from odoo.addons.connector.models.checkpoint import add_checkpoint
|
|
||||||
from ...components.api.opencart import Opencart
|
from ...components.api.opencart import Opencart
|
||||||
|
|
||||||
_logger = getLogger(__name__)
|
_logger = getLogger(__name__)
|
||||||
@@ -97,7 +95,6 @@ class OpencartBackend(models.Model):
|
|||||||
backend.scheduler_order_import_running = bool(sched_action.active)
|
backend.scheduler_order_import_running = bool(sched_action.active)
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
@api.multi
|
|
||||||
def work_on(self, model_name, **kwargs):
|
def work_on(self, model_name, **kwargs):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
opencart_api = Opencart(self.base_url, self.restadmin_token)
|
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:
|
with _super.work_on(model_name, opencart_api=opencart_api, **kwargs) as work:
|
||||||
yield work
|
yield work
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def add_checkpoint(self, record):
|
def add_checkpoint(self, record):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
record.ensure_one()
|
record.ensure_one()
|
||||||
return add_checkpoint(self.env, record._name, record.id,
|
user = self.env.user
|
||||||
self._name, self.id)
|
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):
|
def find_checkpoint(self, record):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
record.ensure_one()
|
record.ensure_one()
|
||||||
checkpoint_model = self.env['connector.checkpoint']
|
if 'odoo_id' in record:
|
||||||
model_model = self.env['ir.model']
|
return record.odoo_id.activity_search(act_type_xmlids='connector_opencart.checkpoint')
|
||||||
model = model_model.search([('model', '=', record._name)], limit=1)
|
return record.activity_search(act_type_xmlids='connector_opencart.checkpoint')
|
||||||
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)
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def synchronize_metadata(self):
|
def synchronize_metadata(self):
|
||||||
try:
|
try:
|
||||||
for backend in self:
|
for backend in self:
|
||||||
@@ -148,12 +144,10 @@ class OpencartBackend(models.Model):
|
|||||||
])
|
])
|
||||||
return backends.import_sale_orders()
|
return backends.import_sale_orders()
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def import_sale_orders(self):
|
def import_sale_orders(self):
|
||||||
self._import_sale_orders_after_date()
|
self._import_sale_orders_after_date()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _import_after_id(self, model_name, after_id_field):
|
def _import_after_id(self, model_name, after_id_field):
|
||||||
for backend in self:
|
for backend in self:
|
||||||
after_id = backend[after_id_field]
|
after_id = backend[after_id_field]
|
||||||
@@ -162,7 +156,6 @@ class OpencartBackend(models.Model):
|
|||||||
filters={'after_id': after_id}
|
filters={'after_id': after_id}
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _import_sale_orders_after_date(self):
|
def _import_sale_orders_after_date(self):
|
||||||
for backend in self:
|
for backend in self:
|
||||||
date = backend.date_to_opencart(backend.import_orders_after_date)
|
date = backend.date_to_opencart(backend.import_orders_after_date)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo.addons.component.core import Component
|
from odoo.addons.component.core import Component
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo import api, models, fields
|
from odoo import api, models, fields
|
||||||
from odoo.addons.queue_job.job import job, related_action
|
|
||||||
|
|
||||||
|
|
||||||
class OpencartBinding(models.AbstractModel):
|
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.'),
|
('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
|
@api.model
|
||||||
def import_batch(self, backend, filters=None):
|
def import_batch(self, backend, filters=None):
|
||||||
""" Prepare the import of records modified on Opencart """
|
""" Prepare the import of records modified on Opencart """
|
||||||
@@ -38,8 +34,6 @@ class OpencartBinding(models.AbstractModel):
|
|||||||
importer = work.component(usage='batch.importer')
|
importer = work.component(usage='batch.importer')
|
||||||
return importer.run(filters=filters)
|
return importer.run(filters=filters)
|
||||||
|
|
||||||
@job(default_channel='root.opencart')
|
|
||||||
@related_action(action='related_action_opencart_link')
|
|
||||||
@api.model
|
@api.model
|
||||||
def import_record(self, backend, external_id, force=False):
|
def import_record(self, backend, external_id, force=False):
|
||||||
""" Import a Opencart record """
|
""" Import a Opencart record """
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo.addons.component.core import Component
|
from odoo.addons.component.core import Component
|
||||||
from odoo.addons.connector.components.mapper import mapping
|
from odoo.addons.connector.components.mapper import mapping
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
import odoo.addons.decimal_precision as dp
|
import odoo.addons.decimal_precision as dp
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
from odoo.addons.queue_job.job import job
|
|
||||||
from odoo.addons.component.core import Component
|
from odoo.addons.component.core import Component
|
||||||
from odoo.addons.queue_job.exception import RetryableJobError
|
from odoo.addons.queue_job.exception import RetryableJobError
|
||||||
|
|
||||||
@@ -32,7 +30,6 @@ class OpencartSaleOrder(models.Model):
|
|||||||
digits=dp.get_precision('Account')
|
digits=dp.get_precision('Account')
|
||||||
)
|
)
|
||||||
|
|
||||||
@job(default_channel='root.opencart')
|
|
||||||
@api.model
|
@api.model
|
||||||
def import_batch(self, backend, filters=None):
|
def import_batch(self, backend, filters=None):
|
||||||
""" Prepare the import of Sales Orders from Opencart """
|
""" Prepare the import of Sales Orders from Opencart """
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from html import unescape
|
from html import unescape
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo import api, models, fields, _
|
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.component.core import Component
|
||||||
from odoo.addons.queue_job.exception import RetryableJobError
|
from odoo.addons.queue_job.exception import RetryableJobError
|
||||||
|
|
||||||
@@ -21,9 +19,6 @@ class OpencartStockPicking(models.Model):
|
|||||||
string='Opencart Sale Order',
|
string='Opencart Sale Order',
|
||||||
ondelete='set null')
|
ondelete='set null')
|
||||||
|
|
||||||
@job(default_channel='root.opencart')
|
|
||||||
@related_action(action='related_action_unwrap_binding')
|
|
||||||
@api.multi
|
|
||||||
def export_picking_done(self):
|
def export_picking_done(self):
|
||||||
""" Export a complete or partial delivery order. """
|
""" Export a complete or partial delivery order. """
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019-2021 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo.addons.component.core import Component
|
from odoo.addons.component.core import Component
|
||||||
from odoo.addons.queue_job.exception import NothingToDoJob
|
from odoo.addons.queue_job.exception import NothingToDoJob
|
||||||
|
|||||||
@@ -102,7 +102,6 @@
|
|||||||
<record id="action_opencart_backend" model="ir.actions.act_window">
|
<record id="action_opencart_backend" model="ir.actions.act_window">
|
||||||
<field name="name">Opencart Backends</field>
|
<field name="name">Opencart Backends</field>
|
||||||
<field name="res_model">opencart.backend</field>
|
<field name="res_model">opencart.backend</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_id" ref="view_opencart_backend_tree"/>
|
<field name="view_id" ref="view_opencart_backend_tree"/>
|
||||||
</record>
|
</record>
|
||||||
@@ -162,7 +161,6 @@
|
|||||||
<record id="action_opencart_store" model="ir.actions.act_window">
|
<record id="action_opencart_store" model="ir.actions.act_window">
|
||||||
<field name="name">Opencart Stores</field>
|
<field name="name">Opencart Stores</field>
|
||||||
<field name="res_model">opencart.store</field>
|
<field name="res_model">opencart.store</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_id" ref="view_opencart_store_tree"/>
|
<field name="view_id" ref="view_opencart_store_tree"/>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -39,10 +39,24 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="view_opencart_product_template_search" model="ir.ui.view">
|
||||||
|
<field name="name">opencart.product.template.search</field>
|
||||||
|
<field name="model">opencart.product.template</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search string="Search Purchase Order">
|
||||||
|
<field name="odoo_id" string="Odoo Product"/>
|
||||||
|
<field name="external_id" string="External ID"/>
|
||||||
|
<separator/>
|
||||||
|
<filter string="My Activities" name="activities_my" domain="[('activity_ids.user_id', '=', uid)]"/>
|
||||||
|
<separator/>
|
||||||
|
<filter string="Has Activities" name="activities_all" domain="[('activity_ids', '!=', False)]" />
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="action_opencart_product_template" model="ir.actions.act_window">
|
<record id="action_opencart_product_template" model="ir.actions.act_window">
|
||||||
<field name="name">Opencart Products</field>
|
<field name="name">Opencart Products</field>
|
||||||
<field name="res_model">opencart.product.template</field>
|
<field name="res_model">opencart.product.template</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_id" ref="view_opencart_product_template_tree"/>
|
<field name="view_id" ref="view_opencart_product_template_tree"/>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user