mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[13.0][MIG] stock_demand_estimate
This commit is contained in:
@@ -7,20 +7,20 @@ Stock Demand Estimate
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
|
||||
:target: https://odoo-community.org/page/development-status
|
||||
:alt: Beta
|
||||
:alt: Production/Stable
|
||||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_demand_estimate
|
||||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_demand_estimate
|
||||
:alt: OCA/stock-logistics-warehouse
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_demand_estimate
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_demand_estimate
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/153/12.0
|
||||
:target: https://runbot.odoo-community.org/runbot/153/13.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
@@ -41,7 +41,7 @@ Bug Tracker
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_demand_estimate%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_demand_estimate%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
@@ -72,6 +72,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_demand_estimate>`_ project on GitHub.
|
||||
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_demand_estimate>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# Copyright 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# Copyright 2016-20 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
{
|
||||
"name": "Stock Demand Estimate",
|
||||
"summary": "Allows to create demand estimates.",
|
||||
"version": "12.0.2.0.1",
|
||||
"version": "13.0.1.0.0",
|
||||
"author": "ForgeFlow, Odoo Community Association (OCA)",
|
||||
"development_status": "Production/Stable",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
"category": "Warehouse Management",
|
||||
"depends": ["stock"],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# Copyright 2016-20 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# Copyright 2016 Aleph Objects, Inc. (https://www.alephobjects.com/)
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
@@ -7,8 +7,6 @@ from datetime import date, timedelta
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
from odoo.addons import decimal_precision as dp
|
||||
|
||||
|
||||
class StockDemandEstimate(models.Model):
|
||||
_name = "stock.demand.estimate"
|
||||
@@ -33,9 +31,7 @@ class StockDemandEstimate(models.Model):
|
||||
location_id = fields.Many2one(
|
||||
comodel_name="stock.location", string="Location", required=True
|
||||
)
|
||||
product_uom_qty = fields.Float(
|
||||
string="Quantity", digits=dp.get_precision("Product Unit of Measure")
|
||||
)
|
||||
product_uom_qty = fields.Float(string="Quantity", digits="Product Unit of Measure")
|
||||
product_qty = fields.Float(
|
||||
"Real Quantity",
|
||||
compute="_compute_product_quantity",
|
||||
@@ -50,12 +46,9 @@ class StockDemandEstimate(models.Model):
|
||||
comodel_name="res.company",
|
||||
string="Company",
|
||||
required=True,
|
||||
default=lambda self: self.env["res.company"]._company_default_get(
|
||||
"stock.demand.estimate"
|
||||
),
|
||||
default=lambda self: self.env.company,
|
||||
)
|
||||
|
||||
@api.multi
|
||||
@api.depends("manual_duration", "manual_date_from", "manual_date_to")
|
||||
def _compute_dates(self):
|
||||
today = date.today()
|
||||
@@ -71,7 +64,6 @@ class StockDemandEstimate(models.Model):
|
||||
rec.date_to = rec.date_from + timedelta(days=1)
|
||||
rec.duration = 2
|
||||
|
||||
@api.multi
|
||||
@api.depends("product_qty", "duration")
|
||||
def _compute_daily_qty(self):
|
||||
for rec in self:
|
||||
@@ -80,7 +72,6 @@ class StockDemandEstimate(models.Model):
|
||||
else:
|
||||
rec.daily_qty = 0.0
|
||||
|
||||
@api.multi
|
||||
@api.depends("product_id", "product_uom", "product_uom_qty")
|
||||
def _compute_product_quantity(self):
|
||||
for rec in self:
|
||||
@@ -101,15 +92,11 @@ class StockDemandEstimate(models.Model):
|
||||
)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def name_get(self):
|
||||
res = []
|
||||
for rec in self:
|
||||
name = "{} - {}: {} - {}".format(
|
||||
rec.date_from,
|
||||
rec.date_to,
|
||||
rec.product_id.name,
|
||||
rec.location_id.name,
|
||||
rec.date_from, rec.date_to, rec.product_id.name, rec.location_id.name
|
||||
)
|
||||
res.append((rec.id, name))
|
||||
return res
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||
<meta name="generator" content="Docutils 0.15.2: http://docutils.sourceforge.net/" />
|
||||
<title>Stock Demand Estimate</title>
|
||||
<style type="text/css">
|
||||
|
||||
@@ -367,7 +367,7 @@ ul.auto-toc {
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_demand_estimate"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_demand_estimate"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_demand_estimate"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_demand_estimate"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module allows to create demand estimates for a given product and
|
||||
location, on configurable time periods.</p>
|
||||
<p>The module does not provide in itself any specific usage of the estimates.</p>
|
||||
@@ -388,7 +388,7 @@ location, on configurable time periods.</p>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_demand_estimate%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_demand_estimate%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
@@ -413,7 +413,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_demand_estimate">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_demand_estimate">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -124,3 +124,44 @@ class TestStockDemandEstimate(SavepointCase):
|
||||
# Get exact period:
|
||||
res = estimate.get_quantity_by_date_range(estimate.date_from, estimate.date_to)
|
||||
self.assertEqual(res, 100)
|
||||
# Ask for interval out fo the estimate's:
|
||||
res = estimate.get_quantity_by_date_range(
|
||||
date.today(), date.today() + td(days=8)
|
||||
)
|
||||
self.assertEqual(res, 0)
|
||||
|
||||
def test_04_name_get(self):
|
||||
date_from = date.today() + td(days=10)
|
||||
estimate = self.estimate_model.create(
|
||||
{
|
||||
"product_id": self.product_1.id,
|
||||
"location_id": self.location.id,
|
||||
"manual_date_from": date_from,
|
||||
"manual_duration": False, # to test else case in _compute_dates.
|
||||
"product_uom_qty": 500.0,
|
||||
}
|
||||
)
|
||||
res = estimate.name_get()
|
||||
self.assertEqual(len(res), 1)
|
||||
rec_id, name_get = res[0]
|
||||
self.assertEqual(estimate.id, rec_id)
|
||||
self.assertIn(self.product_1.name, name_get)
|
||||
|
||||
def test_05_onchange_methods(self):
|
||||
date_from = date.today() + td(days=10)
|
||||
date_to = date.today() + td(days=19)
|
||||
estimate = self.estimate_model.new(
|
||||
{
|
||||
"product_id": self.product_1.id,
|
||||
"location_id": self.location.id,
|
||||
"manual_date_from": date_from,
|
||||
"manual_date_to": date_to,
|
||||
"product_uom_qty": 500.0,
|
||||
}
|
||||
)
|
||||
estimate._onchange_manual_date_to()
|
||||
self.assertEqual(estimate.manual_duration, 10)
|
||||
# Change duration manually:
|
||||
estimate.manual_duration = 5
|
||||
estimate._onchange_manual_duration()
|
||||
self.assertEqual(estimate.manual_date_to, date_from + td(days=4))
|
||||
|
||||
@@ -77,7 +77,6 @@
|
||||
<field name="name">Stock Demand Estimates</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">stock.demand.estimate</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form,pivot</field>
|
||||
<field name="search_view_id"
|
||||
ref="stock_demand_estimate_view_search"/>
|
||||
|
||||
Reference in New Issue
Block a user