mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[15.0][MIG] mrp_multi_level
This commit is contained in:
committed by
JasminSForgeFlow
parent
0695f56084
commit
6eb561e1c3
@@ -23,7 +23,7 @@ MRP Multi Level
|
||||
:target: https://runbot.odoo-community.org/runbot/129/14.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module allows you to calculate, based in known inventory, demand, and
|
||||
supply, and based on parameters set at product variant level, the new
|
||||
@@ -226,6 +226,7 @@ Contributors
|
||||
* Jordi Ballester <jordi.ballester@forgeflow.com>
|
||||
* Lois Rilo <lois.rilo@forgeflow.com>
|
||||
* Héctor Villarreal <hector.villarreal@forgeflow.com>
|
||||
* Christopher Ormaza <chris.ormaza@forgeflow.com>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
@@ -249,7 +250,7 @@ promote its widespread use.
|
||||
|
||||
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|
||||
|
||||
|maintainer-JordiBForgeFlow| |maintainer-LoisRForgeFlow|
|
||||
|maintainer-JordiBForgeFlow| |maintainer-LoisRForgeFlow|
|
||||
|
||||
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/14.0/mrp_multi_level>`_ project on GitHub.
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
# Copyright 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
|
||||
# Copyright 2016-19 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# Copyright 2016-21 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
{
|
||||
"name": "MRP Multi Level",
|
||||
"version": "14.0.1.3.0",
|
||||
"version": "15.0.1.0.0",
|
||||
"development_status": "Production/Stable",
|
||||
"license": "LGPL-3",
|
||||
"author": "Ucamco, ForgeFlow, Odoo Community Association (OCA)",
|
||||
"maintainers": ["JordiBForgeFlow", "LoisRForgeFlow"],
|
||||
"maintainers": ["JordiBForgeFlow", "LoisRForgeFlow", "ChrisOForgeFlow"],
|
||||
"summary": "Adds an MRP Scheduler",
|
||||
"website": "https://github.com/OCA/manufacture",
|
||||
"category": "Manufacturing",
|
||||
|
||||
@@ -1,41 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo noupdate="1">
|
||||
<record id="stock_inventory_mrp_example" model="stock.inventory">
|
||||
<field name="name">Starting On-hand for MRP demo</field>
|
||||
</record>
|
||||
<record id="stock_inventory_line_1" model="stock.inventory.line">
|
||||
<record id="stock_inventory_1" model="stock.quant">
|
||||
<field name="product_id" ref="product_product_pp_1" />
|
||||
<field name="product_uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="inventory_id" ref="stock_inventory_mrp_example" />
|
||||
<field name="product_qty">10</field>
|
||||
<field name="location_id" ref="stock.stock_location_stock" />
|
||||
<field name="inventory_quantity">10</field>
|
||||
<field
|
||||
name="location_id"
|
||||
model="stock.location"
|
||||
eval="obj().env.ref('stock.warehouse0').lot_stock_id.id"
|
||||
/>
|
||||
</record>
|
||||
<record id="stock_inventory_line_2" model="stock.inventory.line">
|
||||
<record id="stock_inventory_2" model="stock.quant">
|
||||
<field name="product_id" ref="product_product_pp_2" />
|
||||
<field name="product_uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="inventory_id" ref="stock_inventory_mrp_example" />
|
||||
<field name="product_qty">20</field>
|
||||
<field name="location_id" ref="stock.stock_location_stock" />
|
||||
<field name="inventory_quantity">20</field>
|
||||
<field
|
||||
name="location_id"
|
||||
model="stock.location"
|
||||
eval="obj().env.ref('stock.warehouse0').lot_stock_id.id"
|
||||
/>
|
||||
</record>
|
||||
<record id="stock_inventory_line_3" model="stock.inventory.line">
|
||||
<record id="stock_inventory_3" model="stock.quant">
|
||||
<field name="product_id" ref="product_product_sf_2" />
|
||||
<field name="product_uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="inventory_id" ref="stock_inventory_mrp_example" />
|
||||
<field name="product_qty">15</field>
|
||||
<field name="location_id" ref="stock.stock_location_stock" />
|
||||
<field name="inventory_quantity">15</field>
|
||||
<field
|
||||
name="location_id"
|
||||
model="stock.location"
|
||||
eval="obj().env.ref('stock.warehouse0').lot_stock_id.id"
|
||||
/>
|
||||
</record>
|
||||
<function model="stock.inventory" name="_action_start">
|
||||
<function
|
||||
eval="[[('id', '=', ref('stock_inventory_mrp_example'))]]"
|
||||
model="stock.inventory"
|
||||
<function model="stock.quant" name="action_apply_inventory">
|
||||
<function
|
||||
eval="[[('id', 'in', (ref('stock_inventory_1'),
|
||||
ref('stock_inventory_2'),
|
||||
ref('stock_inventory_3'),
|
||||
))]]"
|
||||
model="stock.quant"
|
||||
name="search"
|
||||
/>
|
||||
</function>
|
||||
<function model="stock.inventory" name="action_validate">
|
||||
<function
|
||||
eval="[[('id', '=', ref('stock_inventory_mrp_example'))]]"
|
||||
model="stock.inventory"
|
||||
name="search"
|
||||
/>
|
||||
</function>
|
||||
</odoo>
|
||||
</function></odoo>
|
||||
|
||||
@@ -45,21 +45,17 @@ class MrpInventory(models.Model):
|
||||
uom_id = fields.Many2one(
|
||||
comodel_name="uom.uom", string="Product UoM", compute="_compute_uom_id"
|
||||
)
|
||||
date = fields.Date(string="Date")
|
||||
date = fields.Date()
|
||||
demand_qty = fields.Float(string="Demand")
|
||||
supply_qty = fields.Float(string="Supply")
|
||||
initial_on_hand_qty = fields.Float(string="Starting Inventory")
|
||||
final_on_hand_qty = fields.Float(string="Forecasted Inventory")
|
||||
to_procure = fields.Float(
|
||||
string="To procure", compute="_compute_to_procure", store=True
|
||||
)
|
||||
to_procure = fields.Float(compute="_compute_to_procure", store=True)
|
||||
running_availability = fields.Float(
|
||||
string="Planned Availability",
|
||||
help="Theoretical inventory level if all planned orders" "were released.",
|
||||
)
|
||||
order_release_date = fields.Date(
|
||||
string="Order Release Date", compute="_compute_order_release_date", store=True
|
||||
help="Theoretical inventory level if all planned orders were released.",
|
||||
)
|
||||
order_release_date = fields.Date(compute="_compute_order_release_date", store=True)
|
||||
planned_order_ids = fields.One2many(
|
||||
comodel_name="mrp.planned.order", inverse_name="mrp_inventory_id", readonly=True
|
||||
)
|
||||
|
||||
@@ -37,8 +37,8 @@ class MrpMove(models.Model):
|
||||
store=True,
|
||||
)
|
||||
|
||||
current_date = fields.Date(string="Current Date")
|
||||
current_qty = fields.Float(string="Current Qty")
|
||||
current_date = fields.Date()
|
||||
current_qty = fields.Float()
|
||||
mrp_date = fields.Date(string="MRP Date")
|
||||
planned_order_up_ids = fields.Many2many(
|
||||
comodel_name="mrp.planned.order",
|
||||
@@ -87,7 +87,6 @@ class MrpMove(models.Model):
|
||||
("to approve", "To Approve"),
|
||||
("approved", "Approved"),
|
||||
],
|
||||
string="State",
|
||||
)
|
||||
stock_move_id = fields.Many2one(
|
||||
comodel_name="stock.move", string="Stock Move", index=True
|
||||
|
||||
@@ -42,7 +42,6 @@ class MrpPlannedOrder(models.Model):
|
||||
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,
|
||||
)
|
||||
|
||||
@@ -82,7 +82,6 @@ class ProductMRPArea(models.Model):
|
||||
("push", "Push To"),
|
||||
("pull_push", "Pull & Push"),
|
||||
],
|
||||
string="Supply Method",
|
||||
compute="_compute_supply_method",
|
||||
)
|
||||
qty_available = fields.Float(
|
||||
@@ -170,7 +169,7 @@ class ProductMRPArea(models.Model):
|
||||
def _compute_qty_available(self):
|
||||
for rec in self:
|
||||
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
|
||||
|
||||
def _compute_supply_method(self):
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
* Jordi Ballester <jordi.ballester@forgeflow.com>
|
||||
* Lois Rilo <lois.rilo@forgeflow.com>
|
||||
* Héctor Villarreal <hector.villarreal@forgeflow.com>
|
||||
* Christopher Ormaza <chris.ormaza@forgeflow.com>
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from odoo.tests import Form
|
||||
from odoo.tests.common import SavepointCase
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestMrpMultiLevelCommon(SavepointCase):
|
||||
class TestMrpMultiLevelCommon(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
|
||||
@@ -212,11 +212,9 @@ class TestMrpMultiLevel(TestMrpMultiLevelCommon):
|
||||
[("product_mrp_area_id.product_id", "=", self.fp_1.id)]
|
||||
)
|
||||
self.mrp_inventory_procure_wiz.with_context(
|
||||
{
|
||||
"active_model": "mrp.inventory",
|
||||
"active_ids": mrp_inv.ids,
|
||||
"active_id": mrp_inv.id,
|
||||
}
|
||||
active_model="mrp.inventory",
|
||||
active_ids=mrp_inv.ids,
|
||||
active_id=mrp_inv.id,
|
||||
).create({}).make_procurement()
|
||||
mos = self.mo_obj.search([("product_id", "=", self.fp_1.id)])
|
||||
self.assertTrue(mos)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<field name="model">mrp.area</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="MRP Area">
|
||||
<tree>
|
||||
<field name="name" />
|
||||
<field name="warehouse_id" />
|
||||
<field name="company_id" groups="base.group_multi_company" />
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<field name="model">mrp.inventory</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="MRP Inventory" create="false">
|
||||
<tree create="false">
|
||||
<field name="mrp_area_id" />
|
||||
<field name="company_id" groups="base.group_multi_company" />
|
||||
<field name="product_id" />
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<field name="model">product.mrp.area</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Product MRP Area parameters">
|
||||
<tree>
|
||||
<field name="mrp_area_id" />
|
||||
<field name="company_id" groups="base.group_multi_company" />
|
||||
<field name="product_tmpl_id" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2018-19 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# Copyright 2018-21 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
@@ -34,11 +34,11 @@ class MrpInventoryProcure(models.TransientModel):
|
||||
):
|
||||
if self.user_has_groups("mrp_multi_level.group_change_mrp_procure_qty"):
|
||||
view_id = self.env.ref(
|
||||
"mrp_multi_level." "view_mrp_inventory_procure_wizard"
|
||||
"mrp_multi_level.view_mrp_inventory_procure_wizard"
|
||||
).id
|
||||
else:
|
||||
view_id = self.env.ref(
|
||||
"mrp_multi_level." "view_mrp_inventory_procure_without_security"
|
||||
"mrp_multi_level.view_mrp_inventory_procure_without_security"
|
||||
).id
|
||||
return super(MrpInventoryProcure, self).fields_view_get(
|
||||
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
|
||||
@@ -122,7 +122,6 @@ class MrpInventoryProcureItem(models.TransientModel):
|
||||
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"),
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</p>
|
||||
<group name="items" string="Items">
|
||||
<field name="item_ids" nolabel="1">
|
||||
<tree string="Items" nocreate="1" editable="top">
|
||||
<tree nocreate="1" editable="top">
|
||||
<field name="mrp_inventory_id" invisible="True" />
|
||||
<field
|
||||
name="warehouse_id"
|
||||
|
||||
@@ -28,7 +28,7 @@ class MultiLevelMrp(models.TransientModel):
|
||||
product_obj = self.env["product.product"]
|
||||
location_ids = product_mrp_area.mrp_area_id._get_locations()
|
||||
for location in location_ids:
|
||||
product_l = product_obj.with_context({"location": location.id}).browse(
|
||||
product_l = product_obj.with_context(location=location.id).browse(
|
||||
product_mrp_area.product_id.id
|
||||
)
|
||||
qty_available += product_l.qty_available
|
||||
@@ -697,7 +697,9 @@ class MultiLevelMrp(models.TransientModel):
|
||||
mrp_dates = set(moves_dates + action_dates)
|
||||
on_hand_qty = product_mrp_area.product_id.with_context(
|
||||
location=product_mrp_area.mrp_area_id.location_id.id
|
||||
)._product_available()[product_mrp_area.product_id.id]["qty_available"]
|
||||
)._compute_quantities_dict(False, False, False)[product_mrp_area.product_id.id][
|
||||
"qty_available"
|
||||
]
|
||||
running_availability = on_hand_qty
|
||||
mrp_inventory_vals = []
|
||||
for mdt in sorted(mrp_dates):
|
||||
|
||||
Reference in New Issue
Block a user