diff --git a/wms_connector/models/attachment_queue.py b/wms_connector/models/attachment_queue.py index 5293e468e5..bdbf42a23c 100644 --- a/wms_connector/models/attachment_queue.py +++ b/wms_connector/models/attachment_queue.py @@ -6,6 +6,7 @@ WMS_IMPORT_FILETYPES = [ ("wms_reception_confirmed", "WMS Reception confirmed"), ("wms_delivery_confirmed", "WMS Delivery confirmed"), + ("wms_update_inventory", "WMS inventory update"), ] @@ -13,6 +14,24 @@ class AttachmentQueue(models.Model): _inherit = "attachment.queue" file_type = fields.Selection(selection_add=WMS_IMPORT_FILETYPES) + default_warehouse_id = fields.Many2one( + "stock.warehouse", compute="_compute_default_warehouse", store=True + ) + + def _compute_default_warehouse(self): + for rec in self: + task_queue_prefix = None + if rec.file_type == "wms_reception_confirmed": + task_queue_prefix = "wms_import_picking_in" + elif rec.file_type == "wms_delivery_confirmed": + task_queue_prefix = "wms_import_picking_out" + elif rec.file_type == "wms_update_inventory": + task_queue_prefix = "wms_import_update_inventory" + + if task_queue_prefix is not None: + rec.default_warehouse_id = rec.env["stock.warehouse"].search( + [(f"{task_queue_prefix}_task_id.attachment_ids", "=", rec.id)] + ) def _run(self): for filetype in [el[0] for el in WMS_IMPORT_FILETYPES]: @@ -25,3 +44,6 @@ def _run_wms_reception_confirmed(self): def _run_wms_delivery_confirmed(self): raise NotImplementedError + + def _run_wms_update_inventory(self): + raise NotImplementedError diff --git a/wms_connector/models/attachment_synchronize_task.py b/wms_connector/models/attachment_synchronize_task.py index b126352167..75470198e9 100644 --- a/wms_connector/models/attachment_synchronize_task.py +++ b/wms_connector/models/attachment_synchronize_task.py @@ -12,5 +12,6 @@ class AttachmentSynchronizeTask(models.Model): ("export", "Export"), ("wms_reception_confirmed", "Reception confirmed"), ("wms_delivery_confirmed", "Delivery confirmed"), + ("wms_update_inventory", "Inventory update"), ] ) diff --git a/wms_connector/models/stock_warehouse.py b/wms_connector/models/stock_warehouse.py index 54f56dd4af..207052dc1f 100644 --- a/wms_connector/models/stock_warehouse.py +++ b/wms_connector/models/stock_warehouse.py @@ -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()", + }, } @@ -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") diff --git a/wms_connector/views/stock_warehouse.xml b/wms_connector/views/stock_warehouse.xml index 61f547f9d4..f106eaab27 100644 --- a/wms_connector/views/stock_warehouse.xml +++ b/wms_connector/views/stock_warehouse.xml @@ -46,6 +46,7 @@ + @@ -53,6 +54,7 @@ +