diff --git a/edi_core_oca/models/edi_exchange_consumer_mixin.py b/edi_core_oca/models/edi_exchange_consumer_mixin.py index 07b29b4f1..3bd97d1f9 100644 --- a/edi_core_oca/models/edi_exchange_consumer_mixin.py +++ b/edi_core_oca/models/edi_exchange_consumer_mixin.py @@ -261,7 +261,9 @@ 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): @@ -269,6 +271,7 @@ def action_view_edi_records(self): 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 diff --git a/edi_core_oca/tests/test_consumer_mixin.py b/edi_core_oca/tests/test_consumer_mixin.py index d7adadbe3..97c7e7209 100644 --- a/edi_core_oca/tests/test_consumer_mixin.py +++ b/edi_core_oca/tests/test_consumer_mixin.py @@ -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 = {