-
Notifications
You must be signed in to change notification settings - Fork 2
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 wfor 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
8f2367e
commit c1f0c4c
Showing
12 changed files
with
136 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 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 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 trigger_inspection(self, qc_trigger, timings, partner=False): | ||
self.ensure_one() | ||
inspection_model = self.env["qc.inspection"].sudo() | ||
partner = partner if qc_trigger.partner_selectable else 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) |
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 |
---|---|---|
|
@@ -7,3 +7,8 @@ | |
|
||
* Pedro M. Baeza | ||
* Carlos Roca | ||
|
||
* `Quartile <https://www.quartile.co>`_: | ||
|
||
* Aung Ko Ko Lin | ||
* Yoshi Tashiro |
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