mirror of
https://github.com/OCA/stock-logistics-reporting.git
synced 2025-02-16 17:13:21 +02:00
- Make use of create_multi to speed up.
- Add an option in the wizard 'Quantity > 0' to speed up the report
This commit is contained in:
committed by
Christopher Ormaza
parent
f89089fd10
commit
2fcb7ec412
@@ -10,6 +10,11 @@ class StockReportByLocationPrepare(models.TransientModel):
|
||||
location_ids = fields.Many2many(
|
||||
comodel_name="stock.location", string="Locations", required=True
|
||||
)
|
||||
with_quantity = fields.Boolean(
|
||||
string="Quantity > 0",
|
||||
default=True,
|
||||
help="Show only the products that have existing quantity on hand",
|
||||
)
|
||||
|
||||
def open(self):
|
||||
self.ensure_one()
|
||||
@@ -42,8 +47,11 @@ class StockReportByLocationPrepare(models.TransientModel):
|
||||
for quant_group in quant_groups
|
||||
}
|
||||
products = self.env["product.product"].search([("type", "=", "product")])
|
||||
vals_list = []
|
||||
for product in products:
|
||||
r = self.env["stock.report.quantity.by.location"].create(
|
||||
quantity = mapping.get(product.id, 0.0)
|
||||
if (self.with_quantity and quantity) or not self.with_quantity:
|
||||
vals_list.append(
|
||||
{
|
||||
"product_id": product.id,
|
||||
"product_category_id": product.categ_id.id,
|
||||
@@ -54,8 +62,8 @@ class StockReportByLocationPrepare(models.TransientModel):
|
||||
"default_code": product.default_code,
|
||||
}
|
||||
)
|
||||
recs.append(r.id)
|
||||
return recs
|
||||
recs = self.env["stock.report.quantity.by.location"].create(vals_list)
|
||||
return recs.ids
|
||||
|
||||
|
||||
class StockReportQuantityByLocation(models.TransientModel):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
Copyright 2019 Eficent Business and IT Consulting Services, S.L.
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
@@ -11,37 +11,54 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
<form>
|
||||
<group>
|
||||
<group>
|
||||
<field name="location_ids" widget="many2many_tags"/>
|
||||
<field name="location_ids" widget="many2many_tags" />
|
||||
</group>
|
||||
<group>
|
||||
<field name="with_quantity" />
|
||||
</group>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="open" string="Retrieve the Inventory Quantities" type="object" class="btn-primary"/>
|
||||
<button
|
||||
name="open"
|
||||
string="Retrieve the Inventory Quantities"
|
||||
type="object"
|
||||
class="btn-primary"
|
||||
/>
|
||||
<button string="Cancel" class="btn-default" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_stock_report_quantity_by_location_prepare" model="ir.actions.act_window">
|
||||
<record
|
||||
id="action_stock_report_quantity_by_location_prepare"
|
||||
model="ir.actions.act_window"
|
||||
>
|
||||
<field name="name">Inventory By Location</field>
|
||||
<field name="res_model">stock.report.quantity.by.location.prepare</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="stock_report_quantity_by_location_prepare_form_view"/>
|
||||
<field
|
||||
name="view_id"
|
||||
ref="stock_report_quantity_by_location_prepare_form_view"
|
||||
/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
<menuitem id="menu_quantity_by_location" name="Inventory by Location"
|
||||
<menuitem
|
||||
id="menu_quantity_by_location"
|
||||
name="Inventory by Location"
|
||||
parent="stock.menu_warehouse_report"
|
||||
action="action_stock_report_quantity_by_location_prepare"
|
||||
groups="stock.group_stock_manager"/>
|
||||
groups="stock.group_stock_manager"
|
||||
/>
|
||||
|
||||
<record id="stock_report_quantity_by_location_tree_view" model="ir.ui.view">
|
||||
<field name="name">Stock Report Quantity By Location Form</field>
|
||||
<field name="model">stock.report.quantity.by.location</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="product_id"/>
|
||||
<field name="location_id"/>
|
||||
<field name="quantity"/>
|
||||
<field name="uom_id" groups="uom.group_uom"/>
|
||||
<field name="product_id" />
|
||||
<field name="location_id" />
|
||||
<field name="quantity" />
|
||||
<field name="uom_id" groups="uom.group_uom" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -51,9 +68,9 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
<field name="model">stock.report.quantity.by.location</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot string="Stock by Location" disable_linking="True">
|
||||
<field name="product_id" type="row"/>
|
||||
<field name="location_id" type="col"/>
|
||||
<field name="quantity" type="measure"/>
|
||||
<field name="product_id" type="row" />
|
||||
<field name="location_id" type="col" />
|
||||
<field name="quantity" type="measure" />
|
||||
</pivot>
|
||||
</field>
|
||||
</record>
|
||||
@@ -63,13 +80,23 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
<field name="model">stock.report.quantity.by.location</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Stock Report Quantity by Location">
|
||||
<field name="product_id"/>
|
||||
<field name="default_code"/>
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="product_category_id"/>
|
||||
<filter name="quantity_gt_zero" string="Quantity > 0" domain="[('quantity', '>', '0.0')]"/>
|
||||
<field name="product_id" />
|
||||
<field name="default_code" />
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations" />
|
||||
<field name="product_category_id" />
|
||||
<filter
|
||||
name="quantity_gt_zero"
|
||||
string="Quantity > 0"
|
||||
domain="[('quantity', '>', '0.0')]"
|
||||
/>
|
||||
<group expand="0" string="Group By">
|
||||
<filter name="location" string="Location" domain="[]" context="{'group_by':'location_id'}" help="Group by Location"/>
|
||||
<filter
|
||||
name="location"
|
||||
string="Location"
|
||||
domain="[]"
|
||||
context="{'group_by':'location_id'}"
|
||||
help="Group by Location"
|
||||
/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user