Skip to content

Commit

Permalink
wms_connector: ADD inventory import support
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzPoize committed Dec 6, 2023
1 parent a3cad06 commit 91064e6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions wms_connector/models/attachment_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
WMS_IMPORT_FILETYPES = [
("wms_reception_confirmed", "WMS Reception confirmed"),
("wms_delivery_confirmed", "WMS Delivery confirmed"),
("wms_update_inventory", "WMS inventory update")
]


class AttachmentQueue(models.Model):
_inherit = "attachment.queue"

file_type = fields.Selection(selection_add=WMS_IMPORT_FILETYPES)
# This seems fishy but we need the warehouse id to allow
# for update inventory
default_warehouse_id = fields.Many2one("stock.warehouse")

def _run(self):
for filetype in [el[0] for el in WMS_IMPORT_FILETYPES]:
Expand All @@ -25,3 +29,6 @@ def _run_wms_reception_confirmed(self):

def _run_wms_delivery_confirmed(self):
raise NotImplementedError

def _run_wms_update_inventory(self):
raise NotImplementedError
9 changes: 9 additions & 0 deletions wms_connector/models/attachment_synchronize_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@
class AttachmentSynchronizeTask(models.Model):
_inherit = "attachment.synchronize.task"

default_warehouse_id = fields.Many2one("stock.warehouse")

file_type = fields.Selection(
selection_add=[
("export", "Export"),
("wms_reception_confirmed", "Reception confirmed"),
("wms_delivery_confirmed", "Delivery confirmed"),
("wms_update_inventory", "Inventory update"),
]
)

def _prepare_attachment_vals(self, data, filename):
self.ensure_one()
vals = super()._prepare_attachment_vals(data, filename)
vals["default_warehouse_id"] = self.default_warehouse_id.id
return vals
14 changes: 14 additions & 0 deletions wms_connector/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@
"name_fragment": "delivery confirmation",
"code": "env['stock.warehouse'].browse({}).{}.run_import()",
},
"inventory": {
"fieldname_task": "wms_import_update_inventory_task_id",
"fieldname_cron": "wms_import_update_inventory_cron_id",
"filetype": "wms_update_inventory",
"method_type": "import",
"filepath": "OUT/",
"name_fragment": "Update inventory",
"code": "env['stock.warehouse'].browse({}).{}.run_import()",
},
}


Expand All @@ -96,11 +105,15 @@ class StockWarehouse(models.Model):
wms_import_confirm_delivery_task_id = fields.Many2one(
"attachment.synchronize.task", readonly=True
)
wms_import_update_inventory_task_id = fields.Many2one(
"attachment.synchronize.task", readonly=True
)
wms_export_product_cron_id = fields.Many2one("ir.cron", readonly=True)
wms_export_picking_in_cron_id = fields.Many2one("ir.cron", readonly=True)
wms_export_picking_out_cron_id = fields.Many2one("ir.cron", readonly=True)
wms_import_confirm_reception_cron_id = fields.Many2one("ir.cron", readonly=True)
wms_import_confirm_delivery_cron_id = fields.Many2one("ir.cron", readonly=True)
wms_import_update_inventory_cron_id = fields.Many2one("ir.cron", readonly=True)
wms_export_product_filter_id = fields.Many2one("ir.filters")
wms_export_picking_in_filter_id = fields.Many2one("ir.filters")
wms_export_picking_out_filter_id = fields.Many2one("ir.filters")
Expand Down Expand Up @@ -195,6 +208,7 @@ def _prepare_wms_task_vals(self, filetype, name_fragment="", method_type="export
"filepath": filepath,
"backend_id": self.env.ref("storage_backend.default_storage_backend").id,
"file_type": filetype,
"default_warehouse_id": self.id,
}

def _prepare_wms_cron_vals(self, code="", name_fragment=""):
Expand Down
2 changes: 2 additions & 0 deletions wms_connector/views/stock_warehouse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@
<field name="wms_export_task_id" />
<field name="wms_import_confirm_delivery_task_id" />
<field name="wms_import_confirm_reception_task_id" />
<field name="wms_import_update_inventory_task_id" />
</group>
<group>
<field name="wms_export_product_cron_id" />
<field name="wms_export_picking_in_cron_id" />
<field name="wms_export_picking_out_cron_id" />
<field name="wms_import_confirm_delivery_cron_id" />
<field name="wms_import_confirm_reception_cron_id" />
<field name="wms_import_update_inventory_cron_id" />
</group>
<group>
<field name="wms_export_product_filter_id" />
Expand Down

0 comments on commit 91064e6

Please sign in to comment.