Skip to content

Commit

Permalink
[FIX] make it possible to export errored wms_product_sync without cha…
Browse files Browse the repository at this point in the history
…nging its name
  • Loading branch information
FranzPoize committed Jun 7, 2024
1 parent 39d0e7f commit f710273
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 0 additions & 1 deletion wms_connector/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def _get_domains(self):
"product": [
("warehouse_id", "=", self.id),
("to_export", "=", True),
("wms_export_error", "=", False),
],
"pickings_in": self.wms_export_picking_in_filter_id._get_eval_domain(),
"pickings_out": self.wms_export_picking_out_filter_id._get_eval_domain(),
Expand Down
5 changes: 3 additions & 2 deletions wms_connector/models/synchronize_exportable_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ def _get_export_data(self, raise_error=False):
records |= rec
rec.wms_export_error = None
except Exception as e:
rec.wms_export_error = str(e)
rec.to_export = False
if raise_error:
raise
if "pdb" in config.get("dev_mode"):
raise
rec.wms_export_error = str(e)
continue
if self.record_per_file > 0 and len(records) >= self.record_per_file:
yield records, data
Expand All @@ -56,7 +57,7 @@ def _get_export_data(self, raise_error=False):
def synchronize_export(self, raise_error=False):
attachments = self.env["attachment.queue"]
for records, data in self._get_export_data(raise_error=raise_error):
vals = self._format_to_exportfile(data)
vals = records._format_to_exportfile(data)
attachment = self.env["attachment.queue"].create(vals)
records.track_export(attachment)
attachments |= attachment
Expand Down
7 changes: 6 additions & 1 deletion wms_connector/models/wms_product_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ class WmsProductSync(models.Model):
warehouse_id = fields.Many2one("stock.warehouse", required=True, readonly=True)
active = fields.Boolean(default=True)

to_export = fields.Boolean(compute="_compute_to_export", store=True, readonly=False)
to_export = fields.Boolean(compute="_compute_to_export", inverse="_inverse_to_export", store=True, readonly=False)

@api.depends("product_id.name", "active")
def _compute_to_export(self):
for record in self:
record.to_export = True

def _inverse_to_export(self):
for rec in self:
rec.to_export = rec.to_export

def _schedule_export(self, warehouse, domain=False):
warehouse.refresh_wms_products()
return super()._schedule_export(warehouse, domain)


def track_export(self, attachment):
super().track_export(attachment)
self.to_export = False
Expand Down
2 changes: 1 addition & 1 deletion wms_connector/views/wms_product_sync.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<field name="name">wms.product.sync.tree (in wms_connector)</field>
<field name="model">wms.product.sync</field>
<field name="arch" type="xml">
<tree>
<tree multi_edit="1" editable="bottom">
<field name="name" />
<field name="product_id" />
<field name="warehouse_id" />
Expand Down

0 comments on commit f710273

Please sign in to comment.