-
-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] stock_inventory_quantity_history : module to keep track of theo…
…retical and real qty at the time of an inventory
- Loading branch information
1 parent
8b67562
commit baaa7e4
Showing
13 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/stock_inventory_quantity_history/odoo/addons/stock_inventory_quantity_history
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 @@ | ||
../../../../stock_inventory_quantity_history |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
Empty file.
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,3 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import models |
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,16 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Stock Inventory Theoretical Quantity History", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"summary": "Keep theoretical and real quantities history", | ||
"author": "Akretion, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/stock-logistics-warehouse", | ||
"category": "Warehouse Management", | ||
"depends": ["stock"], | ||
"data": [ | ||
"views/stock_move_line_views.xml", | ||
], | ||
"installable": True, | ||
} |
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,4 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import stock_quant | ||
from . import stock_move_line |
17 changes: 17 additions & 0 deletions
17
stock_inventory_quantity_history/models/stock_move_line.py
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,17 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class StockMoveLine(models.Model): | ||
_inherit = "stock.move.line" | ||
|
||
inventory_theoretical_qty = fields.Float( | ||
digits="Product Unit of Measure", | ||
readonly=True, | ||
help="Theoretical Quantity right before the inventory", | ||
) | ||
inventory_real_qty = fields.Float( | ||
digits="Product Unit of Measure", | ||
help="Real Quantity at the time of the inventory", | ||
) |
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,17 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class StockQuant(models.Model): | ||
_inherit = "stock.quant" | ||
|
||
def _get_inventory_move_values(self, qty, location_id, location_dest_id, out=False): | ||
vals = super()._get_inventory_move_values( | ||
qty, location_id, location_dest_id, out=out | ||
) | ||
move_line_vals = vals["move_line_ids"][0][2] | ||
# quantity before the adjustment | ||
move_line_vals["inventory_theoretical_qty"] = self.quantity | ||
move_line_vals["inventory_real_qty"] = self.inventory_quantity | ||
return vals |
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 @@ | ||
* Florian da Costa <florian.dacosta@akretion.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 @@ | ||
When doing inventories, keep historic of the theoretical and real quantity |
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_inventory_quantity_history |
23 changes: 23 additions & 0 deletions
23
stock_inventory_quantity_history/tests/test_inventory_quantity_history.py
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,23 @@ | ||
# Copyright 2022 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestInventoryQuantityHistory(TransactionCase): | ||
def test_inventory_theoretical_quantity(self): | ||
product = self.env.ref("product.product_product_8") | ||
self.env["stock.quant"].with_context(inventory_mode=True).create( | ||
{ | ||
"product_id": product.id, | ||
"location_id": self.env.ref("stock.stock_location_stock").id, | ||
"inventory_quantity": 32.0, | ||
} | ||
)._apply_inventory() | ||
history_sml = self.env["stock.move.line"].search( | ||
[("product_id", "=", product.id), ("is_inventory", "=", True)], | ||
order="id desc", | ||
limit=1, | ||
) | ||
self.assertEqual(history_sml.inventory_theoretical_qty, 0.0) | ||
self.assertEqual(history_sml.inventory_real_qty, 32.0) |
45 changes: 45 additions & 0 deletions
45
stock_inventory_quantity_history/views/stock_move_line_views.xml
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 @@ | ||
<odoo> | ||
<record id="stock_move_line_form" model="ir.ui.view"> | ||
<field name="model">stock.move.line</field> | ||
<field name="inherit_id" ref="stock.view_move_line_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="lot_id" position="before"> | ||
<label | ||
for="inventory_theoretical_qty" | ||
string="Theoretical Quantity" | ||
/> | ||
<div class="o_row"> | ||
<field name="inventory_theoretical_qty" /> | ||
<field | ||
name="product_uom_id" | ||
options="{'no_create': True}" | ||
string="Unit of Measure" | ||
groups="uom.group_uom" | ||
/> | ||
</div> | ||
<label for="inventory_real_qty" string="Real Quantity" /> | ||
<div class="o_row"> | ||
<field name="inventory_real_qty" /> | ||
<field | ||
name="product_uom_id" | ||
options="{'no_create': True}" | ||
string="Unit of Measure" | ||
groups="uom.group_uom" | ||
/> | ||
</div> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="stock_move_line_tree" model="ir.ui.view"> | ||
<field name="model">stock.move.line</field> | ||
<field name="inherit_id" ref="stock.view_move_line_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="qty_done" position="after"> | ||
<field name="inventory_theoretical_qty" optional="hide" /> | ||
<field name="inventory_real_qty" optional="hide" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |