Skip to content

Commit

Permalink
Circumvent CacheMiss errors in tests of other modules
Browse files Browse the repository at this point in the history
  • Loading branch information
yostashiro committed Jun 16, 2024
1 parent dc1b23d commit 766dd03
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions quality_control_stock_oca/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ 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:
Expand Down

0 comments on commit 766dd03

Please sign in to comment.