[13.0][MIG] mrp_multi_level

This commit is contained in:
Lois Rilo
2019-12-18 09:46:15 +01:00
committed by davidborromeo
parent d20466cf58
commit 3bde781f26
25 changed files with 178 additions and 236 deletions

View File

@@ -7,20 +7,20 @@ MRP Multi Level
!! changes will be overwritten. !! !! 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 :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 .. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3 :alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/12.0/mrp_multi_level :target: https://github.com/OCA/manufacture/tree/13.0/mrp_multi_level
:alt: OCA/manufacture :alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_multi_level :target: https://translation.odoo-community.org/projects/manufacture-13-0/manufacture-13-0-mrp_multi_level
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/129/12.0 :target: https://runbot.odoo-community.org/runbot/129/13.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -82,6 +82,11 @@ To launch replenishment orders (moves, purchases, production orders...):
Changelog Changelog
========= =========
13.0.1.0.0 (2019-12-18)
~~~~~~~~~~~~~~~~~~~~~~~
* [MIG] Migration to v13.
12.0.1.0.0 (2019-08-05) 12.0.1.0.0 (2019-08-05)
~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
@@ -147,7 +152,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_multi_level%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_multi_level%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. Do not contact contributors directly about support or help with technical issues.
@@ -158,14 +163,14 @@ Authors
~~~~~~~ ~~~~~~~
* Ucamco * Ucamco
* Eficent * ForgeFlow
Contributors Contributors
~~~~~~~~~~~~ ~~~~~~~~~~~~
* Wim Audenaert <wim.audenaert@ucamco.com> * Wim Audenaert <wim.audenaert@ucamco.com>
* Jordi Ballester <jordi.ballester@eficent.com> * Jordi Ballester <jordi.ballester@forgeflow.com>
* Lois Rilo <lois.rilo@eficent.com> * Lois Rilo <lois.rilo@forgeflow.com>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@@ -180,17 +185,17 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
.. |maintainer-jbeficent| image:: https://github.com/jbeficent.png?size=40px .. |maintainer-JordiBForgeFlow| image:: https://github.com/JordiBForgeFlow.png?size=40px
:target: https://github.com/jbeficent :target: https://github.com/JordiBForgeFlow
:alt: jbeficent :alt: JordiBForgeFlow
.. |maintainer-lreficent| image:: https://github.com/lreficent.png?size=40px .. |maintainer-LoisRForgeFlow| image:: https://github.com/LoisRForgeFlow.png?size=40px
:target: https://github.com/lreficent :target: https://github.com/LoisRForgeFlow
:alt: lreficent :alt: LoisRForgeFlow
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__: 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. This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/13.0/mrp_multi_level>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -1,14 +1,14 @@
# Copyright 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com> # 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). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{ {
"name": "MRP Multi Level", "name": "MRP Multi Level",
"version": "12.0.1.0.1", "version": "13.0.1.0.0",
"development_status": "Beta", "development_status": "Production/Stable",
"license": "LGPL-3", "license": "LGPL-3",
"author": "Ucamco, " "Eficent, " "Odoo Community Association (OCA)", "author": "Ucamco, ForgeFlow, Odoo Community Association (OCA)",
"maintainers": ["jbeficent", "lreficent"], "maintainers": ["JordiBForgeFlow", "LoisRForgeFlow"],
"summary": "Adds an MRP Scheduler", "summary": "Adds an MRP Scheduler",
"website": "https://github.com/OCA/manufacture", "website": "https://github.com/OCA/manufacture",
"category": "Manufacturing", "category": "Manufacturing",

0
mrp_multi_level/data/mrp_multi_level_cron.xml Executable file → Normal file
View File

View File

@@ -2,7 +2,7 @@
<odoo noupdate="1"> <odoo noupdate="1">
<record id="stock_inventory_mrp_example" model="stock.inventory"> <record id="stock_inventory_mrp_example" model="stock.inventory">
<field name="name">Simulating MRP</field> <field name="name">Starting On-hand for MRP demo</field>
</record> </record>
<record id="stock_inventory_line_1" model="stock.inventory.line"> <record id="stock_inventory_line_1" model="stock.inventory.line">
<field name="product_id" ref="product_product_pp_1"/> <field name="product_id" ref="product_product_pp_1"/>
@@ -25,6 +25,10 @@
<field name="product_qty">15</field> <field name="product_qty">15</field>
<field name="location_id" ref="stock.stock_location_stock"/> <field name="location_id" ref="stock.stock_location_stock"/>
</record> </record>
<function model="stock.inventory" name="_action_start">
<function eval="[[('id', '=', ref('stock_inventory_mrp_example'))]]" model="stock.inventory" name="search"/>
</function>
<function model="stock.inventory" name="action_validate"> <function model="stock.inventory" name="action_validate">
<function eval="[[('id', '=', ref('stock_inventory_mrp_example'))]]" model="stock.inventory" name="search"/> <function eval="[[('id', '=', ref('stock_inventory_mrp_example'))]]" model="stock.inventory" name="search"/>
</function> </function>

View File

@@ -4,7 +4,5 @@
<field name="name">Lazer Tech</field> <field name="name">Lazer Tech</field>
<field name="is_company">1</field> <field name="is_company">1</field>
<field name="company_id" ref="base.main_company"/> <field name="company_id" ref="base.main_company"/>
<field name="customer" eval="False"/>
<field name="supplier" eval="True"/>
</record> </record>
</odoo> </odoo>

View File

@@ -1,66 +0,0 @@
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
import logging
from odoo import SUPERUSER_ID, api
_logger = logging.getLogger(__name__)
__name__ = "Upgrade to 11.0.2.0.0"
def _migrate_product_to_product_mrp_area(env):
_logger.info("Migrating product parameters to Product MRP Areas")
env.cr.execute(
"""
SELECT DISTINCT mrp_area.id, pr.id, pr.mrp_applicable, pr.mrp_exclude,
pr.mrp_inspection_delay, pr.mrp_maximum_order_qty,
pr.mrp_minimum_order_qty, pr.mrp_minimum_stock, pr.mrp_nbr_days,
pr.mrp_qty_multiple, pr.mrp_transit_delay, pr.mrp_verified, pr.active
FROM product_product AS pr
CROSS JOIN mrp_area
LEFT JOIN product_template AS pt
ON pt.id = pr.product_tmpl_id
WHERE pr.mrp_exclude = False
AND pt.type = 'product'
"""
)
product_mrp_area_model = env["product.mrp.area"]
for (
mrp_area_id,
product_id,
mrp_applicable,
mrp_exclude,
mrp_inspection_delay,
mrp_maximum_order_qty,
mrp_minimum_order_qty,
mrp_minimum_stock,
mrp_nbr_days,
mrp_qty_multiple,
mrp_transit_delay,
mrp_verified,
active,
) in env.cr.fetchall():
product_mrp_area_model.create(
{
"mrp_area_id": mrp_area_id,
"product_id": product_id,
"mrp_applicable": mrp_applicable,
"mrp_exclude": mrp_exclude,
"mrp_inspection_delay": mrp_inspection_delay,
"mrp_maximum_order_qty": mrp_maximum_order_qty,
"mrp_minimum_order_qty": mrp_minimum_order_qty,
"mrp_minimum_stock": mrp_minimum_stock,
"mrp_nbr_days": mrp_nbr_days,
"mrp_qty_multiple": mrp_qty_multiple,
"mrp_transit_delay": mrp_transit_delay,
"mrp_verified": mrp_verified,
"active": active,
}
)
def migrate(cr, version):
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
_migrate_product_to_product_mrp_area(env)

View File

@@ -1,10 +1,10 @@
# © 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com> # © 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# © 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> # - Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
# - Lois Rilo Antelo <lois.rilo@eficent.com> # - Lois Rilo Antelo <lois.rilo@forgeflow.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, fields, models from odoo import fields, models
class MrpArea(models.Model): class MrpArea(models.Model):
@@ -28,7 +28,6 @@ class MrpArea(models.Model):
related="warehouse_id.calendar_id", related="warehouse_id.calendar_id",
) )
@api.multi
def _get_locations(self): def _get_locations(self):
self.ensure_one() self.ensure_one()
return self.env["stock.location"].search( return self.env["stock.location"].search(

View File

@@ -1,7 +1,7 @@
# © 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com> # © 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> # - Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
# - Lois Rilo Antelo <lois.rilo@eficent.com> # - Lois Rilo Antelo <lois.rilo@forgeflow.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from datetime import date, timedelta from datetime import date, timedelta
@@ -63,7 +63,6 @@ class MrpInventory(models.Model):
comodel_name="mrp.planned.order", inverse_name="mrp_inventory_id", readonly=True comodel_name="mrp.planned.order", inverse_name="mrp_inventory_id", readonly=True
) )
@api.multi
def _compute_uom_id(self): def _compute_uom_id(self):
for rec in self: for rec in self:
rec.uom_id = rec.product_mrp_area_id.product_id.uom_id rec.uom_id = rec.product_mrp_area_id.product_id.uom_id
@@ -75,7 +74,6 @@ class MrpInventory(models.Model):
rec.planned_order_ids.mapped("qty_released") rec.planned_order_ids.mapped("qty_released")
) )
@api.multi
@api.depends( @api.depends(
"product_mrp_area_id", "product_mrp_area_id",
"product_mrp_area_id.main_supplierinfo_id", "product_mrp_area_id.main_supplierinfo_id",

View File

@@ -1,5 +1,5 @@
# © 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com> # © 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# © 2016-18 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). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import fields, models from odoo import fields, models

View File

@@ -1,5 +1,5 @@
# 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> # - Lois Rilo Antelo <lois.rilo@forgeflow.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import fields, models from odoo import fields, models

View File

@@ -1,7 +1,7 @@
# Copyright 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com> # 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> # - Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
# - Lois Rilo Antelo <lois.rilo@eficent.com> # - Lois Rilo Antelo <lois.rilo@forgeflow.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from math import ceil from math import ceil
@@ -104,7 +104,6 @@ class ProductMRPArea(models.Model):
) )
] ]
@api.multi
@api.constrains( @api.constrains(
"mrp_minimum_order_qty", "mrp_minimum_order_qty",
"mrp_maximum_order_qty", "mrp_maximum_order_qty",
@@ -126,14 +125,15 @@ class ProductMRPArea(models.Model):
if any(v < 0 for v in rec.values()): if any(v < 0 for v in rec.values()):
raise ValidationError(_("You cannot use a negative number.")) raise ValidationError(_("You cannot use a negative number."))
@api.multi
def name_get(self): def name_get(self):
return [ return [
(area.id, "[{}] {}".format(area.mrp_area_id.name, area.product_id.display_name)) (
area.id,
"[{}] {}".format(area.mrp_area_id.name, area.product_id.display_name),
)
for area in self for area in self
] ]
@api.multi
def _compute_mrp_lead_time(self): def _compute_mrp_lead_time(self):
produced = self.filtered(lambda r: r.supply_method == "manufacture") produced = self.filtered(lambda r: r.supply_method == "manufacture")
purchased = self.filtered(lambda r: r.supply_method == "buy") purchased = self.filtered(lambda r: r.supply_method == "buy")
@@ -145,14 +145,12 @@ class ProductMRPArea(models.Model):
for rec in self - produced - purchased: for rec in self - produced - purchased:
rec.mrp_lead_time = 0 rec.mrp_lead_time = 0
@api.multi
def _compute_qty_available(self): def _compute_qty_available(self):
for rec in self: for rec in self:
rec.qty_available = rec.product_id.with_context( rec.qty_available = rec.product_id.with_context(
{"location": rec.mrp_area_id.location_id.id} {"location": rec.mrp_area_id.location_id.id}
).qty_available ).qty_available
@api.multi
def _compute_supply_method(self): def _compute_supply_method(self):
group_obj = self.env["procurement.group"] group_obj = self.env["procurement.group"]
for rec in self: for rec in self:
@@ -165,7 +163,6 @@ class ProductMRPArea(models.Model):
rule = group_obj._get_rule(rec.product_id, proc_loc, values) rule = group_obj._get_rule(rec.product_id, proc_loc, values)
rec.supply_method = rule.action if rule else "none" rec.supply_method = rule.action if rule else "none"
@api.multi
@api.depends("supply_method", "product_id.route_ids", "product_id.seller_ids") @api.depends("supply_method", "product_id.route_ids", "product_id.seller_ids")
def _compute_main_supplier(self): def _compute_main_supplier(self):
"""Simplified and similar to procurement.rule logic.""" """Simplified and similar to procurement.rule logic."""
@@ -178,7 +175,6 @@ class ProductMRPArea(models.Model):
rec.main_supplierinfo_id = suppliers[0] rec.main_supplierinfo_id = suppliers[0]
rec.main_supplier_id = suppliers[0].name rec.main_supplier_id = suppliers[0].name
@api.multi
def _adjust_qty_to_order(self, qty_to_order): def _adjust_qty_to_order(self, qty_to_order):
self.ensure_one() self.ensure_one()
if ( if (

View File

@@ -1,9 +1,10 @@
# Copyright 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com> # Copyright 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# Copyright 2016-18 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). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
import ast import ast
from odoo import api, fields, models from odoo import fields, models
class Product(models.Model): class Product(models.Model):
@@ -32,12 +33,10 @@ class Product(models.Model):
compute="_compute_mrp_area_count", compute="_compute_mrp_area_count",
) )
@api.multi
def _compute_mrp_area_count(self): def _compute_mrp_area_count(self):
for rec in self: for rec in self:
rec.mrp_area_count = len(rec.mrp_area_ids) rec.mrp_area_count = len(rec.mrp_area_ids)
@api.multi
def action_view_mrp_area_parameters(self): def action_view_mrp_area_parameters(self):
self.ensure_one() self.ensure_one()
action = self.env.ref("mrp_multi_level.product_mrp_area_action") action = self.env.ref("mrp_multi_level.product_mrp_area_action")

View File

@@ -1,8 +1,9 @@
# Copyright 2018 Eficent Business and IT Consulting Services S.L. # Copyright 2018-19 ForgeFlow S.L. (https://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
import ast import ast
from odoo import api, fields, models from odoo import fields, models
class ProductTemplate(models.Model): class ProductTemplate(models.Model):
@@ -19,12 +20,10 @@ class ProductTemplate(models.Model):
compute="_compute_mrp_area_count", compute="_compute_mrp_area_count",
) )
@api.multi
def _compute_mrp_area_count(self): def _compute_mrp_area_count(self):
for rec in self: for rec in self:
rec.mrp_area_count = len(rec.mrp_area_ids) rec.mrp_area_count = len(rec.mrp_area_ids)
@api.multi
def action_view_mrp_area_parameters(self): def action_view_mrp_area_parameters(self):
self.ensure_one() self.ensure_one()
action = self.env.ref("mrp_multi_level.product_mrp_area_action") action = self.env.ref("mrp_multi_level.product_mrp_area_action")

View File

@@ -1,6 +1,6 @@
# © 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com> # © 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
# © 2016 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> # - Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import fields, models from odoo import fields, models

View File

@@ -1,3 +1,3 @@
* Wim Audenaert <wim.audenaert@ucamco.com> * Wim Audenaert <wim.audenaert@ucamco.com>
* Jordi Ballester <jordi.ballester@eficent.com> * Jordi Ballester <jordi.ballester@forgeflow.com>
* Lois Rilo <lois.rilo@eficent.com> * Lois Rilo <lois.rilo@forgeflow.com>

View File

@@ -1,3 +1,8 @@
13.0.1.0.0 (2019-12-18)
~~~~~~~~~~~~~~~~~~~~~~~
* [MIG] Migration to v13.
12.0.1.0.0 (2019-08-05) 12.0.1.0.0 (2019-08-05)
~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <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>MRP Multi Level</title> <title>MRP Multi Level</title>
<style type="text/css"> <style type="text/css">
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! 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/manufacture/tree/12.0/mrp_multi_level"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_multi_level"><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/129/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/manufacture/tree/13.0/mrp_multi_level"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-13-0/manufacture-13-0-mrp_multi_level"><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/129/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 you to calculate, based in known inventory, demand, and <p>This module allows you to calculate, based in known inventory, demand, and
supply, and based on parameters set at product variant level, the new supply, and based on parameters set at product variant level, the new
procurements for each product.</p> procurements for each product.</p>
@@ -387,43 +387,44 @@ Note: You need to install <a class="reference external" href="https://github.com
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
<ul class="simple"> <ul class="simple">
<li><a class="reference internal" href="#configuration" id="id15">Configuration</a><ul> <li><a class="reference internal" href="#configuration" id="id16">Configuration</a><ul>
<li><a class="reference internal" href="#mrp-areas" id="id16">MRP Areas</a></li> <li><a class="reference internal" href="#mrp-areas" id="id17">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="#product-mrp-area-parameters" id="id18">Product MRP Area Parameters</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference internal" href="#usage" id="id18">Usage</a></li> <li><a class="reference internal" href="#usage" id="id19">Usage</a></li>
<li><a class="reference internal" href="#changelog" id="id19">Changelog</a><ul> <li><a class="reference internal" href="#changelog" id="id20">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="#id1" id="id21">13.0.1.0.0 (2019-12-18)</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="#id2" id="id22">12.0.1.0.0 (2019-08-05)</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="#id3" id="id23">11.0.3.0.0 (2019-05-22)</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="#id5" id="id24">11.0.2.2.0 (2019-05-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="#id7" id="id25">11.0.2.1.0 (2019-04-02)</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="#id9" id="id26">11.0.2.0.0 (2018-11-20)</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="#id11" id="id27">11.0.1.1.0 (2018-08-30)</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="#id13" id="id28">11.0.1.0.1 (2018-08-03)</a></li>
<li><a class="reference internal" href="#id15" id="id29">11.0.1.0.0 (2018-07-09)</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference internal" href="#bug-tracker" id="id28">Bug Tracker</a></li> <li><a class="reference internal" href="#bug-tracker" id="id30">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id29">Credits</a><ul> <li><a class="reference internal" href="#credits" id="id31">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id30">Authors</a></li> <li><a class="reference internal" href="#authors" id="id32">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id31">Contributors</a></li> <li><a class="reference internal" href="#contributors" id="id33">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id32">Maintainers</a></li> <li><a class="reference internal" href="#maintainers" id="id34">Maintainers</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
</div> </div>
<div class="section" id="configuration"> <div class="section" id="configuration">
<h2><a class="toc-backref" href="#id15">Configuration</a></h2> <h2><a class="toc-backref" href="#id16">Configuration</a></h2>
<div class="section" id="mrp-areas"> <div class="section" id="mrp-areas">
<h3><a class="toc-backref" href="#id16">MRP Areas</a></h3> <h3><a class="toc-backref" href="#id17">MRP Areas</a></h3>
<ul class="simple"> <ul class="simple">
<li>Go to <em>Manufacturing &gt; Configuration &gt; MRP Areas</em> and define or edit <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> any existing area. You can specify the working hours for every area.</li>
</ul> </ul>
</div> </div>
<div class="section" id="product-mrp-area-parameters"> <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="#id18">Product MRP Area Parameters</a></h3>
<ul class="simple"> <ul class="simple">
<li>Go to <em>Manufacturing &gt; Master Data &gt; Product MRP Area Parameters</em> and set <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> 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> </div>
<div class="section" id="usage"> <div class="section" id="usage">
<h2><a class="toc-backref" href="#id18">Usage</a></h2> <h2><a class="toc-backref" href="#id19">Usage</a></h2>
<p>To manually run the MRP scheduler:</p> <p>To manually run the MRP scheduler:</p>
<ol class="arabic simple"> <ol class="arabic simple">
<li>Go to <em>Manufacturing &gt; Operations &gt; Run MRP Multi Level</em>.</li> <li>Go to <em>Manufacturing &gt; Operations &gt; Run MRP Multi Level</em>.</li>
@@ -447,9 +448,15 @@ hand side gears in any record.</li>
</ol> </ol>
</div> </div>
<div class="section" id="changelog"> <div class="section" id="changelog">
<h2><a class="toc-backref" href="#id19">Changelog</a></h2> <h2><a class="toc-backref" href="#id20">Changelog</a></h2>
<div class="section" id="id1"> <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="#id21">13.0.1.0.0 (2019-12-18)</a></h3>
<ul class="simple">
<li>[MIG] Migration to v13.</li>
</ul>
</div>
<div class="section" id="id2">
<h3><a class="toc-backref" href="#id22">12.0.1.0.0 (2019-08-05)</a></h3>
<ul class="simple"> <ul class="simple">
<li>[MIG] Migration to v12:<ul> <li>[MIG] Migration to v12:<ul>
<li>Estimates as a forecasting mechanism is moved to a new module <li>Estimates as a forecasting mechanism is moved to a new module
@@ -458,31 +465,31 @@ hand side gears in any record.</li>
</li> </li>
</ul> </ul>
</div> </div>
<div class="section" id="id2"> <div class="section" id="id3">
<h3><a class="toc-backref" href="#id21">11.0.3.0.0 (2019-05-22)</a></h3> <h3><a class="toc-backref" href="#id23">11.0.3.0.0 (2019-05-22)</a></h3>
<ul class="simple"> <ul class="simple">
<li>[REW/IMP] Rework to include Planned Orders. <li>[REW/IMP] Rework to include Planned Orders.
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/365">#365</a>).</li> (<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> <li>[IMP] Able to procure from a different location than the areas location.</li>
</ul> </ul>
</div> </div>
<div class="section" id="id4"> <div class="section" id="id5">
<h3><a class="toc-backref" href="#id22">11.0.2.2.0 (2019-05-02)</a></h3> <h3><a class="toc-backref" href="#id24">11.0.2.2.0 (2019-05-02)</a></h3>
<ul class="simple"> <ul class="simple">
<li>[IMP] Able to run MRP only for selected areas. <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> (<a class="reference external" href="https://github.com/OCA/manufacture/pull/360">#360</a>).</li>
</ul> </ul>
</div> </div>
<div class="section" id="id6"> <div class="section" id="id7">
<h3><a class="toc-backref" href="#id23">11.0.2.1.0 (2019-04-02)</a></h3> <h3><a class="toc-backref" href="#id25">11.0.2.1.0 (2019-04-02)</a></h3>
<ul class="simple"> <ul class="simple">
<li>[IMP] Implement <em>Nbr. Days</em> functionality to be able to group demand when <li>[IMP] Implement <em>Nbr. Days</em> functionality to be able to group demand when
generating supply proposals. generating supply proposals.
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/345">#345</a>).</li> (<a class="reference external" href="https://github.com/OCA/manufacture/pull/345">#345</a>).</li>
</ul> </ul>
</div> </div>
<div class="section" id="id8"> <div class="section" id="id9">
<h3><a class="toc-backref" href="#id24">11.0.2.0.0 (2018-11-20)</a></h3> <h3><a class="toc-backref" href="#id26">11.0.2.0.0 (2018-11-20)</a></h3>
<ul class="simple"> <ul class="simple">
<li>[REW] Refactor MRP Area. <li>[REW] Refactor MRP Area.
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/322">#322</a>):<ul> (<a class="reference external" href="https://github.com/OCA/manufacture/pull/322">#322</a>):<ul>
@@ -494,15 +501,15 @@ different areas.</li>
</li> </li>
</ul> </ul>
</div> </div>
<div class="section" id="id10"> <div class="section" id="id11">
<h3><a class="toc-backref" href="#id25">11.0.1.1.0 (2018-08-30)</a></h3> <h3><a class="toc-backref" href="#id27">11.0.1.1.0 (2018-08-30)</a></h3>
<ul class="simple"> <ul class="simple">
<li>[FIX] Consider <em>Qty Multiple</em> on product to propose the quantity to procure. <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> (<a class="reference external" href="https://github.com/OCA/manufacture/pull/297">#297</a>)</li>
</ul> </ul>
</div> </div>
<div class="section" id="id12"> <div class="section" id="id13">
<h3><a class="toc-backref" href="#id26">11.0.1.0.1 (2018-08-03)</a></h3> <h3><a class="toc-backref" href="#id28">11.0.1.0.1 (2018-08-03)</a></h3>
<ul class="simple"> <ul class="simple">
<li>[FIX] User and system locales doesnt break MRP calculation. <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> (<a class="reference external" href="https://github.com/OCA/manufacture/pull/290">#290</a>)</li>
@@ -511,48 +518,48 @@ as a related on MRP Areas.
(<a class="reference external" href="https://github.com/OCA/manufacture/pull/290">#290</a>)</li> (<a class="reference external" href="https://github.com/OCA/manufacture/pull/290">#290</a>)</li>
</ul> </ul>
</div> </div>
<div class="section" id="id14"> <div class="section" id="id15">
<h3><a class="toc-backref" href="#id27">11.0.1.0.0 (2018-07-09)</a></h3> <h3><a class="toc-backref" href="#id29">11.0.1.0.0 (2018-07-09)</a></h3>
<ul class="simple"> <ul class="simple">
<li>Start of the history.</li> <li>Start of the history.</li>
</ul> </ul>
</div> </div>
</div> </div>
<div class="section" id="bug-tracker"> <div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#id28">Bug Tracker</a></h2> <h2><a class="toc-backref" href="#id30">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/issues">GitHub Issues</a>. <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. 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 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:%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/manufacture/issues/new?body=module:%20mrp_multi_level%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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
<h2><a class="toc-backref" href="#id29">Credits</a></h2> <h2><a class="toc-backref" href="#id31">Credits</a></h2>
<div class="section" id="authors"> <div class="section" id="authors">
<h3><a class="toc-backref" href="#id30">Authors</a></h3> <h3><a class="toc-backref" href="#id32">Authors</a></h3>
<ul class="simple"> <ul class="simple">
<li>Ucamco</li> <li>Ucamco</li>
<li>Eficent</li> <li>ForgeFlow</li>
</ul> </ul>
</div> </div>
<div class="section" id="contributors"> <div class="section" id="contributors">
<h3><a class="toc-backref" href="#id31">Contributors</a></h3> <h3><a class="toc-backref" href="#id33">Contributors</a></h3>
<ul class="simple"> <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>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>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;eficent.com">lois.rilo&#64;eficent.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>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h3><a class="toc-backref" href="#id32">Maintainers</a></h3> <h3><a class="toc-backref" href="#id34">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p> <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> <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 <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</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>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/13.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> <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>
</div> </div>

View File

@@ -1,9 +1,9 @@
# 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). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from datetime import datetime, timedelta from datetime import datetime, timedelta
from odoo.tests import Form
from odoo.tests.common import SavepointCase from odoo.tests.common import SavepointCase
@@ -209,6 +209,7 @@ class TestMrpMultiLevelCommon(SavepointCase):
"picking_type_id": cls.env.ref("stock.picking_type_out").id, "picking_type_id": cls.env.ref("stock.picking_type_out").id,
"location_id": cls.stock_location.id, "location_id": cls.stock_location.id,
"location_dest_id": cls.customer_location.id, "location_dest_id": cls.customer_location.id,
"scheduled_date": date_move,
"move_lines": [ "move_lines": [
( (
0, 0,
@@ -249,6 +250,7 @@ class TestMrpMultiLevelCommon(SavepointCase):
"picking_type_id": cls.env.ref("stock.picking_type_out").id, "picking_type_id": cls.env.ref("stock.picking_type_out").id,
"location_id": cls.stock_location.id, "location_id": cls.stock_location.id,
"location_dest_id": cls.customer_location.id, "location_dest_id": cls.customer_location.id,
"scheduled_date": date_move,
"move_lines": [ "move_lines": [
( (
0, 0,
@@ -323,15 +325,7 @@ class TestMrpMultiLevelCommon(SavepointCase):
# Create test MO: # Create test MO:
date_mo = cls.calendar.plan_days(9 + 1, datetime.today().replace(hour=0)).date() date_mo = cls.calendar.plan_days(9 + 1, datetime.today().replace(hour=0)).date()
bom_fp_2 = cls.env.ref("mrp_multi_level.mrp_bom_fp_2") bom_fp_2 = cls.env.ref("mrp_multi_level.mrp_bom_fp_2")
cls.mo = cls.mo_obj.create( cls.mo = cls._create_mo(cls.fp_2, bom_fp_2, date_mo, qty=12.0)
{
"product_id": cls.fp_2.id,
"bom_id": bom_fp_2.id,
"product_qty": 12.0,
"product_uom_id": cls.fp_2.uom_id.id,
"date_planned_start": date_mo,
}
)
# Dates: # Dates:
today = datetime.today().replace(hour=0) today = datetime.today().replace(hour=0)
@@ -361,6 +355,7 @@ class TestMrpMultiLevelCommon(SavepointCase):
"picking_type_id": cls.env.ref("stock.picking_type_out").id, "picking_type_id": cls.env.ref("stock.picking_type_out").id,
"location_id": cls.sec_loc.id, "location_id": cls.sec_loc.id,
"location_dest_id": cls.customer_location.id, "location_dest_id": cls.customer_location.id,
"scheduled_date": date_move,
"move_lines": [ "move_lines": [
( (
0, 0,
@@ -403,6 +398,7 @@ class TestMrpMultiLevelCommon(SavepointCase):
"picking_type_id": cls.env.ref("stock.picking_type_in").id, "picking_type_id": cls.env.ref("stock.picking_type_in").id,
"location_id": cls.supplier_location.id, "location_id": cls.supplier_location.id,
"location_dest_id": location.id, "location_dest_id": location.id,
"scheduled_date": date_move,
"move_lines": [ "move_lines": [
( (
0, 0,
@@ -433,6 +429,7 @@ class TestMrpMultiLevelCommon(SavepointCase):
"picking_type_id": cls.env.ref("stock.picking_type_out").id, "picking_type_id": cls.env.ref("stock.picking_type_out").id,
"location_id": location.id, "location_id": location.id,
"location_dest_id": cls.customer_location.id, "location_dest_id": cls.customer_location.id,
"scheduled_date": date_move,
"move_lines": [ "move_lines": [
( (
0, 0,
@@ -453,3 +450,15 @@ class TestMrpMultiLevelCommon(SavepointCase):
) )
picking.action_confirm() picking.action_confirm()
return picking return picking
@classmethod
def _create_mo(cls, product, bom, date, qty=10.0):
mo_form = Form(cls.mo_obj)
mo_form.product_id = product
mo_form.bom_id = bom
mo_form.product_qty = qty
mo_form.date_planned_start = date
mo = mo_form.save()
# Confirm the MO to generate stock moves:
mo.action_confirm()
return mo

View File

@@ -1,10 +1,9 @@
# 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). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import fields from odoo import fields
from odoo.addons.mrp_multi_level.tests.common import TestMrpMultiLevelCommon from .common import TestMrpMultiLevelCommon
class TestMrpMultiLevel(TestMrpMultiLevelCommon): class TestMrpMultiLevel(TestMrpMultiLevelCommon):
@@ -83,11 +82,10 @@ class TestMrpMultiLevel(TestMrpMultiLevelCommon):
self.assertEqual(len(fp_2_line_1), 1) self.assertEqual(len(fp_2_line_1), 1)
self.assertEqual(fp_2_line_1.demand_qty, 15.0) self.assertEqual(fp_2_line_1.demand_qty, 15.0)
self.assertEqual(fp_2_line_1.to_procure, 15.0) self.assertEqual(fp_2_line_1.to_procure, 15.0)
# TODO: ask odoo to fix it... should be date10
fp_2_line_2 = self.mrp_inventory_obj.search( fp_2_line_2 = self.mrp_inventory_obj.search(
[ [
("product_mrp_area_id.product_id", "=", self.fp_2.id), ("product_mrp_area_id.product_id", "=", self.fp_2.id),
("date", "=", self.date_9), ("date", "=", self.date_10),
] ]
) )
self.assertEqual(len(fp_2_line_2), 1) self.assertEqual(len(fp_2_line_2), 1)
@@ -280,7 +278,7 @@ class TestMrpMultiLevel(TestMrpMultiLevelCommon):
def test_09_isolated_mrp_area_run(self): def test_09_isolated_mrp_area_run(self):
"""Test running MRP for just one area.""" """Test running MRP for just one area."""
self.mrp_multi_level_wiz.sudo(self.mrp_manager).create( self.mrp_multi_level_wiz.with_user(self.mrp_manager).create(
{"mrp_area_ids": [(6, 0, self.secondary_area.ids)]} {"mrp_area_ids": [(6, 0, self.secondary_area.ids)]}
).run_mrp_multi_level() ).run_mrp_multi_level()
this = self.mrp_inventory_obj.search( this = self.mrp_inventory_obj.search(

View File

@@ -23,17 +23,13 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="MRP Area"> <form string="MRP Area">
<sheet> <sheet>
<div class="oe_button_box" name="button_box"> <div class="oe_button_box" name="button_box"/>
<button name="toggle_active" type="object" <widget name="web_ribbon" title="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<label for="name" class="oe_edit_only"/> <label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1> <h1><field name="name"/></h1>
<group colspan="4" col="2"> <group colspan="4" col="2">
<group> <group>
<field name="active" invisible="1"/>
<field name="warehouse_id"/> <field name="warehouse_id"/>
<field name="location_id"/> <field name="location_id"/>
<field name="company_id" groups="base.group_multi_company"/> <field name="company_id" groups="base.group_multi_company"/>
@@ -51,7 +47,6 @@
<field name="name">MRP Area</field> <field name="name">MRP Area</field>
<field name="res_model">mrp.area</field> <field name="res_model">mrp.area</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<field name="view_id" ref="mrp_area_tree"/> <field name="view_id" ref="mrp_area_tree"/>
</record> </record>

View File

@@ -121,7 +121,6 @@
<field name="name">MRP Inventory</field> <field name="name">MRP Inventory</field>
<field name="res_model">mrp.inventory</field> <field name="res_model">mrp.inventory</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,pivot,graph</field> <field name="view_mode">tree,form,pivot,graph</field>
<field name="view_id" ref="mrp_inventory_tree"/> <field name="view_id" ref="mrp_inventory_tree"/>
<field name="search_view_id" ref="mrp_inventory_search"/> <field name="search_view_id" ref="mrp_inventory_search"/>

View File

@@ -33,15 +33,11 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Product MRP Area parameters"> <form string="Product MRP Area parameters">
<sheet> <sheet>
<div class="oe_button_box" name="button_box"> <div class="oe_button_box" name="button_box"/>
<button name="toggle_active" type="object" <widget name="web_ribbon" title="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<group colspan="4" col="2"> <group colspan="4" col="2">
<group> <group>
<field name="active" invisible="1"/>
<field name="mrp_area_id"/> <field name="mrp_area_id"/>
<field name="company_id" groups="base.group_multi_company"/> <field name="company_id" groups="base.group_multi_company"/>
<field name="product_tmpl_id" invisible="1"/> <field name="product_tmpl_id" invisible="1"/>
@@ -120,7 +116,6 @@
<field name="name">Product MRP Area Parameters</field> <field name="name">Product MRP Area Parameters</field>
<field name="res_model">product.mrp.area</field> <field name="res_model">product.mrp.area</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<field name="view_id" ref="product_mrp_area_tree"/> <field name="view_id" ref="product_mrp_area_tree"/>
<field name="search_view_id" ref="product_mrp_area_search"/> <field name="search_view_id" ref="product_mrp_area_search"/>

View File

@@ -1,5 +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). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, fields, models from odoo import _, api, fields, models
@@ -64,30 +63,36 @@ class MrpInventoryProcure(models.TransientModel):
res["item_ids"] = [(6, 0, items.ids)] res["item_ids"] = [(6, 0, items.ids)]
return res return res
@api.multi
def make_procurement(self): def make_procurement(self):
self.ensure_one() self.ensure_one()
errors = [] errors = []
pg = self.env["procurement.group"]
procurements = []
for item in self.item_ids: for item in self.item_ids:
if not item.qty: if not item.qty:
raise ValidationError(_("Quantity must be positive.")) raise ValidationError(_("Quantity must be positive."))
values = item._prepare_procurement_values() values = item._prepare_procurement_values()
# Run procurement procurements.append(
try: pg.Procurement(
self.env["procurement.group"].run(
item.product_id, item.product_id,
item.qty, item.qty,
item.uom_id, item.uom_id,
item.location_id, item.location_id,
"INT: " + str(self.env.user.login), # name? "MRP: " + str(self.env.user.login), # name?
"INT: " + str(self.env.user.login), # origin? "MRP: " + str(self.env.user.login), # origin?
item.mrp_inventory_id.company_id,
values, values,
) )
)
# Run procurements
try:
pg.run(procurements)
for item in self.item_ids:
item.planned_order_id.qty_released += item.qty item.planned_order_id.qty_released += item.qty
except UserError as error: except UserError as error:
errors.append(error.name) errors.append(error.name)
if errors: if errors:
raise UserError("\n".join(errors)) raise UserError("\n".join(errors))
return {"type": "ir.actions.act_window_close"} return {"type": "ir.actions.act_window_close"}
@@ -122,7 +127,6 @@ class MrpInventoryProcureItem(models.TransientModel):
"group_id": group, "group_id": group,
} }
@api.multi
@api.onchange("uom_id") @api.onchange("uom_id")
def onchange_uom_id(self): def onchange_uom_id(self):
for rec in self: for rec in self:

View File

@@ -1,7 +1,7 @@
# Copyright 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com> # 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> # - Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
# - Lois Rilo <lois.rilo@eficent.com> # - Lois Rilo <lois.rilo@forgeflow.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
import logging import logging
@@ -298,7 +298,9 @@ class MultiLevelMrp(models.TransientModel):
products.write({"llc": llc}) products.write({"llc": llc})
products = self.env["product.product"].search([("llc", "=", llc)]) products = self.env["product.product"].search([("llc", "=", llc)])
counter = len(products) counter = len(products)
log_msg = "Low level code {} finished - Nbr. products: {}".format(llc, counter) log_msg = "Low level code {} finished - Nbr. products: {}".format(
llc, counter
)
logger.info(log_msg) logger.info(log_msg)
mrp_lowest_llc = llc mrp_lowest_llc = llc
@@ -473,8 +475,7 @@ class MultiLevelMrp(models.TransientModel):
continue continue
init_counter += 1 init_counter += 1
log_msg = "MRP Init: {} - {} ".format( log_msg = "MRP Init: {} - {} ".format(
init_counter, init_counter, product_mrp_area.display_name
product_mrp_area.display_name,
) )
logger.info(log_msg) logger.info(log_msg)
self._init_mrp_move(product_mrp_area) self._init_mrp_move(product_mrp_area)
@@ -603,8 +604,7 @@ class MultiLevelMrp(models.TransientModel):
counter += 1 counter += 1
log_msg = "MRP Calculation LLC {} Finished - Nbr. products: {}".format( log_msg = "MRP Calculation LLC {} Finished - Nbr. products: {}".format(
llc - 1, llc - 1, counter
counter,
) )
logger.info(log_msg) logger.info(log_msg)
@@ -723,7 +723,6 @@ class MultiLevelMrp(models.TransientModel):
self._init_mrp_inventory(product_mrp_area) self._init_mrp_inventory(product_mrp_area)
logger.info("End MRP final process") logger.info("End MRP final process")
@api.multi
def run_mrp_multi_level(self): def run_mrp_multi_level(self):
self._mrp_cleanup(self.mrp_area_ids) self._mrp_cleanup(self.mrp_area_ids)
mrp_lowest_llc = self._low_level_code_calculation() mrp_lowest_llc = self._low_level_code_calculation()

View File

@@ -20,10 +20,9 @@
<act_window name="Run MRP" <act_window name="Run MRP"
res_model="mrp.multi.level" res_model="mrp.multi.level"
src_model="mrp.multi.level" binding_model="mrp.multi.level"
view_mode="form" view_mode="form"
target="new" target="new"
key2="client_action_multi"
id="action_mrp_multi_level"/> id="action_mrp_multi_level"/>
</odoo> </odoo>