Skip to content

Commit

Permalink
wms_connector: improve export
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienbeau committed Oct 26, 2023
1 parent 2be02f1 commit 2f85e81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions wms_connector/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
FILTER_VALS = {
"wms_export_product_filter_id": {
"name": "WMS: {} filter for product sync",
"model_id": "wms.product.sync",
"model_id": "product.product",
},
"wms_export_picking_in_filter_id": {
"name": "WMS: {} filter for picking in",
Expand Down Expand Up @@ -211,7 +211,7 @@ def refresh_wms_products(self):
self.env["wms.product.sync"].create(
[{"product_id": prd.id, "warehouse_id": rec.id} for prd in to_create]
)
to_unlink.unlink()
to_unlink.wms_sync_ids.filtered(lambda s: s.warehouse_id == rec).unlink()

def button_open_wms_sync_ids(self):
return {
Expand Down
10 changes: 7 additions & 3 deletions wms_connector/models/synchronize_exportable_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ def button_trigger_export(self):

def _get_export_data(self):
data = []
for rec in self.sorted("id"):
for idx, rec in enumerate(self.sorted("id")):
if self.file_creation_mode == "per_record":
sequence = 0
else:
sequence = idx
try:
data += rec._prepare_export_data()
data += rec._prepare_export_data(sequence)
except Exception as e:
if "pdb" in config.get("dev_mode"):
raise
Expand Down Expand Up @@ -56,7 +60,7 @@ def track_export(self, attachment):
self.wms_export_date = datetime.datetime.now()
self.wms_export_attachment = attachment

def _prepare_export_data(self) -> list:
def _prepare_export_data(self, idx) -> list:
raise NotImplementedError

def _format_to_exportfile(self, data):
Expand Down

0 comments on commit 2f85e81

Please sign in to comment.