Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkhao committed Oct 12, 2023
1 parent 8eb16d1 commit b9d7d8d
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 20 deletions.
11 changes: 11 additions & 0 deletions wms_connector/demo/storage_backend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Akretion
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="storage.backend" id="demo_wms_backend">
<field name="name">Demo WMS backend</field>
<field name="directory_path">/</field>
</record>

</odoo>
1 change: 1 addition & 0 deletions wms_connector/models/attachment_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ def _run_wms_reception_confirmed(self):

def _run_wms_delivery_confirmed(self):
raise NotImplementedError

1 change: 1 addition & 0 deletions wms_connector/models/attachment_synchronize_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ def scheduler_export(self, model, domain=False):
("delivery_confirmed", "Delivery confirmed"),
]
)

1 change: 1 addition & 0 deletions wms_connector/models/ir_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ class IrCron(models.Model):
warehouse_import_confirm_delivery_ids = fields.One2many(
"stock.warehouse", "wms_import_confirm_delivery_cron_id"
)
product_sync_ids = fields.One2many("wms.product.sync", "warehouse_id")
3 changes: 3 additions & 0 deletions wms_connector/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@

class ProductProduct(models.Model):
_inherit = "product.product"

wms_sync_ids = fields.One2many("wms.product.sync", "product_id")

2 changes: 1 addition & 1 deletion wms_connector/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo.addons.wms_connector.pydantic_models.stock_picking import StockPickingExporter



class StockPicking(models.Model):
Expand Down
1 change: 1 addition & 0 deletions wms_connector/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class StockWarehouse(models.Model):
required=True,
default=lambda r: r.env.ref("wms_connector.default_empty_filter"),
)
wms_product_sync_ids = fields.One2many("product.product", "warehouse_id")

def _inverse_active_wms_sync(self):
for rec in self:
Expand Down
5 changes: 4 additions & 1 deletion wms_connector/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from . import test_sync
from . import test_activate_sync
from . import test_export_records
from . import test_export_file
from . import test_import
32 changes: 32 additions & 0 deletions wms_connector/tests/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2023 Akretion
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase
import uuid
from odoo_test_helper import FakeModelLoader


class WmsConnectorCommon(TransactionCase):

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.backend = cls.env.ref("wms_connector.demo_wms_backend")
cls.backend.directory_path = str(uuid.uuid1()) + "/"
# cls.loader = FakeModelLoader(cls.env, cls.__module__)
# cls.loader.backup_registry()
#
# from .model import ResUsers
#
# cls.loader.update_registry((AttachmentSynchronizeTask,))

def tearDown(self):
super().tearDown()
files = self.backend.list_files("OUT/")
for f in files:
self.backend.delete("OUT/" + f)

@classmethod
def tearDownClass(cls):
# cls.loader.restore_registry()
super().tearDownClass()
11 changes: 11 additions & 0 deletions wms_connector/tests/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2023 Akretion
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


# class ResUsers(models.Model):
# _inherit = ["res.users", "synchronize.exportable.mixin", "synchronize.importable.mixin"]
#
# def _prepare_export_data(self):
#
26 changes: 26 additions & 0 deletions wms_connector/tests/test_activate_sync.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2023 Akretion
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase


class TestActivateSync(TransactionCase):
def setUp(self):
super().setUp()
self.warehouse = self.env.ref("stock.warehouse0")

def test_active_deactivate_wms_sync(self):
self.warehouse.active_wms_sync = True
for field in (
"wms_export_cron_id",
"wms_import_confirm_reception_cron_id",
"wms_import_confirm_delivery_cron_id",
):
self.assertTrue(getattr(self, field))
self.warehouse.active_wms_sync = False
for field in (
"wms_export_cron_id",
"wms_import_confirm_reception_cron_id",
"wms_import_confirm_delivery_cron_id",
):
self.assertFalse(getattr(self, field).active)
17 changes: 17 additions & 0 deletions wms_connector/tests/test_export.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2023 Akretion
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase


class TestExportFile(TransactionCase):

def setUp(self):
super().setUp()
self.warehouse = self.env.ref("stock.warehouse0")
self.warehouse.active_wms_sync = True

def test_run_export_cron(self):
self.warehouse.wms_export_cron_id.run()
pass

13 changes: 13 additions & 0 deletions wms_connector/tests/test_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 Akretion
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase


class TestImport(TransactionCase):

def setUp(self):
super().setUp()

def test_import_file(self):
pass
18 changes: 0 additions & 18 deletions wms_connector/tests/test_sync.py

This file was deleted.

0 comments on commit b9d7d8d

Please sign in to comment.