-
-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0cef9c
commit 83f4e79
Showing
6 changed files
with
91 additions
and
21 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
18 changes: 0 additions & 18 deletions
18
stock_receipt_lot_info/migrations/15.0.1.0.0/pre-migration.py
This file was deleted.
Oops, something went wrong.
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,3 +1,4 @@ | ||
* Forgeflow (https://www.forgeflow.com) | ||
|
||
* Lois Rilo <lois.rilo@forgeflow.com> | ||
* Marc Belmonte <marc.belmonte@forgeflow.com> |
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_receipt_lot_info |
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,86 @@ | ||
# Copyright 2022 ForgeFlow, S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
from datetime import timedelta | ||
|
||
from odoo.fields import Datetime | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class ReceiptLotInfo(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super(ReceiptLotInfo, cls).setUpClass() | ||
group_stock_multi_locations = cls.env.ref("stock.group_stock_multi_locations") | ||
cls.env.user.write({"groups_id": [(4, group_stock_multi_locations.id, 0)]}) | ||
cls.stock_location = cls.env.ref("stock.stock_location_stock") | ||
cls.customer_location = cls.env.ref("stock.stock_location_customers") | ||
cls.supplier_location = cls.env.ref("stock.stock_location_suppliers") | ||
cls.uom_unit = cls.env.ref("uom.product_uom_unit") | ||
cls.uom_dozen = cls.env.ref("uom.product_uom_dozen") | ||
cls.product = cls.env["product.product"] | ||
cls.product_lot = cls.product.create( | ||
{ | ||
"name": "Product A", | ||
"type": "product", | ||
"tracking": "lot", | ||
"categ_id": cls.env.ref("product.product_category_all").id, | ||
} | ||
) | ||
|
||
cls.lot1 = cls.env["stock.lot"].create( | ||
{ | ||
"name": "lot_1", | ||
"product_id": cls.product_lot.id, | ||
"company_id": cls.env.company.id, | ||
} | ||
) | ||
|
||
def test_in_1(self): | ||
"""This tests adds info about dates in move lines and check if | ||
its set correctly. | ||
""" | ||
|
||
receipt_type = self.env.ref("stock.picking_type_in") | ||
picking = self.env["stock.picking"].create( | ||
{ | ||
"location_id": self.supplier_location.id, | ||
"location_dest_id": self.stock_location.id, | ||
"picking_type_id": receipt_type.id, | ||
} | ||
) | ||
move1 = self.env["stock.move"].create( | ||
{ | ||
"name": "test_lot_info_1", | ||
"location_id": self.supplier_location.id, | ||
"location_dest_id": self.stock_location.id, | ||
"product_id": self.product_lot.id, | ||
"product_uom": self.uom_unit.id, | ||
"product_uom_qty": 1.0, | ||
"picking_id": picking.id, | ||
"picking_type_id": receipt_type.id, | ||
} | ||
) | ||
picking.action_confirm() | ||
move_line1 = move1.move_line_ids[0] | ||
move_line1.write( | ||
{ | ||
"qty_done": 1, | ||
"lot_name": "lot1", | ||
"lot_expiration_date": Datetime.now() + timedelta(days=15), | ||
"lot_use_date": Datetime.now() + timedelta(days=5), | ||
"lot_removal_date": Datetime.now() + timedelta(days=20), | ||
"lot_alert_date": Datetime.now() + timedelta(days=10), | ||
} | ||
) | ||
picking.button_validate() | ||
self.assertEqual(move1.state, "done") | ||
|
||
self.assertEqual( | ||
move_line1.lot_expiration_date, Datetime.now() + timedelta(days=15) | ||
) | ||
self.assertEqual(move_line1.lot_use_date, Datetime.now() + timedelta(days=5)) | ||
self.assertEqual( | ||
move_line1.lot_removal_date, Datetime.now() + timedelta(days=20) | ||
) | ||
self.assertEqual(move_line1.lot_alert_date, Datetime.now() + timedelta(days=10)) |