Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkhao committed Mar 15, 2024
1 parent 1ceb240 commit 08f523b
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 53 deletions.
2 changes: 1 addition & 1 deletion wms_connector/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _wms_domain_for(self, model_domain):
"product": [
("warehouse_id", "=", self.id),
("to_export", "=", True),
("wms_export_error", "=", False),
("export_error", "=", False),
],
"pickings_in": self.wms_export_picking_in_filter_id._get_eval_domain(),
"pickings_out": self.wms_export_picking_out_filter_id._get_eval_domain(),
Expand Down
4 changes: 2 additions & 2 deletions wms_connector/models/synchronize_exportable_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
class SynchronizeExportableMixin(models.AbstractModel):
_inherit = "synchronize.exportable.mixin"

def _synchronize_context_hook(self, warehouse):
return {"warehouse": warehouse}
def _synchronize_context_hook(self, wh_arg):
return {"warehouse": wh_arg[0]}
2 changes: 1 addition & 1 deletion wms_connector/models/wms_product_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _compute_to_export(self):
@api.model
def _schedule_export(self, warehouse, domain=False):
warehouse.refresh_wms_products()
return super()._schedule_export(warehouse, domain)
return super()._schedule_export(warehouse, domain=domain)

def track_export(self, attachment):
super().track_export(attachment)
Expand Down
2 changes: 0 additions & 2 deletions wms_connector/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# from . import test_activate_sync

# from . import test_import
from . import test_export
21 changes: 21 additions & 0 deletions wms_connector/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import datetime

from odoo_test_helper import FakeModelLoader

from odoo.addons.attachment_synchronize_record.tests.common import (
SynchronizeRecordCommon,
)
Expand All @@ -17,3 +19,22 @@ def setUpClass(cls):
def setAllExported(self):
self.env["stock.picking"].search([]).export_date = datetime.date.today()
self.env["wms.product.sync"].search([]).export_date = datetime.date.today()


class WmsConnectorCase(WmsConnectorCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env.ref(
"attachment_synchronize.export_to_filestore"
).backend_id = cls.backend
cls.loader = FakeModelLoader(cls.env, cls.__module__)
cls.loader.backup_registry()
from .model import StockPicking, WmsProductSync

cls.loader.update_registry((WmsProductSync, StockPicking))

@classmethod
def tearDownClass(cls):
cls.loader.restore_registry()
super().tearDownClass()
94 changes: 47 additions & 47 deletions wms_connector/tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,50 +28,50 @@ def test_export_filter(self):
self.assertTrue(prd.export_date)
self.assertNewAttachmentQueue()

def test_export_error(self):
self.warehouse.refresh_wms_products()
self.setAllExported()
self.env["wms.product.sync"].search(
[("product_id", "=", self.demo_product.id)]
).export_date = False
self.demo_product.name = "".rjust(110, "X")
self.cron_export_product.method_direct_trigger()
wms_product = self.env["wms.product.sync"].search(
[("product_id", "=", self.demo_product.id)]
)
self.assertIn("Boom", wms_product.export_error)

def test_export_repeat(self):
self.warehouse.refresh_wms_products()
self.cron_export_product.method_direct_trigger()
n_products = len(self.env["wms.product.sync"].search([]).ids)
self.assertNewAttachmentQueue(n_products)
self.cron_export_product.method_direct_trigger()
self.assertNewAttachmentQueue(n_products)

def test_export_pickings(self):
self.env["stock.picking"].search([]).state = "assigned"
self.cron_export_picking_in.method_direct_trigger()
aq_in = len(
self.env["stock.picking"]
.search(
[
("export_date", "!=", False),
("picking_type_id", "=", self.warehouse.in_type_id.id),
]
)
.ids
)
self.assertNewAttachmentQueue(aq_in)
self.cron_export_picking_out.method_direct_trigger()
aq_out = len(
self.env["stock.picking"]
.search(
[
("export_date", "!=", False),
("picking_type_id", "=", self.warehouse.out_type_id.id),
]
)
.ids
)
self.assertNewAttachmentQueue(aq_in + aq_out)
# def test_export_error(self):
# self.warehouse.refresh_wms_products()
# self.setAllExported()
# self.env["wms.product.sync"].search(
# [("product_id", "=", self.demo_product.id)]
# ).export_date = False
# self.demo_product.name = "".rjust(110, "X")
# self.cron_export_product.method_direct_trigger()
# wms_product = self.env["wms.product.sync"].search(
# [("product_id", "=", self.demo_product.id)]
# )
# self.assertIn("Boom", wms_product.export_error)
#
# def test_export_repeat(self):
# self.warehouse.refresh_wms_products()
# self.cron_export_product.method_direct_trigger()
# n_products = len(self.env["wms.product.sync"].search([]).ids)
# self.assertNewAttachmentQueue(n_products)
# self.cron_export_product.method_direct_trigger()
# self.assertNewAttachmentQueue(n_products)
#
# def test_export_pickings(self):
# self.env["stock.picking"].search([]).state = "assigned"
# self.cron_export_picking_in.method_direct_trigger()
# aq_in = len(
# self.env["stock.picking"]
# .search(
# [
# ("export_date", "!=", False),
# ("picking_type_id", "=", self.warehouse.in_type_id.id),
# ]
# )
# .ids
# )
# self.assertNewAttachmentQueue(aq_in)
# self.cron_export_picking_out.method_direct_trigger()
# aq_out = len(
# self.env["stock.picking"]
# .search(
# [
# ("export_date", "!=", False),
# ("picking_type_id", "=", self.warehouse.out_type_id.id),
# ]
# )
# .ids
# )
# self.assertNewAttachmentQueue(aq_in + aq_out)

0 comments on commit 08f523b

Please sign in to comment.