mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
Take draft PO quantities into account for forecast stock in mrp_mto_with_stock
This commit is contained in:
committed by
Lois Rilo
parent
6a1431cf38
commit
738f7f5cf0
@@ -122,6 +122,13 @@ class MrpProduction(models.Model):
|
||||
raise UserError('\n'.join(errors))
|
||||
return True
|
||||
|
||||
# This method should be overriden in submodule to manage cases where
|
||||
# we need to add quantities to the forecast quantity. Like draft purchase
|
||||
# order, purchase request, etc...
|
||||
@api.model
|
||||
def _get_incoming_qty_waiting_validation(self, move):
|
||||
return 0.0
|
||||
|
||||
@api.multi
|
||||
def get_mto_qty_to_procure(self, move):
|
||||
self.ensure_one()
|
||||
@@ -130,6 +137,8 @@ class MrpProduction(models.Model):
|
||||
virtual_available = move_location.product_id.virtual_available
|
||||
qty_available = move.product_id.uom_id._compute_quantity(
|
||||
virtual_available, move.product_uom)
|
||||
draft_incoming_qty = self._get_incoming_qty_waiting_validation(move)
|
||||
qty_available += draft_incoming_qty
|
||||
if qty_available >= 0:
|
||||
return 0.0
|
||||
else:
|
||||
|
||||
5
mrp_mto_with_stock_purchase/__init__.py
Normal file
5
mrp_mto_with_stock_purchase/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 Akretion
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import models
|
||||
21
mrp_mto_with_stock_purchase/__manifest__.py
Normal file
21
mrp_mto_with_stock_purchase/__manifest__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 Akretion
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "MRP MTO with Stock Purchase",
|
||||
"summary": "Module needed to make mrp_mto_with_stock module compatible "
|
||||
"with purchase module.",
|
||||
"author": "Akretion, Odoo Community Association (OCA)",
|
||||
"website": "https://odoo-community.org/",
|
||||
"category": "Manufacturing",
|
||||
"version": "10.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"application": False,
|
||||
"installable": True,
|
||||
"depends": [
|
||||
"mrp_mto_with_stock",
|
||||
"purchase"
|
||||
],
|
||||
"auto_install": True,
|
||||
}
|
||||
5
mrp_mto_with_stock_purchase/models/__init__.py
Normal file
5
mrp_mto_with_stock_purchase/models/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 Akretion
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import mrp_production
|
||||
31
mrp_mto_with_stock_purchase/models/mrp_production.py
Normal file
31
mrp_mto_with_stock_purchase/models/mrp_production.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 Akretion
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = 'mrp.production'
|
||||
|
||||
@api.model
|
||||
def _get_incoming_qty_waiting_validation(self, move):
|
||||
qty = super(MrpProduction, self)._get_incoming_qty_waiting_validation(
|
||||
move)
|
||||
location_ids = self.env['stock.location'].search(
|
||||
[('id', 'child_of', move.location_id.id)])
|
||||
picking_types = self.env['stock.picking.type'].search(
|
||||
[('default_location_dest_id', 'in',
|
||||
location_ids.ids)])
|
||||
orders = self.env['purchase.order'].search(
|
||||
[('picking_type_id', 'in', picking_types.ids),
|
||||
('state', 'in', ['draft', 'sent', 'to approve'])])
|
||||
po_lines = self.env['purchase.order.line'].search(
|
||||
[('order_id', 'in', orders.ids),
|
||||
('product_qty', '>', 0.0),
|
||||
('product_id', '=', move.product_id.id)])
|
||||
for line in po_lines:
|
||||
qty_uom = line.product_uom._compute_quantity(
|
||||
line.product_qty, move.product_uom)
|
||||
qty += qty_uom
|
||||
return qty
|
||||
1
mrp_mto_with_stock_purchase/readme/CONFIGURE.rst
Normal file
1
mrp_mto_with_stock_purchase/readme/CONFIGURE.rst
Normal file
@@ -0,0 +1 @@
|
||||
* This module is installed automatically when mrp_mto_with_stock and purchase module are installed
|
||||
1
mrp_mto_with_stock_purchase/readme/CONTRIBUTORS.rst
Normal file
1
mrp_mto_with_stock_purchase/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1 @@
|
||||
* * Florian da Costa <florian.dacosta@akretion.com>
|
||||
5
mrp_mto_with_stock_purchase/readme/DESCRIPTION.rst
Normal file
5
mrp_mto_with_stock_purchase/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
This module make compatible mrp_mto_with_stock and purchase modules.
|
||||
Indeed, there is an option in mto_mto_with_stock to check the forecast stock
|
||||
when checking the availibility of a Manufacture Order. But this forecast stock
|
||||
does not take into account the quantities coming from draft POs. This module
|
||||
adds this behavior.
|
||||
8
mrp_mto_with_stock_purchase/readme/USAGE.rst
Normal file
8
mrp_mto_with_stock_purchase/readme/USAGE.rst
Normal file
@@ -0,0 +1,8 @@
|
||||
When a manufacturing order is created out of a procurement evaluation
|
||||
(from an orderpoint, MTO,...) the calendar is considered in the computation
|
||||
of the planned start date of the manufacturing order.
|
||||
|
||||
For example, if it takes 1 day to manufacture a product and it is required
|
||||
for Monday, the manufacturing order will be created with planned start date
|
||||
on the previous Friday, if the warehouse operates under a Mo-Fri working
|
||||
calendar.
|
||||
Reference in New Issue
Block a user