mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
IMP connector_opencart Run queue.job in company related to Opencart Store.
Additionally, bump all related submodules.
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
'delivery',
|
'delivery',
|
||||||
'sale_stock',
|
'sale_stock',
|
||||||
'connector_ecommerce',
|
'connector_ecommerce',
|
||||||
|
'base_technical_user',
|
||||||
],
|
],
|
||||||
'author': 'Hibou Corp.',
|
'author': 'Hibou Corp.',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
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
|
||||||
@@ -106,7 +104,8 @@ class SaleOrderAdapter(Component):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
orders = orders_response['data']
|
orders = orders_response['data']
|
||||||
return map(lambda o: o['order_id'], orders)
|
# Note that `store_id is None` is checked as it may not be in the output.
|
||||||
|
return map(lambda o: (o['order_id'], o.get('store_id', None)), orders)
|
||||||
|
|
||||||
def read(self, id):
|
def read(self, id):
|
||||||
api_instance = self.api_instance
|
api_instance = self.api_instance
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
# © 2019 Hibou Corp.
|
# © 2019 Hibou Corp.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
from copy import deepcopy, copy
|
from copy import deepcopy, copy
|
||||||
|
|
||||||
from odoo import fields, _
|
from odoo import fields, _
|
||||||
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
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
from odoo.addons.queue_job.exception import NothingToDoJob, FailedJobError
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class SaleOrderBatchImporter(Component):
|
class SaleOrderBatchImporter(Component):
|
||||||
@@ -20,12 +14,22 @@ class SaleOrderBatchImporter(Component):
|
|||||||
_inherit = 'opencart.delayed.batch.importer'
|
_inherit = 'opencart.delayed.batch.importer'
|
||||||
_apply_on = 'opencart.sale.order'
|
_apply_on = 'opencart.sale.order'
|
||||||
|
|
||||||
def _import_record(self, external_id, job_options=None, **kwargs):
|
def _import_record(self, external_id, store_id, job_options=None, **kwargs):
|
||||||
if not job_options:
|
if not job_options:
|
||||||
job_options = {
|
job_options = {
|
||||||
'max_retries': 0,
|
'max_retries': 0,
|
||||||
'priority': 5,
|
'priority': 5,
|
||||||
}
|
}
|
||||||
|
if store_id is not None:
|
||||||
|
store_binder = self.binder_for('opencart.store')
|
||||||
|
store = store_binder.to_internal(store_id)
|
||||||
|
user = store.sudo().warehouse_id.company_id.user_tech_id
|
||||||
|
if user and user != self.env.user:
|
||||||
|
# Note that this is a component, which has an env through it's 'colletion'
|
||||||
|
# however, when importing the 'model' is actually what runs the delayed job
|
||||||
|
env = self.env(user=user)
|
||||||
|
self.collection.env = env
|
||||||
|
self.model.env = env
|
||||||
return super(SaleOrderBatchImporter, self)._import_record(
|
return super(SaleOrderBatchImporter, self)._import_record(
|
||||||
external_id, job_options=job_options)
|
external_id, job_options=job_options)
|
||||||
|
|
||||||
@@ -34,10 +38,10 @@ class SaleOrderBatchImporter(Component):
|
|||||||
if filters is None:
|
if filters is None:
|
||||||
filters = {}
|
filters = {}
|
||||||
external_ids = list(self.backend_adapter.search(filters))
|
external_ids = list(self.backend_adapter.search(filters))
|
||||||
for external_id in external_ids:
|
for ids in external_ids:
|
||||||
self._import_record(external_id)
|
self._import_record(ids[0], ids[1])
|
||||||
if external_ids:
|
if external_ids:
|
||||||
last_id = list(sorted(external_ids))[-1]
|
last_id = list(sorted(external_ids, key=lambda i: i[0]))[-1][0]
|
||||||
self.backend_record.import_orders_after_id = last_id
|
self.backend_record.import_orders_after_id = last_id
|
||||||
|
|
||||||
|
|
||||||
@@ -316,9 +320,6 @@ class SaleOrderImporter(Component):
|
|||||||
if binding.fiscal_position_id:
|
if binding.fiscal_position_id:
|
||||||
binding.odoo_id._compute_tax_id()
|
binding.odoo_id._compute_tax_id()
|
||||||
|
|
||||||
# if binding.backend_id.acknowledge_order == 'order_create':
|
|
||||||
# binding.with_delay().acknowledge_order(binding.backend_id, binding.external_id)
|
|
||||||
|
|
||||||
return binding
|
return binding
|
||||||
|
|
||||||
def _import_dependencies(self):
|
def _import_dependencies(self):
|
||||||
@@ -362,5 +363,4 @@ class SaleOrderLineImportMapper(Component):
|
|||||||
if not product:
|
if not product:
|
||||||
# we could use a record like (0, 0, values)
|
# we could use a record like (0, 0, values)
|
||||||
product = self.env['product.product'].create(self._product_values(record))
|
product = self.env['product.product'].create(self._product_values(record))
|
||||||
|
return {'product_id': product.id, 'product_uom': product.uom_id.id}
|
||||||
return {'product_id': product.id}
|
|
||||||
|
|||||||
@@ -143,8 +143,8 @@
|
|||||||
<field name="model">opencart.store</field>
|
<field name="model">opencart.store</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Opencart Store">
|
<tree string="Opencart Store">
|
||||||
<field name="backend_id"/>
|
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
|
<field name="backend_id"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
2
external/hibou-oca/bank-payment
vendored
2
external/hibou-oca/bank-payment
vendored
Submodule external/hibou-oca/bank-payment updated: 4747a11579...9e3bd2f6c1
2
external/hibou-oca/connector
vendored
2
external/hibou-oca/connector
vendored
Submodule external/hibou-oca/connector updated: e66413e41e...fdd035ae4e
2
external/hibou-oca/connector-ecommerce
vendored
2
external/hibou-oca/connector-ecommerce
vendored
Submodule external/hibou-oca/connector-ecommerce updated: de374703f2...41674c2f46
2
external/hibou-oca/product-attribute
vendored
2
external/hibou-oca/product-attribute
vendored
Submodule external/hibou-oca/product-attribute updated: 8cb735d736...65a989073c
2
external/hibou-oca/queue
vendored
2
external/hibou-oca/queue
vendored
Submodule external/hibou-oca/queue updated: d708db07ae...9a5084bdc3
2
external/hibou-oca/sale-workflow
vendored
2
external/hibou-oca/sale-workflow
vendored
Submodule external/hibou-oca/sale-workflow updated: 0dc78a7dea...82a1cd2ca9
2
external/hibou-oca/server-tools
vendored
2
external/hibou-oca/server-tools
vendored
Submodule external/hibou-oca/server-tools updated: 4461b174e0...b138e0a740
2
external/hibou-oca/stock-logistics-warehouse
vendored
2
external/hibou-oca/stock-logistics-warehouse
vendored
Submodule external/hibou-oca/stock-logistics-warehouse updated: de2759105e...1389db39dd
Reference in New Issue
Block a user