-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] repair_type: Migration to 17.0
- Loading branch information
1 parent
c2b6153
commit 573126f
Showing
9 changed files
with
127 additions
and
79 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 |
---|---|---|
|
@@ -87,6 +87,10 @@ Contributors | |
|
||
- Bernat Puig <[email protected]> | ||
|
||
- `APSL-Nagarro <https://apsl.tech>`__: | ||
|
||
- Miquel Alzanillas <[email protected]> | ||
|
||
Maintainers | ||
----------- | ||
|
||
|
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import repair | ||
from . import repair_type | ||
from . import stock_move |
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,41 @@ | ||
# Copyright (C) 2024 APSL-Nagarro (Advanced Programming Solutions, S.L.) | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
|
||
from odoo import api, models | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
@api.depends("repair_line_type", "repair_id.repair_type_id") | ||
def _compute_location_id(self): | ||
for rec in self: | ||
repair_type_id = rec.repair_id.repair_type_id | ||
if rec.repair_line_type == "add": | ||
if repair_type_id.source_location_add_part_id: | ||
rec.location_id = repair_type_id.source_location_add_part_id | ||
if repair_type_id.destination_location_add_part_id: | ||
rec.location_dest_id = ( | ||
repair_type_id.destination_location_add_part_id | ||
) | ||
elif rec.repair_line_type == "remove": | ||
if repair_type_id.source_location_remove_part_id: | ||
rec.location_id = repair_type_id.source_location_remove_part_id | ||
if repair_type_id.destination_location_remove_part_id: | ||
rec.location_dest_id = ( | ||
repair_type_id.destination_location_remove_part_id | ||
) | ||
|
||
@api.onchange("repair_line_type") | ||
def onchange_operation_type(self): | ||
# this onchange was overriding the changes from the compute | ||
# method `_compute_location_id`, we ensure that the locations | ||
# in the types have more priority by explicit calling the compute. | ||
return self._compute_location_id() | ||
|
||
def write(self, vals): | ||
res = super().write(vals) | ||
for rec in self: | ||
if "repair_line_type" in vals: | ||
rec._compute_location_id() | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
- [ForgeFlow](https://forgeflow.com): | ||
|
||
> - Bernat Puig \<<[email protected]>\> | ||
- [APSL-Nagarro](https://apsl.tech): | ||
|
||
> - Miquel Alzanillas \<<[email protected]>\> |
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