Skip to content
Open
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
1 change: 0 additions & 1 deletion wms_connector/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def _compute_is_wms_exportable(self):
for rec in self:
rec.is_wms_exportable = (
rec.picking_type_id.warehouse_id.active_wms_sync
and rec.picking_type_id.code in ("incoming", "outgoing")
)

def _is_user_allowed_to_cancel(self):
Expand Down
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
9 changes: 5 additions & 4 deletions wms_connector/models/synchronize_exportable_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ def _get_export_data(self, raise_error=False):
for rec in self:
try:
with self._cr.savepoint():
data += rec._prepare_export_data(sequence)
sequence, rec_data = rec._prepare_export_data(sequence)
data += rec_data
records |= rec
rec.wms_export_error = None
sequence += 1
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
1 change: 1 addition & 0 deletions wms_connector/views/stock_picking.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
/>
</header>
<field name="date_done" position="before">
<field name="is_wms_exportable" invisible="1"/>
<field
name="wms_export_date"
attrs="{'invisible': [('is_wms_exportable', '=', 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
Loading