From 36cfb7b62c2ae9e7589416ef3462f8ec5dcd5d4e Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Fri, 23 Jun 2023 18:13:24 +0200 Subject: [PATCH] edi_oca: fix consumer mixin exchange record count --- edi_oca/models/edi_exchange_consumer_mixin.py | 2 +- edi_oca/tests/test_consumer_mixin.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/edi_oca/models/edi_exchange_consumer_mixin.py b/edi_oca/models/edi_exchange_consumer_mixin.py index d8e3538683..8ac1ba76af 100644 --- a/edi_oca/models/edi_exchange_consumer_mixin.py +++ b/edi_oca/models/edi_exchange_consumer_mixin.py @@ -231,7 +231,7 @@ def _get_exchange_record(self, exchange_type, backend=False, extra_domain=False) @api.depends("exchange_record_ids") def _compute_exchange_record_count(self): data = self.env["edi.exchange.record"].read_group( - [("res_id", "in", self.ids)], + [("res_id", "in", self.ids), ("model", "=", self._name)], ["res_id"], ["res_id"], ) diff --git a/edi_oca/tests/test_consumer_mixin.py b/edi_oca/tests/test_consumer_mixin.py index 931c239fa6..ad7dddbe97 100644 --- a/edi_oca/tests/test_consumer_mixin.py +++ b/edi_oca/tests/test_consumer_mixin.py @@ -75,6 +75,15 @@ def test_mixin(self): "res_id": self.consumer_record.id, } exchange_record = self.backend.create_record("test_csv_output", vals) + self.assertEqual(self.consumer_record.exchange_record_count, 1) + self.env["edi.exchange.record"].create( + { + "backend_id": self.backend.id, + "type_id": self.exchange_type_new.id, + "model": "an.other.model.with.same.id", + "res_id": self.consumer_record.id, + } + ) self.consumer_record.refresh() self.assertEqual(self.consumer_record.exchange_record_count, 1) action = self.consumer_record.action_view_edi_records()