Merge PR #494 into 12.0

Signed-off-by LoisRForgeFlow
This commit is contained in:
OCA-git-bot
2020-04-09 11:17:27 +00:00
26 changed files with 578 additions and 178 deletions

View File

@@ -82,6 +82,46 @@ To launch replenishment orders (moves, purchases, production orders...):
Changelog
=========
12.0.2.0.0 (2020-03-31)
~~~~~~~~~~~~~~~~~~~~~~~
* Improving the management of planned orders:
* Add menu entry for planned orders
* Add button to navigate from planned orders to linked manufacturing orders
* Add action to convert planned orders to fixed
* When changing the due date in a planned order the release date is recomputed
* [IMP] Minor changes"
(`#470 <https://github.com/OCA/manufacture/pull/470>`_).
* Planned Order release and due date become required.
* Add button to Product MRP Area to update MOQ from Supplier Info.
* Link Manufacturing Orders with Planned Orders.
* Allow Mrp Inventory Procure Wizard to be used from other models.
* Make MRP Inventory creation more extensible.
* Main Supplier computation (v13 requires explicit False definitions)
* [IMP] Minor changes
(`#468 <https://github.com/OCA/manufacture/pull/468>`_).
* Planned Orders become fixed on manual creation by default
* Released Quantity becomes readonly
* Add product reference if Planned Order name is not defined on bom explosion
* [FIX] Minor changes
(`#469 <https://github.com/OCA/manufacture/pull/469>`_).
* Fix Main supplier computation in multi company
* Drop Triplicated field in search view
* [IMP] Minor changes
(`#463 <https://github.com/OCA/manufacture/pull/463>`_).
* Show supply method on MRP Inventory
* Allow no-MRP users to look into Products
12.0.1.0.0 (2019-08-05)
~~~~~~~~~~~~~~~~~~~~~~~
@@ -158,14 +198,15 @@ Authors
~~~~~~~
* Ucamco
* Eficent
* ForgeFlow
Contributors
~~~~~~~~~~~~
* Wim Audenaert <wim.audenaert@ucamco.com>
* Jordi Ballester <jordi.ballester@eficent.com>
* Lois Rilo <lois.rilo@eficent.com>
* Jordi Ballester <jordi.ballester@forgeflow.com>
* Lois Rilo <lois.rilo@forgeflow.com>
* Héctor Villarreal <hector.villarreal@forgeflow.com>
Maintainers
~~~~~~~~~~~
@@ -180,16 +221,16 @@ 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.
.. |maintainer-jbeficent| image:: https://github.com/jbeficent.png?size=40px
:target: https://github.com/jbeficent
:alt: jbeficent
.. |maintainer-lreficent| image:: https://github.com/lreficent.png?size=40px
:target: https://github.com/lreficent
:alt: lreficent
.. |maintainer-JordiBForgeFlow| image:: https://github.com/JordiBForgeFlow.png?size=40px
:target: https://github.com/JordiBForgeFlow
:alt: JordiBForgeFlow
.. |maintainer-LoisRForgeFlow| image:: https://github.com/LoisRForgeFlow.png?size=40px
:target: https://github.com/LoisRForgeFlow
:alt: LoisRForgeFlow
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-jbeficent| |maintainer-lreficent|
|maintainer-JordiBForgeFlow| |maintainer-LoisRForgeFlow|
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/12.0/mrp_multi_level>`_ project on GitHub.

View File

@@ -1,5 +1,5 @@
# Copyright 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# Copyright 2016-19 Eficent Business and IT Consulting Services S.L.
# Copyright 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
@@ -8,9 +8,9 @@
'development_status': 'Beta',
'license': 'LGPL-3',
'author': 'Ucamco, '
'Eficent, '
'ForgeFlow, '
'Odoo Community Association (OCA)',
'maintainers': ['jbeficent', 'lreficent'],
"maintainers": ["JordiBForgeFlow", "LoisRForgeFlow"],
'summary': 'Adds an MRP Scheduler',
'website': 'https://github.com/OCA/manufacture',
'category': 'Manufacturing',
@@ -20,19 +20,20 @@
'mrp_warehouse_calendar',
],
'data': [
'security/mrp_multi_level_security.xml',
'security/ir.model.access.csv',
'views/mrp_area_views.xml',
'views/product_product_views.xml',
'views/product_template_views.xml',
'views/product_mrp_area_views.xml',
'views/stock_location_views.xml',
'wizards/mrp_inventory_procure_views.xml',
'views/mrp_inventory_views.xml',
'wizards/mrp_multi_level_views.xml',
'views/mrp_menuitem.xml',
'data/mrp_multi_level_cron.xml',
'data/mrp_area_data.xml',
"security/mrp_multi_level_security.xml",
"security/ir.model.access.csv",
"views/mrp_area_views.xml",
"views/product_product_views.xml",
"views/product_template_views.xml",
"views/product_mrp_area_views.xml",
"views/stock_location_views.xml",
"wizards/mrp_inventory_procure_views.xml",
"views/mrp_inventory_views.xml",
"views/mrp_planned_order_views.xml",
"wizards/mrp_multi_level_views.xml",
"views/mrp_menuitem.xml",
"data/mrp_multi_level_cron.xml",
"data/mrp_area_data.xml",
],
'demo': [
'demo/product_category_demo.xml',

View File

@@ -1,4 +1,4 @@
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
# Copyright 2019 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
import logging
from odoo import api, SUPERUSER_ID

View File

@@ -6,3 +6,5 @@ from . import mrp_move
from . import mrp_planned_order
from . import mrp_inventory
from . import product_mrp_area
from . import stock_rule
from . import mrp_production

View File

@@ -1,5 +1,5 @@
# © 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# © 2016-19 Eficent Business and IT Consulting Services S.L.
# © 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
# - Jordi Ballester Alomar <jordi.ballester@eficent.com>
# - Lois Rilo Antelo <lois.rilo@eficent.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

View File

@@ -1,5 +1,5 @@
# © 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# Copyright 2016-19 Eficent Business and IT Consulting Services S.L.
# Copyright 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
# - Jordi Ballester Alomar <jordi.ballester@eficent.com>
# - Lois Rilo Antelo <lois.rilo@eficent.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
@@ -67,6 +67,12 @@ class MrpInventory(models.Model):
inverse_name="mrp_inventory_id",
readonly=True,
)
supply_method = fields.Selection(
string="Supply Method",
related="product_mrp_area_id.supply_method",
readonly=True,
store=True,
)
@api.multi
def _compute_uom_id(self):

View File

@@ -1,5 +1,5 @@
# © 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# © 2016-18 Eficent Business and IT Consulting Services S.L.
# © 2016-18 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import models, fields

View File

@@ -1,8 +1,9 @@
# Copyright 2019 Eficent Business and IT Consulting Services S.L.
# Copyright 2019 ForgeFlow S.L. (https://www.forgeflow.com)
# - Lois Rilo Antelo <lois.rilo@eficent.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from datetime import timedelta
from odoo import models, fields
from odoo import api, fields, models
class MrpPlannedOrder(models.Model):
@@ -37,15 +38,15 @@ class MrpPlannedOrder(models.Model):
readonly=True,
)
order_release_date = fields.Date(
string="Release Date",
help="Order release date planned by MRP.",
string="Release Date", help="Order release date planned by MRP.", required=True
)
due_date = fields.Date(
string="Due Date",
help="Date in which the supply must have been completed.",
required=True,
)
qty_released = fields.Float()
fixed = fields.Boolean()
qty_released = fields.Float(readonly=True)
fixed = fields.Boolean(default=True)
mrp_qty = fields.Float(string="Quantity")
mrp_move_down_ids = fields.Many2many(
comodel_name="mrp.move",
@@ -68,3 +69,38 @@ class MrpPlannedOrder(models.Model):
comodel_name="mrp.inventory",
ondelete="set null",
)
mrp_production_ids = fields.One2many(
"mrp.production", "planned_order_id", string="Manufacturing Orders"
)
mo_count = fields.Integer(compute="_compute_mrp_production_count")
def _compute_mrp_production_count(self):
for rec in self:
rec.mo_count = len(rec.mrp_production_ids)
@api.onchange("due_date")
def _onchange_due_date(self):
if self.due_date:
if self.product_mrp_area_id.mrp_lead_time:
calendar = self.mrp_area_id.calendar_id
if calendar:
dt = fields.Datetime.from_string(self.due_date)
res = calendar.plan_days(
-1 * (self.product_mrp_area_id.mrp_lead_time + 1), dt
)
self.order_release_date = res.date()
else:
self.order_release_date = fields.Date.from_string(
self.due_date
) - timedelta(days=self.product_mrp_area_id.mrp_lead_time)
def action_toggle_fixed(self):
for rec in self:
rec.fixed = not rec.fixed
def action_open_linked_mrp_production(self):
action = self.env.ref("mrp.mrp_production_action")
result = action.read()[0]
result["context"] = {}
result["domain"] = "[('id','in',%s)]" % self.mrp_production_ids.ids
return result

View File

@@ -0,0 +1,12 @@
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# - Héctor Villarreal <hector.villarreal@forgeflow.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import fields, models
class MrpProduction(models.Model):
""" Manufacturing Orders """
_inherit = "mrp.production"
planned_order_id = fields.Many2one(comodel_name="mrp.planned.order")

View File

@@ -1,5 +1,5 @@
# Copyright 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# Copyright 2016-19 Eficent Business and IT Consulting Services S.L.
# Copyright 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
# - Jordi Ballester Alomar <jordi.ballester@eficent.com>
# - Lois Rilo Antelo <lois.rilo@eficent.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
@@ -190,9 +190,14 @@ class ProductMRPArea(models.Model):
and (not r.company_id or r.company_id == rec.company_id)
)
if not suppliers:
rec.main_supplierinfo_id = False
rec.main_supplier_id = False
continue
rec.main_supplierinfo_id = suppliers[0]
rec.main_supplier_id = suppliers[0].name
for rec in self.filtered(lambda r: r.supply_method != "buy"):
rec.main_supplierinfo_id = False
rec.main_supplier_id = False
@api.multi
def _adjust_qty_to_order(self, qty_to_order):
@@ -209,3 +214,9 @@ class ProductMRPArea(models.Model):
self.mrp_maximum_order_qty:
return self.mrp_maximum_order_qty
return qty_to_order
def update_min_qty_from_main_supplier(self):
for rec in self.filtered(
lambda r: r.main_supplierinfo_id and r.supply_method == "buy"
):
rec.mrp_minimum_order_qty = rec.main_supplierinfo_id.min_qty

View File

@@ -1,5 +1,5 @@
# Copyright 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# Copyright 2016-18 Eficent Business and IT Consulting Services S.L.
# Copyright 2016-18 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
import ast
from odoo import api, fields, models

View File

@@ -1,4 +1,4 @@
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# Copyright 2018 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
import ast
from odoo import api, fields, models

View File

@@ -1,5 +1,5 @@
# © 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# © 2016 Eficent Business and IT Consulting Services S.L.
# © 2016 ForgeFlow S.L. (https://www.forgeflow.com)
# - Jordi Ballester Alomar <jordi.ballester@eficent.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

View File

@@ -0,0 +1,33 @@
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
# - Héctor Villarreal <hector.villarreal@forgeflow.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import models
class StockRule(models.Model):
_inherit = "stock.rule"
def _prepare_mo_vals(
self,
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
values,
bom,
):
res = super()._prepare_mo_vals(
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
values,
bom,
)
if "planned_order_id" in values:
res["planned_order_id"] = values["planned_order_id"]
return res

View File

@@ -1,3 +1,4 @@
* Wim Audenaert <wim.audenaert@ucamco.com>
* Jordi Ballester <jordi.ballester@eficent.com>
* Lois Rilo <lois.rilo@eficent.com>
* Jordi Ballester <jordi.ballester@forgeflow.com>
* Lois Rilo <lois.rilo@forgeflow.com>
* Héctor Villarreal <hector.villarreal@forgeflow.com>

View File

@@ -1,3 +1,43 @@
12.0.2.0.0 (2020-03-31)
~~~~~~~~~~~~~~~~~~~~~~~
* Improving the management of planned orders:
* Add menu entry for planned orders
* Add button to navigate from planned orders to linked manufacturing orders
* Add action to convert planned orders to fixed
* When changing the due date in a planned order the release date is recomputed
* [IMP] Minor changes"
(`#470 <https://github.com/OCA/manufacture/pull/470>`_).
* Planned Order release and due date become required.
* Add button to Product MRP Area to update MOQ from Supplier Info.
* Link Manufacturing Orders with Planned Orders.
* Allow Mrp Inventory Procure Wizard to be used from other models.
* Make MRP Inventory creation more extensible.
* Main Supplier computation (v13 requires explicit False definitions)
* [IMP] Minor changes
(`#468 <https://github.com/OCA/manufacture/pull/468>`_).
* Planned Orders become fixed on manual creation by default
* Released Quantity becomes readonly
* Add product reference if Planned Order name is not defined on bom explosion
* [FIX] Minor changes
(`#469 <https://github.com/OCA/manufacture/pull/469>`_).
* Fix Main supplier computation in multi company
* Drop Triplicated field in search view
* [IMP] Minor changes
(`#463 <https://github.com/OCA/manufacture/pull/463>`_).
* Show supply method on MRP Inventory
* Allow no-MRP users to look into Products
12.0.1.0.0 (2019-08-05)
~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -7,5 +7,6 @@ access_mrp_area_user,mrp.area user,model_mrp_area,mrp.group_mrp_user,1,0,0,0
access_mrp_area_manager,mrp.area manager,model_mrp_area,mrp.group_mrp_manager,1,1,1,1
access_product_mrp_area_user,product.mrp.area user,model_product_mrp_area,mrp.group_mrp_user,1,1,1,0
access_product_mrp_area_manager,product.mrp.area manager,model_product_mrp_area,mrp.group_mrp_manager,1,1,1,1
access_product_mrp_area_read,product.mrp.area read,model_product_mrp_area,base.group_user,1,0,0,0
access_mrp_planned_order_user,mrp.planned.order user,model_mrp_planned_order,mrp.group_mrp_user,1,0,0,0
access_mrp_planned_order_manager,mrp.planned.order manager,model_mrp_planned_order,mrp.group_mrp_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
7 access_mrp_area_manager mrp.area manager model_mrp_area mrp.group_mrp_manager 1 1 1 1
8 access_product_mrp_area_user product.mrp.area user model_product_mrp_area mrp.group_mrp_user 1 1 1 0
9 access_product_mrp_area_manager product.mrp.area manager model_product_mrp_area mrp.group_mrp_manager 1 1 1 1
10 access_product_mrp_area_read product.mrp.area read model_product_mrp_area base.group_user 1 0 0 0
11 access_mrp_planned_order_user mrp.planned.order user model_mrp_planned_order mrp.group_mrp_user 1 0 0 0
12 access_mrp_planned_order_manager mrp.planned.order manager model_mrp_planned_order mrp.group_mrp_manager 1 1 1 1

View File

@@ -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.13.1: http://docutils.sourceforge.net/" />
<title>MRP Multi Level</title>
<style type="text/css">
@@ -387,43 +387,44 @@ Note: You need to install <a class="reference external" href="https://github.com
<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="id15">Configuration</a><ul>
<li><a class="reference internal" href="#mrp-areas" id="id16">MRP Areas</a></li>
<li><a class="reference internal" href="#product-mrp-area-parameters" id="id17">Product MRP Area Parameters</a></li>
<li><a class="reference internal" href="#configuration" id="id20">Configuration</a><ul>
<li><a class="reference internal" href="#mrp-areas" id="id21">MRP Areas</a></li>
<li><a class="reference internal" href="#product-mrp-area-parameters" id="id22">Product MRP Area Parameters</a></li>
</ul>
</li>
<li><a class="reference internal" href="#usage" id="id18">Usage</a></li>
<li><a class="reference internal" href="#changelog" id="id19">Changelog</a><ul>
<li><a class="reference internal" href="#id1" id="id20">12.0.1.0.0 (2019-08-05)</a></li>
<li><a class="reference internal" href="#id2" id="id21">11.0.3.0.0 (2019-05-22)</a></li>
<li><a class="reference internal" href="#id4" id="id22">11.0.2.2.0 (2019-05-02)</a></li>
<li><a class="reference internal" href="#id6" id="id23">11.0.2.1.0 (2019-04-02)</a></li>
<li><a class="reference internal" href="#id8" id="id24">11.0.2.0.0 (2018-11-20)</a></li>
<li><a class="reference internal" href="#id10" id="id25">11.0.1.1.0 (2018-08-30)</a></li>
<li><a class="reference internal" href="#id12" id="id26">11.0.1.0.1 (2018-08-03)</a></li>
<li><a class="reference internal" href="#id14" id="id27">11.0.1.0.0 (2018-07-09)</a></li>
<li><a class="reference internal" href="#usage" id="id23">Usage</a></li>
<li><a class="reference internal" href="#changelog" id="id24">Changelog</a><ul>
<li><a class="reference internal" href="#id1" id="id25">12.0.2.0.0 (2020-03-31)</a></li>
<li><a class="reference internal" href="#id6" id="id26">12.0.1.0.0 (2019-08-05)</a></li>
<li><a class="reference internal" href="#id7" id="id27">11.0.3.0.0 (2019-05-22)</a></li>
<li><a class="reference internal" href="#id9" id="id28">11.0.2.2.0 (2019-05-02)</a></li>
<li><a class="reference internal" href="#id11" id="id29">11.0.2.1.0 (2019-04-02)</a></li>
<li><a class="reference internal" href="#id13" id="id30">11.0.2.0.0 (2018-11-20)</a></li>
<li><a class="reference internal" href="#id15" id="id31">11.0.1.1.0 (2018-08-30)</a></li>
<li><a class="reference internal" href="#id17" id="id32">11.0.1.0.1 (2018-08-03)</a></li>
<li><a class="reference internal" href="#id19" id="id33">11.0.1.0.0 (2018-07-09)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="id28">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id29">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id30">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id31">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id32">Maintainers</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id34">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id35">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id36">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id37">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id38">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#id15">Configuration</a></h2>
<h2><a class="toc-backref" href="#id20">Configuration</a></h2>
<div class="section" id="mrp-areas">
<h3><a class="toc-backref" href="#id16">MRP Areas</a></h3>
<h3><a class="toc-backref" href="#id21">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="#id17">Product MRP Area Parameters</a></h3>
<h3><a class="toc-backref" href="#id22">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>
@@ -431,7 +432,7 @@ the MRP parameters for a given product and area.</li>
</div>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#id18">Usage</a></h2>
<h2><a class="toc-backref" href="#id23">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>
@@ -447,9 +448,50 @@ hand side gears in any record.</li>
</ol>
</div>
<div class="section" id="changelog">
<h2><a class="toc-backref" href="#id19">Changelog</a></h2>
<h2><a class="toc-backref" href="#id24">Changelog</a></h2>
<div class="section" id="id1">
<h3><a class="toc-backref" href="#id20">12.0.1.0.0 (2019-08-05)</a></h3>
<h3><a class="toc-backref" href="#id25">12.0.2.0.0 (2020-03-31)</a></h3>
<ul class="simple">
<li>Improving the management of planned orders:<ul>
<li>Add menu entry for planned orders</li>
<li>Add button to navigate from planned orders to linked manufacturing orders</li>
<li>Add action to convert planned orders to fixed</li>
<li>When changing the due date in a planned order the release date is recomputed</li>
</ul>
</li>
<li>[IMP] Minor changes”
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/470">#470</a>).<ul>
<li>Planned Order release and due date become required.</li>
<li>Add button to Product MRP Area to update MOQ from Supplier Info.</li>
<li>Link Manufacturing Orders with Planned Orders.</li>
<li>Allow Mrp Inventory Procure Wizard to be used from other models.</li>
<li>Make MRP Inventory creation more extensible.</li>
<li>Main Supplier computation (v13 requires explicit False definitions)</li>
</ul>
</li>
<li>[IMP] Minor changes
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/468">#468</a>).<ul>
<li>Planned Orders become fixed on manual creation by default</li>
<li>Released Quantity becomes readonly</li>
<li>Add product reference if Planned Order name is not defined on bom explosion</li>
</ul>
</li>
<li>[FIX] Minor changes
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/469">#469</a>).<ul>
<li>Fix Main supplier computation in multi company</li>
<li>Drop Triplicated field in search view</li>
</ul>
</li>
<li>[IMP] Minor changes
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/463">#463</a>).<ul>
<li>Show supply method on MRP Inventory</li>
<li>Allow no-MRP users to look into Products</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="id6">
<h3><a class="toc-backref" href="#id26">12.0.1.0.0 (2019-08-05)</a></h3>
<ul class="simple">
<li>[MIG] Migration to v12:<ul>
<li>Estimates as a forecasting mechanism is moved to a new module
@@ -458,31 +500,31 @@ hand side gears in any record.</li>
</li>
</ul>
</div>
<div class="section" id="id2">
<h3><a class="toc-backref" href="#id21">11.0.3.0.0 (2019-05-22)</a></h3>
<div class="section" id="id7">
<h3><a class="toc-backref" href="#id27">11.0.3.0.0 (2019-05-22)</a></h3>
<ul class="simple">
<li>[REW/IMP] Rework to include Planned Orders.
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/365">#365</a>).</li>
<li>[IMP] Able to procure from a different location than the areas location.</li>
</ul>
</div>
<div class="section" id="id4">
<h3><a class="toc-backref" href="#id22">11.0.2.2.0 (2019-05-02)</a></h3>
<div class="section" id="id9">
<h3><a class="toc-backref" href="#id28">11.0.2.2.0 (2019-05-02)</a></h3>
<ul class="simple">
<li>[IMP] Able to run MRP only for selected areas.
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/360">#360</a>).</li>
</ul>
</div>
<div class="section" id="id6">
<h3><a class="toc-backref" href="#id23">11.0.2.1.0 (2019-04-02)</a></h3>
<div class="section" id="id11">
<h3><a class="toc-backref" href="#id29">11.0.2.1.0 (2019-04-02)</a></h3>
<ul class="simple">
<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="id8">
<h3><a class="toc-backref" href="#id24">11.0.2.0.0 (2018-11-20)</a></h3>
<div class="section" id="id13">
<h3><a class="toc-backref" href="#id30">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>
@@ -494,15 +536,15 @@ different areas.</li>
</li>
</ul>
</div>
<div class="section" id="id10">
<h3><a class="toc-backref" href="#id25">11.0.1.1.0 (2018-08-30)</a></h3>
<div class="section" id="id15">
<h3><a class="toc-backref" href="#id31">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="id12">
<h3><a class="toc-backref" href="#id26">11.0.1.0.1 (2018-08-03)</a></h3>
<div class="section" id="id17">
<h3><a class="toc-backref" href="#id32">11.0.1.0.1 (2018-08-03)</a></h3>
<ul class="simple">
<li>[FIX] User and system locales doesnt break MRP calculation.
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/290">#290</a>)</li>
@@ -511,15 +553,15 @@ as a related on MRP Areas.
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/290">#290</a>)</li>
</ul>
</div>
<div class="section" id="id14">
<h3><a class="toc-backref" href="#id27">11.0.1.0.0 (2018-07-09)</a></h3>
<div class="section" id="id19">
<h3><a class="toc-backref" href="#id33">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="#id28">Bug Tracker</a></h2>
<h2><a class="toc-backref" href="#id34">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
@@ -527,31 +569,32 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<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="#id29">Credits</a></h2>
<h2><a class="toc-backref" href="#id35">Credits</a></h2>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#id30">Authors</a></h3>
<h3><a class="toc-backref" href="#id36">Authors</a></h3>
<ul class="simple">
<li>Ucamco</li>
<li>Eficent</li>
<li>ForgeFlow</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#id31">Contributors</a></h3>
<h3><a class="toc-backref" href="#id37">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>
<li>Jordi Ballester &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li>
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
<li>Héctor Villarreal &lt;<a class="reference external" href="mailto:hector.villarreal&#64;forgeflow.com">hector.villarreal&#64;forgeflow.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#id32">Maintainers</a></h3>
<h3><a class="toc-backref" href="#id38">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
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external" href="https://github.com/jbeficent"><img alt="jbeficent" src="https://github.com/jbeficent.png?size=40px" /></a> <a class="reference external" href="https://github.com/lreficent"><img alt="lreficent" src="https://github.com/lreficent.png?size=40px" /></a></p>
<p><a class="reference external" href="https://github.com/JordiBForgeFlow"><img alt="JordiBForgeFlow" src="https://github.com/JordiBForgeFlow.png?size=40px" /></a> <a class="reference external" href="https://github.com/LoisRForgeFlow"><img alt="LoisRForgeFlow" src="https://github.com/LoisRForgeFlow.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/12.0/mrp_multi_level">OCA/manufacture</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>

View File

@@ -1,4 +1,4 @@
# Copyright 2018-19 Eficent Business and IT Consulting Services S.L.
# Copyright 2018-19 ForgeFlow S.L. (https://www.forgeflow.com)
# (http://www.eficent.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

View File

@@ -1,4 +1,4 @@
# Copyright 2018-19 Eficent Business and IT Consulting Services S.L.
# Copyright 2018-19 ForgeFlow S.L. (https://www.forgeflow.com)
# (http://www.eficent.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
@@ -24,9 +24,12 @@ class TestMrpMultiLevel(TestMrpMultiLevelCommon):
self.assertEqual(product_mrp_area.supply_method, 'buy')
self.assertEqual(product_mrp_area.main_supplier_id, self.vendor)
self.assertEqual(product_mrp_area.qty_available, 10.0)
product_mrp_area = self.product_mrp_area_obj.search([
('product_id', '=', self.sf_1.id)])
self.assertEqual(product_mrp_area.supply_method, 'manufacture')
product_mrp_area = self.product_mrp_area_obj.search(
[("product_id", "=", self.sf_1.id)]
)
self.assertEqual(product_mrp_area.supply_method, "manufacture")
self.assertFalse(product_mrp_area.main_supplier_id)
self.assertFalse(product_mrp_area.main_supplierinfo_id)
def test_03_mrp_moves(self):
"""Tests for mrp moves generated."""

View File

@@ -14,6 +14,7 @@
<field name="company_id" groups="base.group_multi_company"/>
<field name="product_id"/>
<field name="product_mrp_area_id"/>
<field name="supply_method"/>
<field name="date"/>
</group>
<group>
@@ -51,6 +52,7 @@
name="%(mrp_multi_level.act_mrp_inventory_procure)d"
icon="fa-cogs" type="action"
attrs="{'invisible':[('to_procure','&lt;=',0.0)]}"/>
<field name="supply_method"/>
<field name="running_availability"/>
</tree>
</field>
@@ -103,15 +105,12 @@
<filter name="group_mrp_area"
string="MRP Area"
context="{'group_by':'mrp_area_id'}"/>
<filter name="group_release_date_day"
string="Date to Procure (By Day)"
context="{'group_by':'order_release_date:day'}"/>
<filter name="group_release_date_week"
string="Date to Procure (By Week)"
context="{'group_by':'order_release_date:week'}"/>
<filter name="group_release_date_month"
string="Date to Procure (By Month)"
context="{'group_by':'order_release_date:month'}"/>
<filter name="group_supply_method"
string="Supply Method"
context="{'group_by':'supply_method'}"/>
<filter name="group_release_date"
string="Date to Procure"
context="{'group_by':'order_release_date'}"/>
</group>
</search>
</field>

View File

@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2019-20 ForgeFlow S.L. (https://www.forgeflow.com)
Part of ForgeFlow. See LICENSE file for full copyright and licensing details. -->
<odoo>
<record id="mrp_planned_order_view_tree" model="ir.ui.view">
<field name="name">mrp.planned.order.tree</field>
<field name="model">mrp.planned.order</field>
<field name="arch" type="xml">
<tree decoration-info="fixed != True">
<field name="product_mrp_area_id" />
<field name="product_id" />
<field name="mrp_area_id" />
<field name="order_release_date" />
<field name="due_date" />
<field name="qty_released" />
<field name="mrp_qty" />
<field name="fixed" />
</tree>
</field>
</record>
<record id="mrp_planned_order_view_form" model="ir.ui.view">
<field name="name">mrp.planned.order.form</field>
<field name="model">mrp.planned.order</field>
<field name="arch" type="xml">
<form>
<sheet>
<div class="oe_button_box" name="button_box">
<button
name="action_open_linked_mrp_production"
type="object"
icon="fa-wrench"
attrs="{'invisible':[('mo_count', '=', 0)]}"
class="oe_stat_button"
>
<field name="mo_count" widget="statinfo" string="MOs" />
</button>
</div>
<group>
<group>
<field name="product_mrp_area_id" />
<field name="product_id" />
<field name="mrp_area_id" />
<field name="name" />
<field name="fixed" />
</group>
<group>
<field name="mrp_action" />
<field name="order_release_date" />
<field name="due_date" />
<field name="mrp_qty" />
<field name="qty_released" />
</group>
</group>
<group groups="base.group_no_one">
<field name="mrp_move_down_ids" readonly="True" />
</group>
</sheet>
</form>
</field>
</record>
<record id="mrp_planned_order_view_pivot" model="ir.ui.view">
<field name="name">mrp.planned.order.pivot</field>
<field name="model">mrp.planned.order</field>
<field name="arch" type="xml">
<pivot>
<field name="mrp_area_id" type="row" />
<field name="product_id" type="row" />
<field name="mrp_qty" type="measure" />
<field name="due_date" interval="week" type="col" />
</pivot>
</field>
</record>
<record id="mrp_planned_order_view_search" model="ir.ui.view">
<field name="name">mrp.planned.order.search</field>
<field name="model">mrp.planned.order</field>
<field name="arch" type="xml">
<search>
<field name="product_id" />
<field name="mrp_area_id" />
<separator />
<filter string="Fixed" name="fixed" domain="[('fixed','=',True)]" />
<group name='group_by' expand="0" string="Group By...">
<filter
name='product_parameters'
string="Product Parameters"
context="{'group_by':'product_mrp_area_id'}"
/>
<filter
name='due_date'
string="Due Date"
context="{'group_by':'due_date'}"
/>
</group>
</search>
</field>
</record>
<record id="mrp_planned_order_action" model="ir.actions.act_window">
<field name="name">Planned Orders</field>
<field name="res_model">mrp.planned.order</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">tree,form,pivot</field>
<field name="context">{'search_default_fixed': 1}</field>
</record>
<menuitem
name="Planned Orders"
id="menu_mrp_planned_order"
action="mrp_planned_order_action"
parent="mrp.mrp_planning_menu_root"
sequence="20"
/>
<record id="action_server_planned_order_toggle_fixed" model="ir.actions.server">
<field name="name">Toggle Fixed</field>
<field name="model_id" ref="mrp_multi_level.model_mrp_planned_order" />
<field name="binding_model_id" ref="mrp_multi_level.model_mrp_planned_order" />
<field name="state">code</field>
<field name="code">records.action_toggle_fixed()</field>
</record>
<record id="act_mrp_inventory_procure_planned_order" model="ir.actions.act_window">
<field name="name">Procure</field>
<field name="res_model">mrp.inventory.procure</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="mrp_multi_level.model_mrp_planned_order" />
</record>
</odoo>

View File

@@ -57,7 +57,17 @@
<field name="mrp_transit_delay" invisible="1"/>
<field name="mrp_inspection_delay" invisible="1"/>
<field name="mrp_minimum_stock"/>
<field name="mrp_minimum_order_qty"/>
<label for="mrp_minimum_order_qty"/>
<div name="mrp_minimum_order_qty" class="o_row">
<field name="mrp_minimum_order_qty"/>
<span name="update_min_qty">
<button string="Get from main supplier" type="object"
name="update_min_qty_from_main_supplier"
attrs="{'invisible':[('supply_method', '!=', 'buy'), ('main_supplierinfo_id', '=', False)]}"
class="oe_link pt-0 oe_inline"
/>
</span>
</div>
<field name="mrp_maximum_order_qty"/>
<field name="mrp_qty_multiple"/>
<field name="supply_method"/>

View File

@@ -1,4 +1,4 @@
# Copyright 2018-19 Eficent Business and IT Consulting Services S.L.
# Copyright 2018-19 ForgeFlow S.L. (https://www.forgeflow.com)
# (http://www.eficent.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
@@ -19,16 +19,16 @@ class MrpInventoryProcure(models.TransientModel):
@api.model
def _prepare_item(self, planned_order):
return {
'planned_order_id': planned_order.id,
'qty': planned_order.mrp_qty - planned_order.qty_released,
'uom_id': planned_order.mrp_inventory_id.uom_id.id,
'date_planned': planned_order.due_date,
'mrp_inventory_id': planned_order.mrp_inventory_id.id,
'product_id': planned_order.product_id.id,
'warehouse_id': planned_order.mrp_area_id.warehouse_id.id,
'location_id':
planned_order.product_mrp_area_id.location_proc_id.id or
planned_order.mrp_area_id.location_id.id,
"planned_order_id": planned_order.id,
"qty": planned_order.mrp_qty - planned_order.qty_released,
"uom_id": planned_order.mrp_inventory_id.uom_id.id,
"date_planned": planned_order.due_date,
"mrp_inventory_id": planned_order.mrp_inventory_id.id,
"product_id": planned_order.product_id.id,
"warehouse_id": planned_order.mrp_area_id.warehouse_id.id,
"location_id": planned_order.product_mrp_area_id.location_proc_id.id
or planned_order.mrp_area_id.location_id.id,
"supply_method": planned_order.product_mrp_area_id.supply_method,
}
@api.model
@@ -50,20 +50,19 @@ class MrpInventoryProcure(models.TransientModel):
@api.model
def default_get(self, fields):
res = super(MrpInventoryProcure, self).default_get(fields)
mrp_inventory_obj = self.env['mrp.inventory']
mrp_inventory_ids = self.env.context['active_ids'] or []
active_model = self.env.context['active_model']
if not mrp_inventory_ids or 'item_ids' not in fields:
active_ids = self.env.context["active_ids"] or []
active_model = self.env.context["active_model"]
if not active_ids or "item_ids" not in fields:
return res
assert active_model == 'mrp.inventory', 'Bad context propagation'
items = item_obj = self.env['mrp.inventory.procure.item']
for line in mrp_inventory_obj.browse(mrp_inventory_ids).mapped(
'planned_order_ids'):
if line.qty_released < line.mrp_qty:
items += item_obj.create(self._prepare_item(line))
res['item_ids'] = [(6, 0, items.ids)]
if active_model == "mrp.inventory":
items = item_obj = self.env["mrp.inventory.procure.item"]
mrp_inventory_obj = self.env["mrp.inventory"]
for line in mrp_inventory_obj.browse(active_ids).mapped(
"planned_order_ids"
):
if line.qty_released < line.mrp_qty:
items += item_obj.create(self._prepare_item(line))
res["item_ids"] = [(6, 0, items.ids)]
return res
@api.multi
@@ -101,12 +100,9 @@ class MrpInventoryProcureItem(models.TransientModel):
comodel_name='mrp.inventory.procure', string='Wizard',
ondelete='cascade', readonly=True,
)
qty = fields.Float(string='Quantity')
uom_id = fields.Many2one(
string='Unit of Measure',
comodel_name='uom.uom',
)
date_planned = fields.Date(string='Planned Date', required=False)
qty = fields.Float(string="Quantity")
uom_id = fields.Many2one(string="Unit of Measure", comodel_name="uom.uom")
date_planned = fields.Date(string="Planned Date", required=True)
mrp_inventory_id = fields.Many2one(
string='Mrp Inventory',
comodel_name='mrp.inventory',
@@ -126,14 +122,31 @@ class MrpInventoryProcureItem(models.TransientModel):
string='Location',
comodel_name='stock.location',
)
planned_order_id = fields.Many2one(comodel_name="mrp.planned.order")
product_id = fields.Many2one(string="Product", comodel_name="product.product")
warehouse_id = fields.Many2one(string="Warehouse", comodel_name="stock.warehouse")
location_id = fields.Many2one(string="Location", comodel_name="stock.location")
supply_method = fields.Selection(
string="Supply Method",
selection=[
("buy", "Buy"),
("none", "Undefined"),
("manufacture", "Produce"),
("pull", "Pull From"),
("push", "Push To"),
("pull_push", "Pull & Push"),
],
readonly=True,
)
def _prepare_procurement_values(self, group=False):
return {
'date_planned': fields.Datetime.to_string(
fields.Date.from_string(self.date_planned)),
'warehouse_id': self.warehouse_id,
# 'company_id': self.company_id, # TODO: consider company
'group_id': group,
"date_planned": fields.Datetime.to_string(
fields.Date.from_string(self.date_planned)
),
"warehouse_id": self.warehouse_id,
"group_id": group,
"planned_order_id": self.planned_order_id.id,
}
@api.multi

View File

@@ -23,6 +23,7 @@
<field name="qty"/>
<field name="uom_id" groups="uom.group_uom"/>
<field name="date_planned"/>
<field name="supply_method"/>
</tree>
</field>
</group>

View File

@@ -1,5 +1,5 @@
# Copyright 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# Copyright 2016-19 Eficent Business and IT Consulting Services S.L.
# Copyright 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
# - Jordi Ballester Alomar <jordi.ballester@eficent.com>
# - Lois Rilo <lois.rilo@eficent.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
@@ -105,6 +105,7 @@ class MultiLevelMrp(models.TransientModel):
'mrp_action': product_mrp_area.supply_method,
'qty_released': 0.0,
'name': 'Planned supply for: ' + name,
'fixed': False,
}
@api.model
@@ -117,26 +118,27 @@ class MultiLevelMrp(models.TransientModel):
_("No MRP product found"))
return {
'mrp_area_id': product.mrp_area_id.id,
'product_id': bomline.product_id.id,
'product_mrp_area_id': product_mrp_area.id,
'production_id': None,
'purchase_order_id': None,
'purchase_line_id': None,
'stock_move_id': None,
'mrp_qty': -(qty * bomline.product_qty), # TODO: review with UoM
'current_qty': None,
'mrp_date': mrp_date_demand_2,
'current_date': None,
'mrp_type': 'd',
'mrp_origin': 'mrp',
'mrp_order_number': None,
'parent_product_id': bom.product_id.id,
'name':
('Demand Bom Explosion: ' + name).replace(
'Demand Bom Explosion: Demand Bom '
'Explosion: ',
'Demand Bom Explosion: '),
"mrp_area_id": product.mrp_area_id.id,
"product_id": bomline.product_id.id,
"product_mrp_area_id": product_mrp_area.id,
"production_id": None,
"purchase_order_id": None,
"purchase_line_id": None,
"stock_move_id": None,
"mrp_qty": -(qty * bomline.product_qty), # TODO: review with UoM
"current_qty": None,
"mrp_date": mrp_date_demand_2,
"current_date": None,
"mrp_type": "d",
"mrp_origin": "mrp",
"mrp_order_number": None,
"parent_product_id": bom.product_id.id,
"name": (
"Demand Bom Explosion: %s"
% (name or product.product_id.default_code or product.product_id.name)
).replace(
"Demand Bom Explosion: Demand Bom Explosion: ", "Demand Bom Explosion: "
),
}
@api.model
@@ -623,6 +625,33 @@ class MultiLevelMrp(models.TransientModel):
}
return query, params
@api.model
def _prepare_mrp_inventory_data(
self,
product_mrp_area,
mdt,
on_hand_qty,
running_availability,
demand_qty_by_date,
supply_qty_by_date,
planned_qty_by_date,
):
"""Return dict to create mrp.inventory records on MRP Multi Level Scheduler"""
mrp_inventory_data = {"product_mrp_area_id": product_mrp_area.id, "date": mdt}
demand_qty = demand_qty_by_date.get(mdt, 0.0)
mrp_inventory_data["demand_qty"] = abs(demand_qty)
supply_qty = supply_qty_by_date.get(mdt, 0.0)
mrp_inventory_data["supply_qty"] = abs(supply_qty)
mrp_inventory_data["initial_on_hand_qty"] = on_hand_qty
on_hand_qty += supply_qty + demand_qty
mrp_inventory_data["final_on_hand_qty"] = on_hand_qty
# Consider that MRP plan is followed exactly:
running_availability += (
supply_qty + demand_qty + planned_qty_by_date.get(mdt, 0.0)
)
mrp_inventory_data["running_availability"] = running_availability
return mrp_inventory_data, running_availability
@api.model
def _init_mrp_inventory(self, product_mrp_area):
mrp_move_obj = self.env['mrp.move']
@@ -659,23 +688,16 @@ class MultiLevelMrp(models.TransientModel):
product_mrp_area.product_id.id]['qty_available']
running_availability = on_hand_qty
for mdt in sorted(mrp_dates):
mrp_inventory_data = {
'product_mrp_area_id': product_mrp_area.id,
'date': mdt,
}
demand_qty = demand_qty_by_date.get(mdt, 0.0)
mrp_inventory_data['demand_qty'] = abs(demand_qty)
supply_qty = supply_qty_by_date.get(mdt, 0.0)
mrp_inventory_data['supply_qty'] = abs(supply_qty)
mrp_inventory_data['initial_on_hand_qty'] = on_hand_qty
on_hand_qty += (supply_qty + demand_qty)
mrp_inventory_data['final_on_hand_qty'] = on_hand_qty
# Consider that MRP plan is followed exactly:
running_availability += supply_qty \
+ demand_qty + planned_qty_by_date.get(mdt, 0.0)
mrp_inventory_data['running_availability'] = running_availability
inv_id = self.env['mrp.inventory'].create(mrp_inventory_data)
mrp_inventory_data, running_availability = self._prepare_mrp_inventory_data(
product_mrp_area,
mdt,
on_hand_qty,
running_availability,
demand_qty_by_date,
supply_qty_by_date,
planned_qty_by_date,
)
inv_id = self.env["mrp.inventory"].create(mrp_inventory_data)
# attach planned orders to inventory
planned_order_obj.search([
('due_date', '=', mdt),