Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkhao committed Oct 24, 2023
1 parent 0e04865 commit e3745b8
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions wms_connector/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,18 @@ def _deactivate_crons_tasks(self):

def refresh_wms_products(self):
for rec in self:
prd_with_sync = self.wms_product_sync_ids.product_id
existing_prd = self.wms_product_sync_ids.product_id
prd_matching = self.env["product.product"].search(
rec.wms_export_product_filter_id
and rec.wms_export_product_filter_id._get_eval_domain()
or []
)
to_create = prd_matching - prd_with_sync
for prd in to_create:
self.env["wms.product.sync"].create(
{"product_id": prd.id, "warehouse_id": rec.id}
)
self.env["wms.product.sync"].search(
[
("warehouse_id", "=", rec.id),
("product_id", "in", (prd_with_sync - prd_matching).ids),
]
).unlink()
to_create = prd_matching - existing_prd
to_unlink = existing_prd - prd_matching
self.env["wms.product.sync"].create(
[{"product_id": prd.id, "warehouse_id": rec.id} for prd in to_create]
)
to_unlink.unlink()

def button_open_wms_sync_ids(self):
return {
Expand Down

0 comments on commit e3745b8

Please sign in to comment.