From 924bf9bafdd8e96e79bdf01a1d9c5d58091a6357 Mon Sep 17 00:00:00 2001 From: Yoshi Tashiro Date: Sun, 16 Jun 2024 05:32:15 +0000 Subject: [PATCH] Circumvent CacheMiss errors in tests of other modules --- quality_control_stock_oca/models/stock_move.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/quality_control_stock_oca/models/stock_move.py b/quality_control_stock_oca/models/stock_move.py index 0a3d64bd..822e030f 100644 --- a/quality_control_stock_oca/models/stock_move.py +++ b/quality_control_stock_oca/models/stock_move.py @@ -27,16 +27,18 @@ def _get_partner_for_trigger_line(self): def trigger_inspection(self, timings, partner=False): @lru_cache() - def get_qc_trigger(): + def get_qc_trigger(picking_type): return ( self.env["qc.trigger"] .sudo() - .search([("picking_type_id", "=", self.picking_type_id.id)]) + .search([("picking_type_id", "=", picking_type.id)]) ) - self.ensure_one() + # To avoid CacheMiss error from tests of other modules + if "picking_type_id" not in self._cache: + return inspection_model = self.env["qc.inspection"].sudo() - qc_trigger = get_qc_trigger() + qc_trigger = get_qc_trigger(self.picking_type_id) if qc_trigger.partner_selectable: partner = partner or self._get_partner_for_trigger_line() else: