mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[FIX] stock_demand_estimate: division by zero in _compute_daily_qty
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Stock Demand Estimate",
|
"name": "Stock Demand Estimate",
|
||||||
"summary": "Allows to create demand estimates.",
|
"summary": "Allows to create demand estimates.",
|
||||||
"version": "11.0.1.0.0",
|
"version": "11.0.1.1.0",
|
||||||
"author": "Eficent, "
|
"author": "Eficent, "
|
||||||
"Odoo Community Association (OCA)",
|
"Odoo Community Association (OCA)",
|
||||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||||
|
|||||||
@@ -62,7 +62,10 @@ class StockDemandEstimate(models.Model):
|
|||||||
@api.depends('product_qty', 'date_range_id.days')
|
@api.depends('product_qty', 'date_range_id.days')
|
||||||
def _compute_daily_qty(self):
|
def _compute_daily_qty(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rec.daily_qty = rec.product_qty / rec.date_range_id.days
|
if rec.date_range_id.days:
|
||||||
|
rec.daily_qty = rec.product_qty / rec.date_range_id.days
|
||||||
|
else:
|
||||||
|
rec.daily_qty = 0.0
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('product_id', 'product_uom', 'product_uom_qty')
|
@api.depends('product_id', 'product_uom', 'product_uom_qty')
|
||||||
@@ -94,6 +97,7 @@ class StockDemandEstimate(models.Model):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def get_quantity_by_date_range(self, date_start, date_end):
|
def get_quantity_by_date_range(self, date_start, date_end):
|
||||||
|
"""To be used in other modules"""
|
||||||
# Check if the dates overlap with the period
|
# Check if the dates overlap with the period
|
||||||
period_date_start = fields.Date.from_string(
|
period_date_start = fields.Date.from_string(
|
||||||
self.date_range_id.date_start
|
self.date_range_id.date_start
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<field name="name">stock.demand.estimate.tree</field>
|
<field name="name">stock.demand.estimate.tree</field>
|
||||||
<field name="model">stock.demand.estimate</field>
|
<field name="model">stock.demand.estimate</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Stock Demand Estimate" editable="top">
|
<tree string="Stock Demand Estimate" editable="top" create="0">
|
||||||
<field name="date_range_id"/>
|
<field name="date_range_id"/>
|
||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
<field name="location_id"/>
|
<field name="location_id"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user