Skip to content

Commit

Permalink
revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AungKoKoLin1997 committed Jun 25, 2024
1 parent f2f260d commit 25424b4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions quality_control_stock_oca/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# Copyright 2024 Quartile
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from functools import lru_cache

from odoo import models

from odoo.addons.quality_control_oca.models.qc_trigger_line import _filter_trigger_lines
Expand All @@ -24,16 +26,20 @@ def _get_partner_for_trigger_line(self):
return self.picking_id.partner_id

def trigger_inspection(self, timings, partner=False):
def get_qc_trigger():
@lru_cache()
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 All @@ -59,7 +65,7 @@ def get_qc_trigger():
inspection_model._make_inspection(self, trigger_line, date=date)

def _action_confirm(self, merge=True, merge_into=False):
moves = super()._action_confirm(merge=merge, merge_into=merge_into)
for move in moves:
res = super()._action_confirm(merge=merge, merge_into=merge_into)
for move in self:
move.trigger_inspection(["before", "plan_ahead"])
return moves
return res

0 comments on commit 25424b4

Please sign in to comment.