-
-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] quality_control_stock_oca: Add option to generate inspections f…
…or confirmed moves This commit adds the timing field in the QC trigger line to enable following scenarios: - When timing is 'Before', an inspection is generated for each related move when a picking with the trigger is confirmed. - When timing is 'Plan Ahead', a 'Plan' inspection is generated for each related move when a picking with the trigger is confirmed. A plan inspection is just a plan, and cannot be updated except for the date. A plan inspection gets converted into an executable inspection once the picking is done.
- Loading branch information
1 parent
7eecf03
commit 374baf4
Showing
17 changed files
with
439 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ msgstr "" | |
"Project-Id-Version: Odoo Server 10.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2017-11-28 03:44+0000\n" | ||
"PO-Revision-Date: 2024-06-06 00:30+0000\n" | ||
"PO-Revision-Date: 2024-06-11 08:57+0000\n" | ||
"Last-Translator: Wang-TKurata <[email protected]>\n" | ||
"Language-Team: Japanese (https://www.transifex.com/oca/teams/23907/ja/)\n" | ||
"Language: ja\n" | ||
|
@@ -32,7 +32,7 @@ msgstr "トリガーを定義するための抽象行" | |
#. module: quality_control_oca | ||
#: model_terms:ir.ui.view,arch_db:quality_control_oca.view_qc_test_set_test_form | ||
msgid "Accept" | ||
msgstr "合格" | ||
msgstr "OK" | ||
|
||
#. module: quality_control_oca | ||
#: model:ir.model.fields,field_description:quality_control_oca.field_qc_inspection__message_needaction | ||
|
@@ -856,7 +856,7 @@ msgstr "付番" | |
#. module: quality_control_oca | ||
#: model_terms:ir.ui.view,arch_db:quality_control_oca.qc_inspection_form_view | ||
msgid "Set test" | ||
msgstr "テストに設定" | ||
msgstr "テスト選択" | ||
|
||
#. module: quality_control_oca | ||
#: model:ir.model,name:quality_control_oca.model_qc_inspection_set_test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright 2014 Serv. Tec. Avanzados - Pedro M. Baeza | ||
# Copyright 2018 Simone Rubino - Agile Business Group | ||
# Copyright 2019 Andrii Skrypka | ||
# 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 | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
def write(self, vals): | ||
if "date" in vals: | ||
existing_inspections = self.env["qc.inspection"]._get_existing_inspections( | ||
self | ||
) | ||
existing_inspections.write({"date": vals.get("date")}) | ||
return super().write(vals) | ||
|
||
def _get_partner_for_trigger_line(self): | ||
return self.picking_id.partner_id | ||
|
||
def trigger_inspection(self, timings, partner=False): | ||
@lru_cache() | ||
def get_qc_trigger(picking_type): | ||
return ( | ||
self.env["qc.trigger"] | ||
.sudo() | ||
.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(self.picking_type_id) | ||
if qc_trigger.partner_selectable: | ||
partner = partner or self._get_partner_for_trigger_line() | ||
else: | ||
partner = False | ||
trigger_lines = set() | ||
for model in [ | ||
"qc.trigger.product_category_line", | ||
"qc.trigger.product_template_line", | ||
"qc.trigger.product_line", | ||
]: | ||
trigger_lines = trigger_lines.union( | ||
self.env[model] | ||
.sudo() | ||
.get_trigger_line_for_product( | ||
qc_trigger, timings, self.product_id.sudo(), partner=partner | ||
) | ||
) | ||
for trigger_line in _filter_trigger_lines(trigger_lines): | ||
date = False | ||
if trigger_line.timing in ["before", "plan_ahead"]: | ||
# To pass scheduled date to the generated inspection | ||
date = self.date | ||
inspection_model._make_inspection(self, trigger_line, date=date) | ||
|
||
def _action_confirm(self, merge=True, merge_into=False): | ||
res = super()._action_confirm(merge=merge, merge_into=merge_into) | ||
for move in self: | ||
move.trigger_inspection(["before", "plan_ahead"]) | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.