mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[11.0][REW/IMP] mrp_multi_level:
* Extract concept of planned orders from mrp.move. * Fix error grouping demand when there is no supply for a the first day of grouping. * Adapt tests.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# © 2016 Ucamco - Wim Audenaert <wim.audenaert@ucamco.com>
|
||||
# Copyright 2016-18 Eficent Business and IT Consulting Services S.L.
|
||||
# Copyright 2016-19 Eficent Business and IT Consulting Services S.L.
|
||||
# - Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||
# - Lois Rilo Antelo <lois.rilo@eficent.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
@@ -17,7 +18,6 @@ class MrpInventory(models.Model):
|
||||
# TODO: name to pass to procurements?
|
||||
# TODO: compute procurement_date to pass to the wizard? not needed for
|
||||
# PO at least. Check for MO and moves
|
||||
# TODO: show a LT based on the procure method?
|
||||
|
||||
mrp_area_id = fields.Many2one(
|
||||
comodel_name='mrp.area', string='MRP Area',
|
||||
@@ -41,18 +41,38 @@ class MrpInventory(models.Model):
|
||||
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')
|
||||
to_procure = fields.Float(
|
||||
string="To procure",
|
||||
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,
|
||||
)
|
||||
planned_order_ids = fields.One2many(
|
||||
comodel_name="mrp.planned.order",
|
||||
inverse_name="mrp_inventory_id",
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _compute_uom_id(self):
|
||||
for rec in self:
|
||||
rec.uom_id = rec.product_mrp_area_id.product_id.uom_id
|
||||
|
||||
@api.depends("planned_order_ids", "planned_order_ids.qty_released")
|
||||
def _compute_to_procure(self):
|
||||
for rec in self:
|
||||
rec.to_procure = sum(rec.planned_order_ids.mapped('mrp_qty')) - \
|
||||
sum(rec.planned_order_ids.mapped('qty_released'))
|
||||
|
||||
@api.multi
|
||||
@api.depends('product_mrp_area_id',
|
||||
'product_mrp_area_id.main_supplierinfo_id',
|
||||
@@ -61,12 +81,7 @@ class MrpInventory(models.Model):
|
||||
def _compute_order_release_date(self):
|
||||
today = date.today()
|
||||
for rec in self.filtered(lambda r: r.date):
|
||||
delay = 0
|
||||
if rec.product_mrp_area_id.supply_method == 'buy':
|
||||
delay = rec.product_mrp_area_id.main_supplierinfo_id.delay
|
||||
elif rec.product_mrp_area_id.supply_method == 'manufacture':
|
||||
delay = rec.product_mrp_area_id.mrp_lead_time
|
||||
# TODO: 'move' supply method
|
||||
delay = rec.product_mrp_area_id.mrp_lead_time
|
||||
if delay and rec.mrp_area_id.calendar_id:
|
||||
dt_date = fields.Datetime.from_string(rec.date)
|
||||
order_release_date = rec.mrp_area_id.calendar_id.plan_days(
|
||||
|
||||
Reference in New Issue
Block a user