[FIX] stock_demand_estimate: division by zero in _compute_daily_qty

This commit is contained in:
mreficent
2018-04-19 15:55:18 +02:00
committed by davidborromeo
parent 334a5d6967
commit 6ce7dc7854
3 changed files with 7 additions and 3 deletions

View File

@@ -4,7 +4,7 @@
{
"name": "Stock Demand Estimate",
"summary": "Allows to create demand estimates.",
"version": "11.0.1.0.0",
"version": "11.0.1.1.0",
"author": "Eficent, "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",

View File

@@ -62,7 +62,10 @@ class StockDemandEstimate(models.Model):
@api.depends('product_qty', 'date_range_id.days')
def _compute_daily_qty(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.depends('product_id', 'product_uom', 'product_uom_qty')
@@ -94,6 +97,7 @@ class StockDemandEstimate(models.Model):
@api.model
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
period_date_start = fields.Date.from_string(
self.date_range_id.date_start

View File

@@ -6,7 +6,7 @@
<field name="name">stock.demand.estimate.tree</field>
<field name="model">stock.demand.estimate</field>
<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="product_id"/>
<field name="location_id"/>