[IMP] Remove zone location dependency, rely on warehouse only

This commit is contained in:
Denis Roussel
2023-07-13 14:02:27 +02:00
parent 1221fa1d44
commit 3348644c84
6 changed files with 9 additions and 24 deletions

View File

@@ -15,7 +15,6 @@
"product_abc_classification",
"product_abc_classification_sale_stock",
"product_route_mto",
"stock_location_zone",
],
"data": [
"security/stock_average_daily_sale_config.xml",

View File

@@ -87,9 +87,6 @@ class StockAverageDailySale(models.Model):
string="Daily Qty Standard Deviation", required=True
)
warehouse_id = fields.Many2one(comodel_name="stock.warehouse", required=True)
zone_location_id = fields.Many2one(
string="Location Zone", comodel_name="stock.location", index=True
)
qty_in_stock = fields.Float(
string="Quantity in stock",
digits="Product Unit of Measure",
@@ -187,7 +184,6 @@ class StockAverageDailySale(models.Model):
sm.product_id,
sm.product_uom_qty,
sl_src.warehouse_id,
sl_src.zone_location_id,
(avg(product_uom_qty) OVER pid
- (stddev_samp(product_uom_qty) OVER pid * cfg.standard_deviation_exclude_factor)
) as lower_bound,
@@ -220,7 +216,6 @@ class StockAverageDailySale(models.Model):
concat(warehouse_id, product_id)::integer as id,
product_id,
warehouse_id,
zone_location_id,
(avg(product_uom_qty) FILTER
(WHERE product_uom_qty BETWEEN lower_bound AND upper_bound OR standard_deviation = 0)
)::numeric AS average_qty_by_sale,
@@ -235,7 +230,7 @@ class StockAverageDailySale(models.Model):
config_id,
nrb_days_without_sat_sun
FROM deliveries_last
GROUP BY product_id, warehouse_id, zone_location_id, standard_deviation, nrb_days_without_sat_sun, date_from, date_to, config_id
GROUP BY product_id, warehouse_id, standard_deviation, nrb_days_without_sat_sun, date_from, date_to, config_id
),
-- Compute the stock by product in locations under stock
stock_qty AS (
@@ -277,7 +272,6 @@ class StockAverageDailySale(models.Model):
t.id,
t.product_id,
t.warehouse_id,
t.zone_location_id,
average_qty_by_sale,
average_daily_sales_count,
average_qty_by_sale * average_daily_sales_count as average_daily_qty,

View File

@@ -32,12 +32,6 @@ class StockAverageDailySaleConfig(models.Model):
),
readonly=True,
)
stock_location_kind = fields.Selection(
selection=lambda self: self.env["stock.location"]
._fields["location_kind"]
.selection,
default="zone",
)
period_name = fields.Selection(
string="Period analyzed unit",
selection=[

View File

@@ -26,7 +26,6 @@ class CommonAverageSaleTest:
cls.location_zone = cls.location_obj.create(
{
"name": "Zone Location",
"is_zone": True,
"location_id": cls.warehouse_0.lot_stock_id.id,
}
)

View File

@@ -54,7 +54,7 @@ class TestAverageSale(CommonAverageSaleTest, TransactionCase):
"nbr_sales": 1.0,
"average_qty_by_sale": 10.0,
"qty_in_stock": 40.0,
"zone_location_id": self.location_zone.id,
"warehouse_id": self.warehouse_0.id,
}
],
)
@@ -68,7 +68,7 @@ class TestAverageSale(CommonAverageSaleTest, TransactionCase):
"nbr_sales": 1.0,
"average_qty_by_sale": 12.0,
"qty_in_stock": 48.0,
"zone_location_id": self.location_zone.id,
"warehouse_id": self.warehouse_0.id,
}
],
)
@@ -128,7 +128,7 @@ class TestAverageSale(CommonAverageSaleTest, TransactionCase):
{
"nbr_sales": 3.0,
"qty_in_stock": 19.0,
"zone_location_id": self.location_zone.id,
"warehouse_id": self.warehouse_0.id,
}
],
)
@@ -144,7 +144,7 @@ class TestAverageSale(CommonAverageSaleTest, TransactionCase):
"nbr_sales": 2.0,
"average_qty_by_sale": 8.0,
"qty_in_stock": 44.0,
"zone_location_id": self.location_zone.id,
"warehouse_id": self.warehouse_0.id,
}
],
)

View File

@@ -8,7 +8,7 @@
<field name="arch" type="xml">
<search string="Search Average Daily Sale">
<field name="product_id" />
<field name="zone_location_id" />
<field name="warehouse_id" />
<separator />
<filter
string="Can be Sold"
@@ -28,10 +28,10 @@
/>
<group expand='0' string='Group by...'>
<filter
string="Zone"
name="group_by_zone"
string="Warehouse"
name="group_by_warehouse"
domain="[]"
context="{'group_by': 'zone_location_id'}"
context="{'group_by': 'warehouse_id'}"
/>
</group>
</search>
@@ -56,7 +56,6 @@
<field name="date_from" />
<field name="date_to" />
<field name="warehouse_id" />
<field name="zone_location_id" />
</tree>
</field>
</record>