Skip to content

Commit

Permalink
[IMP] stock_usability: refactorization
Browse files Browse the repository at this point in the history
  • Loading branch information
oihane committed Sep 20, 2024
1 parent dbe9afe commit 62404a8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
10 changes: 5 additions & 5 deletions stock_usability/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
Stock usability
===============

* In "Supplier Minimum Inventory Rule" new field
"Pending receipt from supplier".
* In "Replenishment" and "Reordering rules" menus, show the fields:
"Quantity On Hand", "Incoming", "Outgoing", "Consumed last twelve months",
"Months with stock", and "Pending receipt from supplier".
New fields in Minimum Inventory Rules:

* Quantity On Hand
* Incoming
* Outgoing
* Pending receipt from supplier

Bug Tracker
===========
Expand Down
1 change: 1 addition & 0 deletions stock_usability/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"stock",
"purchase_stock",
"product_usability",
"product_supplierinfo_usability",
],
"data": [
"views/stock_warehouse_orderpoint_views.xml",
Expand Down
19 changes: 16 additions & 3 deletions stock_usability/models/stock_warehouse_orderpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,32 @@ class StockWarehouseOrderpoint(models.Model):
qty_available = fields.Float(
string="Quantity On Hand",
digits="Product Unit of Measure",
related="product_id.qty_available",
computed="_compute_quantities",
)
incoming_qty = fields.Float(
string="Incoming",
digits="Product Unit of Measure",
related="product_id.incoming_qty",
computed="_compute_quantities",
)
outgoing_qty = fields.Float(
string="Outgoing",
digits="Product Unit of Measure",
related="product_id.outgoing_qty",
computed="_compute_quantities",
)
supplier_pending_to_receive = fields.Float(
string="Pending receipt from supplier",
related="supplier_id.supplier_pending_to_receive",
)

def _compute_quantities(self):
for record in self:
location_product = record.product_id.with_context(
location=record.location_id.id
)
record.update(
{
"qty_available": location_product.qty_available,
"incoming_qty": location_product.incoming_qty,
"outgoing_qty": location_product.outgoing_qty,
}
)

0 comments on commit 62404a8

Please sign in to comment.