Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14.0 wms connector inventory support #10

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions wms_connector/models/attachment_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,32 @@
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)
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]:
Expand All @@ -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
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 @@ -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"),
]
)
13 changes: 13 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
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
Loading