Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.0][IMP] mrp_multi_level: be able to group demand when generating supply proposals #345

Merged
merged 1 commit into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions mrp_multi_level/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@ To launch replenishment orders (moves, purchases, production orders...):
hand side gears in any record.
#. On the wizard, check everything is ok and click *Execute*.

Known issues / Roadmap
======================

* The functionality related to field *Nbr. Days* in products is not
functional for the time being. Please, stay tuned to future updates.

Changelog
=========

11.0.2.1.0 (2019-04-02)
~~~~~~~~~~~~~~~~~~~~~~~

* [IMP] Implement *Nbr. Days* functionality to be able to group demand when
generating supply proposals.
(`#345 <https://github.com/OCA/manufacture/pull/345>`_):

11.0.2.0.0 (2018-11-20)
~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
4 changes: 2 additions & 2 deletions mrp_multi_level/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# Copyright 2016-18 Eficent Business and IT Consulting Services S.L.
# Copyright 2016-19 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
'name': 'MRP Multi Level',
'version': '11.0.2.0.0',
'version': '11.0.2.1.0',
'development_status': 'Beta',
'license': 'AGPL-3',
'author': 'Ucamco, '
Expand Down
7 changes: 7 additions & 0 deletions mrp_multi_level/readme/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
11.0.2.1.0 (2019-04-02)
~~~~~~~~~~~~~~~~~~~~~~~

* [IMP] Implement *Nbr. Days* functionality to be able to group demand when
generating supply proposals.
(`#345 <https://github.com/OCA/manufacture/pull/345>`_):

11.0.2.0.0 (2018-11-20)
~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 0 additions & 2 deletions mrp_multi_level/readme/ROADMAP.rst

This file was deleted.

77 changes: 39 additions & 38 deletions mrp_multi_level/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -386,48 +386,48 @@ <h1>Key Features</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="id8">Configuration</a><ul>
<li><a class="reference internal" href="#mrp-areas" id="id9">MRP Areas</a></li>
<li><a class="reference internal" href="#product-mrp-area-parameters" id="id10">Product MRP Area Parameters</a></li>
<li><a class="reference internal" href="#configuration" id="id10">Configuration</a><ul>
<li><a class="reference internal" href="#mrp-areas" id="id11">MRP Areas</a></li>
<li><a class="reference internal" href="#product-mrp-area-parameters" id="id12">Product MRP Area Parameters</a></li>
</ul>
</li>
<li><a class="reference internal" href="#usage" id="id11">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id12">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#changelog" id="id13">Changelog</a><ul>
<li><a class="reference internal" href="#id1" id="id14">11.0.2.0.0 (2018-11-20)</a></li>
<li><a class="reference internal" href="#id3" id="id15">11.0.1.1.0 (2018-08-30)</a></li>
<li><a class="reference internal" href="#id5" id="id16">11.0.1.0.1 (2018-08-03)</a></li>
<li><a class="reference internal" href="#id7" id="id17">11.0.1.0.0 (2018-07-09)</a></li>
<li><a class="reference internal" href="#usage" id="id13">Usage</a></li>
<li><a class="reference internal" href="#changelog" id="id14">Changelog</a><ul>
<li><a class="reference internal" href="#id1" id="id15">11.0.2.1.0 (2019-04-02)</a></li>
<li><a class="reference internal" href="#id3" id="id16">11.0.2.0.0 (2018-11-20)</a></li>
<li><a class="reference internal" href="#id5" id="id17">11.0.1.1.0 (2018-08-30)</a></li>
<li><a class="reference internal" href="#id7" id="id18">11.0.1.0.1 (2018-08-03)</a></li>
<li><a class="reference internal" href="#id9" id="id19">11.0.1.0.0 (2018-07-09)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="id18">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id19">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id20">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id21">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id22">Maintainers</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id20">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id21">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id22">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id23">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id24">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#id8">Configuration</a></h2>
<h2><a class="toc-backref" href="#id10">Configuration</a></h2>
<div class="section" id="mrp-areas">
<h3><a class="toc-backref" href="#id9">MRP Areas</a></h3>
<h3><a class="toc-backref" href="#id11">MRP Areas</a></h3>
<ul class="simple">
<li>Go to <em>Manufacturing &gt; Configuration &gt; MRP Areas</em> and define or edit
any existing area. You can specify the working hours for every area.</li>
</ul>
</div>
<div class="section" id="product-mrp-area-parameters">
<h3><a class="toc-backref" href="#id10">Product MRP Area Parameters</a></h3>
<h3><a class="toc-backref" href="#id12">Product MRP Area Parameters</a></h3>
<ul class="simple">
<li>Go to <em>Manufacturing &gt; Master Data &gt; Product MRP Area Parameters</em> and set
the MRP parameters for a given product and area.</li>
</ul>
</div>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#id11">Usage</a></h2>
<h2><a class="toc-backref" href="#id13">Usage</a></h2>
<p>To manually run the MRP scheduler:</p>
<ol class="arabic simple">
<li>Go to <em>Manufacturing &gt; Operations &gt; Run MRP Multi Level</em>.</li>
Expand All @@ -442,17 +442,18 @@ <h2><a class="toc-backref" href="#id11">Usage</a></h2>
<li>On the wizard, check everything is ok and click <em>Execute</em>.</li>
</ol>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#id12">Known issues / Roadmap</a></h2>
<div class="section" id="changelog">
<h2><a class="toc-backref" href="#id14">Changelog</a></h2>
<div class="section" id="id1">
<h3><a class="toc-backref" href="#id15">11.0.2.1.0 (2019-04-02)</a></h3>
<ul class="simple">
<li>The functionality related to field <em>Nbr. Days</em> in products is not
functional for the time being. Please, stay tuned to future updates.</li>
<li>[IMP] Implement <em>Nbr. Days</em> functionality to be able to group demand when
generating supply proposals.
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/345">#345</a>):</li>
</ul>
</div>
<div class="section" id="changelog">
<h2><a class="toc-backref" href="#id13">Changelog</a></h2>
<div class="section" id="id1">
<h3><a class="toc-backref" href="#id14">11.0.2.0.0 (2018-11-20)</a></h3>
<div class="section" id="id3">
<h3><a class="toc-backref" href="#id16">11.0.2.0.0 (2018-11-20)</a></h3>
<ul class="simple">
<li>[REW] Refactor MRP Area.
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/322">#322</a>):<ul>
Expand All @@ -464,15 +465,15 @@ <h3><a class="toc-backref" href="#id14">11.0.2.0.0 (2018-11-20)</a></h3>
</li>
</ul>
</div>
<div class="section" id="id3">
<h3><a class="toc-backref" href="#id15">11.0.1.1.0 (2018-08-30)</a></h3>
<div class="section" id="id5">
<h3><a class="toc-backref" href="#id17">11.0.1.1.0 (2018-08-30)</a></h3>
<ul class="simple">
<li>[FIX] Consider <em>Qty Multiple</em> on product to propose the quantity to procure.
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/297">#297</a>)</li>
</ul>
</div>
<div class="section" id="id5">
<h3><a class="toc-backref" href="#id16">11.0.1.0.1 (2018-08-03)</a></h3>
<div class="section" id="id7">
<h3><a class="toc-backref" href="#id18">11.0.1.0.1 (2018-08-03)</a></h3>
<ul class="simple">
<li>[FIX] User and system locales doesn’t break MRP calculation.
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/290">#290</a>)</li>
Expand All @@ -481,40 +482,40 @@ <h3><a class="toc-backref" href="#id16">11.0.1.0.1 (2018-08-03)</a></h3>
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/290">#290</a>)</li>
</ul>
</div>
<div class="section" id="id7">
<h3><a class="toc-backref" href="#id17">11.0.1.0.0 (2018-07-09)</a></h3>
<div class="section" id="id9">
<h3><a class="toc-backref" href="#id19">11.0.1.0.0 (2018-07-09)</a></h3>
<ul class="simple">
<li>Start of the history.</li>
</ul>
</div>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#id18">Bug Tracker</a></h2>
<h2><a class="toc-backref" href="#id20">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/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/manufacture/issues/new?body=module:%20mrp_multi_level%0Aversion:%2011.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">
<h2><a class="toc-backref" href="#id19">Credits</a></h2>
<h2><a class="toc-backref" href="#id21">Credits</a></h2>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#id20">Authors</a></h3>
<h3><a class="toc-backref" href="#id22">Authors</a></h3>
<ul class="simple">
<li>Ucamco</li>
<li>Eficent</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#id21">Contributors</a></h3>
<h3><a class="toc-backref" href="#id23">Contributors</a></h3>
<ul class="simple">
<li>Wim Audenaert &lt;<a class="reference external" href="mailto:wim.audenaert&#64;ucamco.com">wim.audenaert&#64;ucamco.com</a>&gt;</li>
<li>Jordi Ballester &lt;<a class="reference external" href="mailto:jordi.ballester&#64;eficent.com">jordi.ballester&#64;eficent.com</a>&gt;</li>
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#64;eficent.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#id22">Maintainers</a></h3>
<h3><a class="toc-backref" href="#id24">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
Expand Down
57 changes: 54 additions & 3 deletions mrp_multi_level/tests/test_mrp_multi_level.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# Copyright 2018-19 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

Expand All @@ -17,6 +17,8 @@ def setUpClass(cls):
cls.mo_obj = cls.env['mrp.production']
cls.po_obj = cls.env['purchase.order']
cls.product_obj = cls.env['product.product']
cls.loc_obj = cls.env['stock.location']
cls.mrp_area_obj = cls.env['mrp.area']
cls.product_mrp_area_obj = cls.env['product.mrp.area']
cls.partner_obj = cls.env['res.partner']
cls.stock_picking_obj = cls.env['stock.picking']
Expand Down Expand Up @@ -45,6 +47,18 @@ def setUpClass(cls):
# Partner:
vendor1 = cls.partner_obj.create({'name': 'Vendor 1'})

# Create secondary location and MRP Area:
cls.sec_loc = cls.loc_obj.create({
'name': 'Test location',
'usage': 'internal',
'location_id': cls.wh.view_location_id.id,
})
cls.secondary_area = cls.mrp_area_obj.create({
'name': 'Test',
'warehouse_id': cls.wh.id,
'location_id': cls.sec_loc.id,
})

# Create products:
route_buy = cls.env.ref('purchase.route_warehouse0_buy').id
cls.prod_test = cls.product_obj.create({
Expand All @@ -59,6 +73,12 @@ def setUpClass(cls):
'product_id': cls.prod_test.id,
'mrp_area_id': cls.mrp_area.id,
})
# Parameters in secondary area with nbr_days set.
cls.product_mrp_area_obj.create({
'product_id': cls.prod_test.id,
'mrp_area_id': cls.secondary_area.id,
'mrp_nbr_days': 7,
})
cls.prod_min = cls.product_obj.create({
'name': 'Product with minimum order qty',
'type': 'product',
Expand Down Expand Up @@ -239,6 +259,8 @@ def setUpClass(cls):
qty += 70.0
cls._create_demand_estimate(
cls.prod_test, cls.stock_location, dr, qty)
cls._create_demand_estimate(
cls.prod_test, cls.sec_loc, dr, qty)

cls.mrp_multi_level_wiz.create({}).run_mrp_multi_level()

Expand Down Expand Up @@ -425,11 +447,13 @@ def test_05_moves_extra_info(self):

def test_06_demand_estimates(self):
"""Tests demand estimates integration."""
estimates = self.estimate_obj.search(
[('product_id', '=', self.prod_test.id)])
estimates = self.estimate_obj.search([
('product_id', '=', self.prod_test.id),
('location_id', '=', self.stock_location.id)])
self.assertEqual(len(estimates), 3)
moves = self.mrp_move_obj.search([
('product_id', '=', self.prod_test.id),
('mrp_area_id', '=', self.mrp_area.id),
])
# 3 weeks - 3 days in the past = 18 days of valid estimates:
moves_from_estimates = moves.filtered(lambda m: m.mrp_type == 'd')
Expand All @@ -440,6 +464,9 @@ def test_06_demand_estimates(self):
self.assertIn(-50.0, quantities) # 350 a week => 50.0 dayly:
actions = moves.filtered(lambda m: m.mrp_action == 'po')
self.assertEqual(len(actions), 18)
inventories = self.mrp_inventory_obj.search([
('mrp_area_id', '=', self.secondary_area.id)])
self.assertEqual(len(inventories), 18)

def test_07_procure_mo(self):
"""Test procurement wizard with MOs."""
Expand Down Expand Up @@ -483,5 +510,29 @@ def test_08_adjust_qty_to_order(self):
('product_mrp_area_id.product_id', '=', self.prod_multiple.id)])
self.assertEqual(mrp_inv_multiple.to_procure, 125)

def test_09_group_demand(self):
"""Test demand grouping functionality, `nbr_days`."""
estimates = self.estimate_obj.search([
('product_id', '=', self.prod_test.id),
('location_id', '=', self.sec_loc.id)])
self.assertEqual(len(estimates), 3)
moves = self.mrp_move_obj.search([
('product_id', '=', self.prod_test.id),
('mrp_area_id', '=', self.secondary_area.id),
])
# 3 weeks - 3 days in the past = 18 days of valid estimates:
moves_from_estimates = moves.filtered(lambda m: m.mrp_type == 'd')
self.assertEqual(len(moves_from_estimates), 18)
# 18 days of demand / 7 nbr_days = 2.57 => 3 supply moves expected.
supply_moves = moves.filtered(lambda m: m.mrp_type == 's')
self.assertEqual(len(supply_moves), 3)
quantities = supply_moves.mapped('mrp_qty')
week_1_expected = sum(moves_from_estimates[0:7].mapped('mrp_qty'))
self.assertIn(abs(week_1_expected), quantities)
week_2_expected = sum(moves_from_estimates[7:14].mapped('mrp_qty'))
self.assertIn(abs(week_2_expected), quantities)
week_3_expected = sum(moves_from_estimates[14:].mapped('mrp_qty'))
self.assertIn(abs(week_3_expected), quantities)

# TODO: test procure wizard: pos, multiple...
# TODO: test multiple destination IDS:...
Loading