-
-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] stock_move_line_reference_link: Migration to 18.0
- Loading branch information
1 parent
296362a
commit 576308e
Showing
6 changed files
with
99 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
- Miquel Raïch \<<miquel.raich@forgeflow.com>\> | ||
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`_ |
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 @@ | ||
from . import test_move_line |
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,78 @@ | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestStockMoveLine(TransactionCase): | ||
def setUp(self): | ||
super().setUp() | ||
# Set up required records for the test | ||
self.product = self.env["product.product"].create( | ||
{ | ||
"name": "Test Product", | ||
"sale_line_warn": "no-message", | ||
} | ||
) | ||
self.stock_location = self.env["stock.location"].create( | ||
{ | ||
"name": "Test Location", | ||
} | ||
) | ||
self.picking_type = self.env["stock.picking.type"].create( | ||
{ | ||
"name": "Test Picking Type", | ||
"code": "outgoing", | ||
'sequence_code': "SPT" | ||
} | ||
) | ||
self.picking = self.env["stock.picking"].create( | ||
{ | ||
"picking_type_id": self.picking_type.id, | ||
"location_id": self.stock_location.id, | ||
"location_dest_id": self.stock_location.id, | ||
} | ||
) | ||
self.move = self.env["stock.move"].create( | ||
{ | ||
"name": "Test Move", | ||
"product_id": self.product.id, | ||
"product_uom_qty": 10, | ||
"location_id": self.stock_location.id, | ||
"location_dest_id": self.stock_location.id, | ||
"picking_id": self.picking.id, | ||
} | ||
) | ||
self.move_line = self.env["stock.move.line"].create( | ||
{ | ||
"product_id": self.product.id, | ||
"move_id": self.move.id, | ||
"location_id": self.stock_location.id, | ||
"location_dest_id": self.stock_location.id, | ||
} | ||
) | ||
|
||
def test_linked_reference_with_picking(self): | ||
# Ensure the linked_reference computes correctly | ||
# when move is linked to a picking | ||
self.assertEqual( | ||
self.move_line.linked_reference, | ||
f"stock.picking,{self.picking.id}", | ||
"linked_reference should point to the picking when available", | ||
) | ||
|
||
def test_linked_reference_with_move(self): | ||
# Detach the picking and test the reference computation for the move | ||
self.move.picking_id = False | ||
self.move_line._compute_linked_reference() | ||
self.assertEqual( | ||
self.move_line.linked_reference, | ||
f"stock.move,{self.move.id}", | ||
"linked_reference should point to the move when picking is not available", | ||
) | ||
|
||
def test_linked_reference_no_reference(self): | ||
# Detach move reference entirely and test | ||
self.move_line.move_id = False | ||
self.move_line._compute_linked_reference() # Trigger compute manually | ||
self.assertFalse( | ||
self.move_line.linked_reference, | ||
"linked_reference should be False if no picking or move is available", | ||
) |