-
-
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_oca, quality_control_stock_oca
This commit adds date_done field, update views and filters and 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
226e59e
commit b5ad9ad
Showing
17 changed files
with
353 additions
and
55 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
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,68 @@ | ||
# 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() | ||
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): | ||
moves = super()._action_confirm(merge=merge, merge_into=merge_into) | ||
for move in moves: | ||
move.trigger_inspection(["before", "plan_ahead"]) | ||
return moves |
Oops, something went wrong.