mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[FIX] mrp_operations_extension
Phantom bom lines with workorder association When installing variants, it doesn't assign corresponding wo to scheduled product Domain added to avoid selecting workorders that don't apply
This commit is contained in:
9
mrp_operations_extension/README.rst
Normal file
9
mrp_operations_extension/README.rst
Normal file
@@ -0,0 +1,9 @@
|
||||
MRP operations extension module
|
||||
===============================
|
||||
|
||||
This module adds:
|
||||
|
||||
- New table to store operations to avoid typing them again.
|
||||
- Adds a relation from WorkcenterLines to BOM Lists.
|
||||
- Adds a relation from WorkcenterLines to Manufacturing Orders in Scheduled/Consumed/Finished Products.
|
||||
- Adds a relation between Routing Work Center Lines and Work Center extra Info.
|
||||
@@ -20,32 +20,24 @@
|
||||
{
|
||||
"name": "MRP Operations Extension",
|
||||
"version": "1.0",
|
||||
"description": """
|
||||
This module adds:
|
||||
|
||||
- New table to store operations to avoid typing them again.
|
||||
- Adds a relation from WorkcenterLines to BOM Lists.
|
||||
- Adds a relation from WorkcenterLines to Manufacturing Orders in
|
||||
Scheduled/Consumed/Finished Products.
|
||||
- Adds a relation between Routing Work Center Lines and Work Center extra
|
||||
Info.
|
||||
|
||||
""",
|
||||
"category": "Manufacturing",
|
||||
"data": ['wizard/mrp_workorder_produce_view.xml',
|
||||
'views/mrp_workcenter_view.xml',
|
||||
'views/mrp_routing_operation_view.xml',
|
||||
'views/mrp_production_view.xml',
|
||||
'views/mrp_bom_view.xml',
|
||||
'views/mrp_routing_workcenter_view.xml',
|
||||
'security/ir.model.access.csv'
|
||||
],
|
||||
"data": [
|
||||
"wizard/mrp_workorder_produce_view.xml",
|
||||
"views/mrp_workcenter_view.xml",
|
||||
"views/mrp_routing_operation_view.xml",
|
||||
"views/mrp_production_view.xml",
|
||||
"views/mrp_bom_view.xml",
|
||||
"views/mrp_routing_workcenter_view.xml",
|
||||
"security/ir.model.access.csv"
|
||||
],
|
||||
"author": "OdooMRP team",
|
||||
"website": "http://www.odoomrp.com",
|
||||
"contributors": [
|
||||
"Daniel Campos <danielcampos@avanzosc.es>",
|
||||
"Mikel Arregi <mikelarregi@avanzosc.es>",
|
||||
"Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>",
|
||||
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
|
||||
"Ana Juaristi <ajuaristio@gmail.com>",
|
||||
],
|
||||
"depends": [
|
||||
"mrp_operations",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, fields, tools, api
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class MrpBom(models.Model):
|
||||
@@ -46,11 +46,12 @@ class MrpBom(models.Model):
|
||||
routing_line_id = routing_lines[0].id
|
||||
elif len(routing_lines) > 1:
|
||||
for routing_line in routing_lines:
|
||||
name_val = tools.ustr(routing_line.name) + ' - '
|
||||
name_val = '%s - ' % (routing_line.name)
|
||||
if name_val in work_order['name']:
|
||||
routing_line_id = routing_line.id
|
||||
break
|
||||
work_order['routing_wc_line'] = routing_line_id
|
||||
if 'routing_wc_line' not in work_order:
|
||||
work_order['routing_wc_line'] = routing_line_id
|
||||
return result2
|
||||
|
||||
|
||||
|
||||
@@ -27,10 +27,12 @@ class MrpProduction(models.Model):
|
||||
res = super(MrpProduction,
|
||||
self)._action_compute_lines(properties=properties)
|
||||
self._get_workorder_in_product_lines(self.workcenter_lines,
|
||||
self.product_lines)
|
||||
self.product_lines,
|
||||
properties=properties)
|
||||
return res
|
||||
|
||||
def _get_workorder_in_product_lines(self, workcenter_lines, product_lines):
|
||||
def _get_workorder_in_product_lines(self, workcenter_lines, product_lines,
|
||||
properties=None):
|
||||
for p_line in product_lines:
|
||||
for bom_line in self.bom_id.bom_line_ids:
|
||||
if bom_line.product_id.id == p_line.product_id.id:
|
||||
@@ -38,6 +40,18 @@ class MrpProduction(models.Model):
|
||||
if wc_line.routing_wc_line.id == bom_line.operation.id:
|
||||
p_line.work_order = wc_line.id
|
||||
break
|
||||
elif bom_line.type == 'phantom':
|
||||
bom_obj = self.env['mrp.bom']
|
||||
bom_id = bom_obj._bom_find(
|
||||
product_id=bom_line.product_id.id,
|
||||
properties=properties)
|
||||
for bom_line2 in bom_obj.browse(bom_id).bom_line_ids:
|
||||
if bom_line2.product_id.id == p_line.product_id.id:
|
||||
for wc_line in workcenter_lines:
|
||||
if (wc_line.routing_wc_line.id ==
|
||||
bom_line2.operation.id):
|
||||
p_line.work_order = wc_line.id
|
||||
break
|
||||
|
||||
def _get_workorder_in_move_lines(self, product_lines, move_lines):
|
||||
for move_line in move_lines:
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="mrp_bom_form_view_inh" model="ir.ui.view">
|
||||
<record id="mrp_bom_form_view_inh" model="ir.ui.view">
|
||||
<field name="name">mrp.bom.form.inh</field>
|
||||
<field name="model">mrp.bom</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_bom_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//tree/field[@name='product_id']" position="after">
|
||||
<field name="operation" domain="[('routing_id', '=', parent.routing_id)]"/>
|
||||
<xpath expr="//tree/field[@name='product_id']"
|
||||
position="after">
|
||||
<field name="operation"
|
||||
domain="[('routing_id', '=', parent.routing_id)]"
|
||||
groups="mrp.group_mrp_routings" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
<field name="inherit_id" ref="mrp.mrp_production_product_tree_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="after">
|
||||
<field name="work_order" />
|
||||
<field name="work_order" groups="mrp.group_mrp_routings"
|
||||
domain="[('production_id', '=', production_id)]" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -19,7 +20,9 @@
|
||||
<field name="inherit_id" ref="mrp.mrp_production_product_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="after">
|
||||
<field name="work_order" />
|
||||
<field name="production_id" invisible="1" />
|
||||
<field name="work_order" groups="mrp.group_mrp_routings"
|
||||
domain="[('production_id', '=', production_id)]" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -32,22 +35,22 @@
|
||||
<xpath
|
||||
expr="//page//group[@string='Products to Consume']//field[@name='product_id']"
|
||||
position="after">
|
||||
<field name="work_order" />
|
||||
<field name="work_order" groups="mrp.group_mrp_routings" />
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//page//group[@string='Consumed Products']//field[@name='product_id']"
|
||||
position="after">
|
||||
<field name="work_order" />
|
||||
<field name="work_order" groups="mrp.group_mrp_routings" />
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//page//group[@string='Products to Produce']//field[@name='product_id']"
|
||||
position="after">
|
||||
<field name="work_order" />
|
||||
<field name="work_order" groups="mrp.group_mrp_routings" />
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//page//group[@string='Produced Products']//field[@name='product_id']"
|
||||
position="after">
|
||||
<field name="work_order" />
|
||||
<field name="work_order" groups="mrp.group_mrp_routings" />
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//field[@name='workcenter_lines']/form//field[@name='name']"
|
||||
|
||||
Reference in New Issue
Block a user