Skip to content

Commit

Permalink
[14.0][IMP] stock_report_quantity_by_location: add virtual_available qty
Browse files Browse the repository at this point in the history
  • Loading branch information
enriquemartin committed May 31, 2023
1 parent 4fbcd60 commit 0b253a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ def _compute_stock_report_by_location(self):
"quantity_unreserved": qty_unreserved,
}
mapping.setdefault(quant_group["product_id"][0], qty_dict)
products = self.env["product.product"].search([("type", "=", "product")])
products = (
self.env["product.product"]
.with_context(location=loc.id)
.search([("type", "=", "product")])
)
vals_list = []
for product in products:
qty_dict = mapping.get(product.id, {})
Expand All @@ -69,6 +73,7 @@ def _compute_stock_report_by_location(self):
"quantity_on_hand": qty_on_hand,
"quantity_reserved": qty_reserved,
"quantity_unreserved": qty_unreserved,
"quantity_available": product.virtual_available,
"location_id": loc.id,
"wiz_id": self.id,
"default_code": product.default_code,
Expand All @@ -91,5 +96,6 @@ class StockReportQuantityByLocation(models.TransientModel):
quantity_on_hand = fields.Float(string="Qty On Hand")
quantity_reserved = fields.Float(string="Qty Reserved")
quantity_unreserved = fields.Float(string="Qty Unreserved")
quantity_available = fields.Float(string="Qty Available")
uom_id = fields.Many2one(comodel_name="uom.uom", string="Product UoM")
default_code = fields.Char("Internal Reference")
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
<field name="quantity_on_hand" />
<field name="quantity_reserved" />
<field name="quantity_unreserved" />
<field name="quantity_available" />
<field name="uom_id" groups="uom.group_uom" />
</tree>
</field>
Expand All @@ -75,6 +76,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
<field name="quantity_on_hand" type="measure" />
<field name="quantity_reserved" type="measure" />
<field name="quantity_unreserved" type="measure" />
<field name="quantity_available" type="measure" />
</pivot>
</field>
</record>
Expand Down

0 comments on commit 0b253a9

Please sign in to comment.