mirror of
https://github.com/OCA/stock-logistics-reporting.git
synced 2025-02-16 17:13:21 +02:00
[IMP] stock_average_daily_sale: Improve module helps / change field name to recommended_qty
This commit is contained in:
committed by
twalter-c2c
parent
bb11b7c3dc
commit
1b017daba7
@@ -31,15 +31,23 @@ class StockAverageDailySale(models.Model):
|
||||
selection=ABC_SELECTION, required=True, readonly=True, index=True
|
||||
)
|
||||
average_daily_sales_count = fields.Float(
|
||||
required=True, digits="Product Unit of Measure"
|
||||
required=True,
|
||||
digits="Product Unit of Measure",
|
||||
help="How much deliveries on average for this product on the period. "
|
||||
"The spikes are excluded from the average computation.",
|
||||
)
|
||||
average_qty_by_sale = fields.Float(
|
||||
required=True, digits="Product Unit of Measure", help="Average Daily Sales Qty"
|
||||
required=True,
|
||||
digits="Product Unit of Measure",
|
||||
help="The quantity "
|
||||
"delivered on average for one delivery of this product on the period. "
|
||||
"The spikes are excluded from the average computation.",
|
||||
)
|
||||
average_daily_qty = fields.Float(
|
||||
digits="Product Unit of Measure",
|
||||
required=True,
|
||||
help="The average daily qty sold",
|
||||
help="The quantity delivered on average on one day for this product on "
|
||||
"the period. The spikes are excluded from the average computation.",
|
||||
)
|
||||
config_id = fields.Many2one(
|
||||
string="Stock Average Daily Sale Configuration",
|
||||
@@ -54,27 +62,23 @@ class StockAverageDailySale(models.Model):
|
||||
store=True,
|
||||
index=True,
|
||||
)
|
||||
nbr_sales = fields.Integer(string="Number of Sales", required=True)
|
||||
nbr_sales = fields.Integer(
|
||||
string="Number of Sales",
|
||||
required=True,
|
||||
help="The total amount of deliveries for this product over the complete period",
|
||||
)
|
||||
product_id = fields.Many2one(
|
||||
comodel_name="product.product", string="Product", required=True, index=True
|
||||
)
|
||||
safety = fields.Float(
|
||||
required=True,
|
||||
help="daily standard deviation * safety factor * sqrt(nbr days into period "
|
||||
"without saturday and sunday",
|
||||
help="Safety stock to cover the variability of the quantity delivered "
|
||||
"each day. Formula: daily standard deviation * safety factor * sqrt(nbr days in the period)",
|
||||
)
|
||||
safety_bin_min_qty = fields.Float(
|
||||
recommended_qty = fields.Float(
|
||||
required=True,
|
||||
digits="Product Unit of Measure",
|
||||
help="Minimal safety qty into a bin location computed as: "
|
||||
"average daily qty * number days in stock * safety",
|
||||
)
|
||||
safety_bin_min_qty_old = fields.Float(
|
||||
required=True,
|
||||
digits="Product Unit of Measure",
|
||||
help="Minimal value for the safety qty. Computed as: "
|
||||
"number days in stock * GREATEST(average daily sales count, 1) * "
|
||||
"(average qty by sale + (stddev * safety factor))",
|
||||
help="Minimal recommended quantity in stock. Formula: average daily qty * number days in stock + safety",
|
||||
)
|
||||
sale_ok = fields.Boolean(
|
||||
string="Can be Sold",
|
||||
@@ -292,7 +296,7 @@ class StockAverageDailySale(models.Model):
|
||||
GREATEST(
|
||||
(cfg.number_days_qty_in_stock * average_qty_by_sale * average_daily_sales_count) + (ds.daily_standard_deviation * cfg.safety_factor * sqrt(nrb_days_without_sat_sun)),
|
||||
(cfg.number_days_qty_in_stock * average_qty_by_sale)
|
||||
) as safety_bin_min_qty
|
||||
) as recommended_qty
|
||||
FROM averages t
|
||||
JOIN daily_standard_deviation ds on ds.id= t.id
|
||||
JOIN stock_average_daily_sale_config cfg on cfg.id = t.config_id
|
||||
|
||||
@@ -55,6 +55,7 @@ class TestAverageSale(CommonAverageSaleTest, TransactionCase):
|
||||
"nbr_sales": 1.0,
|
||||
"average_qty_by_sale": 10.0,
|
||||
"qty_in_stock": 40.0,
|
||||
"recommended_qty": 20.0,
|
||||
"warehouse_id": self.warehouse_0.id,
|
||||
}
|
||||
],
|
||||
@@ -69,6 +70,7 @@ class TestAverageSale(CommonAverageSaleTest, TransactionCase):
|
||||
"nbr_sales": 1.0,
|
||||
"average_qty_by_sale": 12.0,
|
||||
"qty_in_stock": 48.0,
|
||||
"recommended_qty": 24.0,
|
||||
"warehouse_id": self.warehouse_0.id,
|
||||
}
|
||||
],
|
||||
@@ -133,6 +135,7 @@ class TestAverageSale(CommonAverageSaleTest, TransactionCase):
|
||||
}
|
||||
],
|
||||
)
|
||||
self.assertAlmostEqual(20.67, avg_product_1.recommended_qty, places=2)
|
||||
self.assertAlmostEqual(10.33, avg_product_1.average_qty_by_sale, places=2)
|
||||
|
||||
avg_product_2 = self.env["stock.average.daily.sale"].search(
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<field name="standard_deviation" />
|
||||
<field name="daily_standard_deviation" />
|
||||
<field name="safety" />
|
||||
<field name="safety_bin_min_qty" />
|
||||
<field name="recommended_qty" />
|
||||
<field name="nbr_sales" />
|
||||
<field name="qty_in_stock" />
|
||||
<field name="date_from" />
|
||||
|
||||
Reference in New Issue
Block a user