[10.0][mrp_mto_with_stock] Take draft PO quantities into account for forecast (#301)

This commit is contained in:
Florian
2018-09-10 16:15:47 +02:00
committed by Lois Rilo
parent d888530d37
commit 52a823ec24
10 changed files with 182 additions and 0 deletions

View File

@@ -99,6 +99,15 @@ class MrpProduction(models.Model):
vals['move_dest_id'] = move.id
return vals
@api.model
def _get_incoming_qty_waiting_validation(self, move):
"""
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...
"""
return 0.0
@api.multi
def get_mto_qty_to_procure(self, move):
self.ensure_one()
@@ -107,6 +116,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:

View File

@@ -0,0 +1,94 @@
===========================
MRP MTO with Stock Purchase
===========================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/10.0/mrp_mto_with_stock_purchase
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-10-0/manufacture-10-0-mrp_mto_with_stock_purchase
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/129/10.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
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.
**Table of contents**
.. contents::
:local:
Configuration
=============
* This module is installed automatically when mrp_mto_with_stock and purchase module are installed
Usage
=====
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.
Bug Tracker
===========
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.
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_mto_with_stock_purchase%0Aversion:%2010.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.
Credits
=======
Authors
~~~~~~~
* Akretion
Contributors
~~~~~~~~~~~~
* * Florian da Costa <florian.dacosta@akretion.com>
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
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.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/10.0/mrp_mto_with_stock_purchase>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View 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

View 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://github.com/OCA/manufacture",
"category": "Manufacturing",
"version": "10.0.1.0.0",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"mrp_mto_with_stock",
"purchase"
],
"auto_install": True,
}

View 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

View 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

View File

@@ -0,0 +1 @@
* This module is installed automatically when mrp_mto_with_stock and purchase module are installed

View File

@@ -0,0 +1 @@
* * Florian da Costa <florian.dacosta@akretion.com>

View 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.

View 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.