[9.0][REW] mrp_mto_with_stock: Rework to remove dependency and enhance flexibility

This commit is contained in:
lreficent
2017-05-03 19:00:33 +02:00
committed by Florian da Costa
parent 376a2450c7
commit 2c9ee842ae
6 changed files with 43 additions and 6 deletions

View File

@@ -17,8 +17,9 @@ Configuration
To configure this module, you need to:
#. Go to the products you want to follow this behaviour.
#. In the view form got to the tab *Inventory* and check the box for the
route *Make To Order + Make To Stock*.
#. In the view form go to the tab *Inventory* and set the *Manufacturing
MTO/MTS Locations*. Any other location not specified here will have the
standard behavior.
Usage
=====

View File

@@ -14,5 +14,6 @@
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["mrp", "stock_mts_mto_rule"],
"depends": ["mrp"],
"data": ['views/product_template_view.xml'],
}

View File

@@ -4,3 +4,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import mrp
from . import product_template

View File

@@ -30,10 +30,9 @@ class MrpProduction(models.Model):
# reserve all that is available (standard behaviour):
res = super(MrpProduction, self).action_assign()
# try to create procurements:
mtos_route = self.env.ref('stock_mts_mto_rule.route_mto_mts')
for move in self.move_lines:
if (move.state == 'confirmed' and mtos_route.id in
move.product_id.route_ids.ids):
if (move.state == 'confirmed' and move.location_id in
move.product_id.mrp_mts_mto_location_ids):
domain = [('product_id', '=', move.product_id.id),
('state', '=', 'running'),
('move_dest_id', '=', move.id)]

View File

@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import fields, models
class ProductTemplate(models.Model):
_inherit = 'product.template'
mrp_mts_mto_location_ids = fields.Many2many(
comodel_name='stock.location',
string='Manufacturing MTO/MTS Locations',
help='These manufacturing locations will create procurements when '
'there is no stock availale in the source location.')

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="view_template_property_form" model="ir.ui.view">
<field name="name">product.template.form - mrp_mto_with_stock
extension</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.view_template_property_form"/>
<field name="arch" type="xml">
<field name="property_stock_inventory" position="after">
<field name="mrp_mts_mto_location_ids" widget="many2many_tags"
options="{'no_create': True}"/>
</field>
</field>
</record>
</odoo>