Merge pull request #416 from Eficent/9.0-fix-stock_demand_estimate

[9.0][FIX] stock_demand_estimate
This commit is contained in:
Lois Rilo
2018-05-10 12:10:03 +02:00
committed by GitHub
3 changed files with 7 additions and 3 deletions

View File

@@ -5,7 +5,7 @@
{
"name": "Stock Demand Estimate",
"summary": "Allows to create demand estimates.",
"version": "9.0.1.0.0",
"version": "9.0.1.1.0",
"author": "Eficent, "
"Odoo Community Association (OCA)",
"website": "https://www.odoo-community.org",

View File

@@ -31,7 +31,10 @@ class StockDemandEstimate(models.Model):
@api.multi
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
date_range_id = fields.Many2one(
comodel_name="date.range",
@@ -69,6 +72,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

@@ -7,7 +7,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"/>