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
5 changes: 4 additions & 1 deletion edi_core_oca/models/edi_exchange_consumer_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,17 @@ def action_view_edi_records(self):
self.ensure_one()
xmlid = "edi_core_oca.act_open_edi_exchange_record_view"
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
action["domain"] = [("id", "in", self.exchange_record_ids.ids)]
# Include records archived via backend auto-archive configuration
records = self.with_context(active_test=False).exchange_record_ids
action["domain"] = [("id", "in", records.ids)]
# Purge default search filters from ctx to avoid hiding records
ctx = action.get("context", {})
if isinstance(ctx, str):
ctx = safe_eval.safe_eval(ctx, dict(self.env.context))
action["context"] = {
k: v for k, v in ctx.items() if not k.startswith("search_default_")
}
action["context"]["active_test"] = False
# Drop ID otherwise the context will be loaded from the action's record :S
action.pop("id")
return action
Expand Down
20 changes: 20 additions & 0 deletions edi_core_oca/tests/test_consumer_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,26 @@ def test_mixin(self):
exchange_record.type_id, self.backend
)
)
self.assertEqual(action["context"].get("active_test"), False)
exchange_record.active = False
action = self.consumer_record.action_view_edi_records()
self.assertIn(exchange_record.id, action["domain"][0][2])

def test_exchange_record_count_archived(self):
vals = {
"model": self.consumer_record._name,
"res_id": self.consumer_record.id,
}
self.backend.create_record("test_csv_output", vals)
count = self.consumer_record.exchange_record_count
exchange_record = self.env["edi.exchange.record"].search(
[("model", "=", self.consumer_record._name)]
)
exchange_record.active = False
self.consumer_record.invalidate_model(
["exchange_record_ids", "exchange_record_count"]
)
self.assertEqual(self.consumer_record.exchange_record_count, count)

def test_origin(self):
vals = {
Expand Down
Loading