mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[9.0][REW] mrp_mto_with_stock: Rework to remove dependency and enhance flexibility
This commit is contained in:
committed by
Florian da Costa
parent
376a2450c7
commit
2c9ee842ae
@@ -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
|
||||
=====
|
||||
|
||||
@@ -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'],
|
||||
}
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import mrp
|
||||
from . import product_template
|
||||
|
||||
@@ -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)]
|
||||
|
||||
15
mrp_mto_with_stock/models/product_template.py
Normal file
15
mrp_mto_with_stock/models/product_template.py
Normal 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.')
|
||||
20
mrp_mto_with_stock/views/product_template_view.xml
Normal file
20
mrp_mto_with_stock/views/product_template_view.xml
Normal 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>
|
||||
Reference in New Issue
Block a user