[MERGE+REVIEW] merged clean yml of mrp

bzr revid: hmo@tinyerp.com-20111208130824-07w4p3zu0ycx3ity
This commit is contained in:
Harry (OpenERP)
2011-12-08 18:38:24 +05:30
22 changed files with 935 additions and 1300 deletions
+4 -7
View File
@@ -90,15 +90,12 @@ Dashboard provided by this module:
],
'demo_xml': [
'mrp_demo.xml',
'mrp_production_order_demo.yml'
],
'test': [
'test/mrp_procurement.yml',
'test/mrp_packs.yml',
'test/mrp_phantom_bom.yml',
'test/mrp_production_order.yml',
'test/mrp_production_cancel.yml',
'test/mrp_report.yml',
'test/order_demo.yml',
'test/order_process.yml',
'test/cancel_order.yml',
],
'installable': True,
'core': True,
+164 -127
View File
@@ -62,8 +62,6 @@ class mrp_workcenter(osv.osv):
}
def on_change_product_cost(self, cr, uid, ids, product_id, context=None):
if context is None:
context = {}
value = {}
if product_id:
@@ -253,8 +251,7 @@ class mrp_bom(osv.osv):
all_prod.append(bom.product_id.id)
lines = bom.bom_lines
if lines:
newboms = [a for a in lines if a not in boms]
res = res and check_bom(newboms)
res = res and check_bom([bom_id for bom_id in lines if bom_id not in boms])
return res
return check_bom(boms)
@@ -269,14 +266,9 @@ class mrp_bom(osv.osv):
@param product_id: Changed product_id
@return: Dictionary of changed values
"""
if context is None:
context = {}
context['lang'] = self.pool.get('res.users').browse(cr,uid,uid).context_lang
if product_id:
prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
v = {'name': prod.name, 'product_uom': prod.uom_id.id}
return {'value': v}
return {'value': {'name': prod.name, 'product_uom': prod.uom_id.id}}
return {}
def _bom_find(self, cr, uid, product_id, product_uom, properties=[]):
@@ -361,8 +353,6 @@ class mrp_bom(osv.osv):
def copy_data(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
if context is None:
context = {}
bom_data = self.read(cr, uid, id, [], context=context)
default.update({'name': bom_data['name'] + ' ' + _('Copy'), 'bom_id':False})
return super(mrp_bom, self).copy_data(cr, uid, id, default, context=context)
@@ -497,8 +487,7 @@ class mrp_production(osv.osv):
_order = 'priority desc, date_planned asc';
def _check_qty(self, cr, uid, ids, context=None):
orders = self.browse(cr, uid, ids, context=context)
for order in orders:
for order in self.browse(cr, uid, ids, context=context):
if order.product_qty <= 0:
return False
return True
@@ -508,13 +497,12 @@ class mrp_production(osv.osv):
]
def unlink(self, cr, uid, ids, context=None):
productions = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for s in productions:
if s['state'] in ['draft','cancel']:
unlink_ids.append(s['id'])
for production in self.read(cr, uid, ids, ['state'], context=context):
if production['state'] in ['draft','cancel']:
unlink_ids.append(production['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete a manufacturing order in the state \'%s\'!') % s['state'])
raise osv.except_osv(_('Invalid action !'), _('Cannot delete a manufacturing order in the state \'%s\'!') % production['state'])
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
def copy(self, cr, uid, id, default=None, context=None):
@@ -577,8 +565,7 @@ class mrp_production(osv.osv):
return {'value': {
'routing_id': False
}}
bom_pool = self.pool.get('mrp.bom')
bom_point = bom_pool.browse(cr, uid, bom_id, context=context)
bom_point = self.pool.get('mrp.bom').browse(cr, uid, bom_id, context=context)
routing_id = bom_point.routing_id.id or False
result = {
'routing_id': routing_id
@@ -747,7 +734,7 @@ class mrp_production(osv.osv):
# if qtys we have to consume is more than qtys available to consume
prod_name = scheduled.product_id.name_get()[0][1]
raise osv.except_osv(_('Warning!'), _('You are going to consume total %s quantities of "%s".\nBut you can consume upto total %s quantities.' % (qty, prod_name, qty_avail)))
if qty < 0.0:
if qty <= 0.0:
# we already have more qtys consumed than we need
continue
@@ -855,119 +842,169 @@ class mrp_production(osv.osv):
def _get_auto_picking(self, cr, uid, production):
return True
def action_confirm(self, cr, uid, ids):
""" Confirms production order.
@return: Newly generated picking Id.
"""
picking_id = False
proc_ids = []
seq_obj = self.pool.get('ir.sequence')
pick_obj = self.pool.get('stock.picking')
move_obj = self.pool.get('stock.move')
proc_obj = self.pool.get('procurement.order')
def _make_production_line_procurement(self, cr, uid, production_line, shipment_move_id, context=None):
wf_service = netsvc.LocalService("workflow")
for production in self.browse(cr, uid, ids):
if not production.product_lines:
self.action_compute(cr, uid, [production.id])
production = self.browse(cr, uid, [production.id])[0]
routing_loc = None
pick_type = 'internal'
address_id = False
if production.bom_id.routing_id and production.bom_id.routing_id.location_id:
routing_loc = production.bom_id.routing_id.location_id
if routing_loc.usage <> 'internal':
pick_type = 'out'
address_id = routing_loc.address_id and routing_loc.address_id.id or False
routing_loc = routing_loc.id
pick_name = seq_obj.get(cr, uid, 'stock.picking.' + pick_type)
picking_id = pick_obj.create(cr, uid, {
'name': pick_name,
'origin': (production.origin or '').split(':')[0] + ':' + production.name,
'type': pick_type,
'move_type': 'one',
'state': 'auto',
'address_id': address_id,
'auto_picking': self._get_auto_picking(cr, uid, production),
'company_id': production.company_id.id,
})
source = production.product_id.product_tmpl_id.property_stock_production.id
data = {
'name':'PROD:' + production.name,
'date': production.date_planned,
'product_id': production.product_id.id,
'product_qty': production.product_qty,
'product_uom': production.product_uom.id,
'product_uos_qty': production.product_uos and production.product_uos_qty or False,
'product_uos': production.product_uos and production.product_uos.id or False,
'location_id': source,
'location_dest_id': production.location_dest_id.id,
'move_dest_id': production.move_prod_id.id,
'state': 'waiting',
'company_id': production.company_id.id,
}
res_final_id = move_obj.create(cr, uid, data)
self.write(cr, uid, [production.id], {'move_created_ids': [(6, 0, [res_final_id])]})
moves = []
for line in production.product_lines:
move_id = False
newdate = production.date_planned
if line.product_id.type in ('product', 'consu'):
res_dest_id = move_obj.create(cr, uid, {
'name':'PROD:' + production.name,
'date': production.date_planned,
'product_id': line.product_id.id,
'product_qty': line.product_qty,
'product_uom': line.product_uom.id,
'product_uos_qty': line.product_uos and line.product_uos_qty or False,
'product_uos': line.product_uos and line.product_uos.id or False,
'location_id': routing_loc or production.location_src_id.id,
'location_dest_id': source,
'move_dest_id': res_final_id,
'state': 'waiting',
'company_id': production.company_id.id,
})
moves.append(res_dest_id)
move_id = move_obj.create(cr, uid, {
'name':'PROD:' + production.name,
'picking_id':picking_id,
'product_id': line.product_id.id,
'product_qty': line.product_qty,
'product_uom': line.product_uom.id,
'product_uos_qty': line.product_uos and line.product_uos_qty or False,
'product_uos': line.product_uos and line.product_uos.id or False,
'date': newdate,
'move_dest_id': res_dest_id,
'location_id': production.location_src_id.id,
'location_dest_id': routing_loc or production.location_src_id.id,
'state': 'waiting',
'company_id': production.company_id.id,
})
proc_id = proc_obj.create(cr, uid, {
'name': (production.origin or '').split(':')[0] + ':' + production.name,
'origin': (production.origin or '').split(':')[0] + ':' + production.name,
'date_planned': newdate,
'product_id': line.product_id.id,
'product_qty': line.product_qty,
'product_uom': line.product_uom.id,
'product_uos_qty': line.product_uos and line.product_qty or False,
'product_uos': line.product_uos and line.product_uos.id or False,
'location_id': production.location_src_id.id,
'procure_method': line.product_id.procure_method,
'move_id': move_id,
procurement_order = self.pool.get('procurement.order')
production = production_line.production_id
location_id = production.location_src_id.id
date_planned = production.date_planned
procurement_name = (production.origin or '').split(':')[0] + ':' + production.name
procurement_id = procurement_order.create(cr, uid, {
'name': procurement_name,
'origin': procurement_name,
'date_planned': date_planned,
'product_id': production_line.product_id.id,
'product_qty': production_line.product_qty,
'product_uom': production_line.product_uom.id,
'product_uos_qty': production_line.product_uos and production_line.product_qty or False,
'product_uos': production_line.product_uos and production_line.product_uos.id or False,
'location_id': location_id,
'procure_method': production_line.product_id.procure_method,
'move_id': shipment_move_id,
'company_id': production.company_id.id,
})
wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr)
proc_ids.append(proc_id)
wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
self.write(cr, uid, [production.id], {'picking_id': picking_id, 'move_lines': [(6,0,moves)], 'state':'confirmed'})
wf_service.trg_validate(uid, procurement_order._name, procurement_id, 'button_confirm', cr)
return procurement_id
def _make_production_internal_shipment_line(self, cr, uid, production_line, shipment_id, parent_move_id, destination_location_id=False, context=None):
stock_move = self.pool.get('stock.move')
production = production_line.production_id
date_planned = production.date_planned
# Internal shipment is created for Stockable and Consumer Products
if production_line.product_id.type not in ('product', 'consu'):
return False
move_name = _('PROD: %s') % production.name
source_location_id = production.location_src_id.id
if not destination_location_id:
destination_location_id = source_location_id
return stock_move.create(cr, uid, {
'name': move_name,
'picking_id': shipment_id,
'product_id': production_line.product_id.id,
'product_qty': production_line.product_qty,
'product_uom': production_line.product_uom.id,
'product_uos_qty': production_line.product_uos and production_line.product_uos_qty or False,
'product_uos': production_line.product_uos and production_line.product_uos.id or False,
'date': date_planned,
'move_dest_id': parent_move_id,
'location_id': source_location_id,
'location_dest_id': destination_location_id,
'state': 'waiting',
'company_id': production.company_id.id,
})
def _make_production_internal_shipment(self, cr, uid, production, context=None):
ir_sequence = self.pool.get('ir.sequence')
stock_picking = self.pool.get('stock.picking')
routing_loc = None
pick_type = 'internal'
address_id = False
# Take routing address as a Shipment Address.
# If usage of routing location is a internal, make outgoing shipment otherwise internal shipment
if production.bom_id.routing_id and production.bom_id.routing_id.location_id:
routing_loc = production.bom_id.routing_id.location_id
if routing_loc.usage <> 'internal':
pick_type = 'out'
address_id = routing_loc.address_id and routing_loc.address_id.id or False
# Take next Sequence number of shipment base on type
pick_name = ir_sequence.get(cr, uid, 'stock.picking.' + pick_type)
picking_id = stock_picking.create(cr, uid, {
'name': pick_name,
'origin': (production.origin or '').split(':')[0] + ':' + production.name,
'type': pick_type,
'move_type': 'one',
'state': 'auto',
'address_id': address_id,
'auto_picking': self._get_auto_picking(cr, uid, production),
'company_id': production.company_id.id,
})
production.write({'picking_id': picking_id}, context=context)
return picking_id
def _make_production_produce_line(self, cr, uid, production, context=None):
stock_move = self.pool.get('stock.move')
source_location_id = production.product_id.product_tmpl_id.property_stock_production.id
destination_location_id = production.location_dest_id.id
move_name = _('PROD: %s') + production.name
data = {
'name': move_name,
'date': production.date_planned,
'product_id': production.product_id.id,
'product_qty': production.product_qty,
'product_uom': production.product_uom.id,
'product_uos_qty': production.product_uos and production.product_uos_qty or False,
'product_uos': production.product_uos and production.product_uos.id or False,
'location_id': source_location_id,
'location_dest_id': destination_location_id,
'move_dest_id': production.move_prod_id.id,
'state': 'waiting',
'company_id': production.company_id.id,
}
move_id = stock_move.create(cr, uid, data, context=context)
production.write({'move_created_ids': [(6, 0, [move_id])]}, context=context)
return move_id
def _make_production_consume_line(self, cr, uid, production_line, parent_move_id, source_location_id=False, context=None):
stock_move = self.pool.get('stock.move')
production = production_line.production_id
# Internal shipment is created for Stockable and Consumer Products
if production_line.product_id.type not in ('product', 'consu'):
return False
move_name = _('PROD: %s') % production.name
destination_location_id = production.product_id.product_tmpl_id.property_stock_production.id
if not source_location_id:
source_location_id = production.location_src_id.id
move_id = move_obj.create(cr, uid, {
'name': move_name,
'date': production.date_planned,
'product_id': production_line.product_id.id,
'product_qty': production_line.product_qty,
'product_uom': production_line.product_uom.id,
'product_uos_qty': production_line.product_uos and production_line.product_uos_qty or False,
'product_uos': production_line.product_uos and production_line.product_uos.id or False,
'location_id': source_location_id,
'location_dest_id': destination_location_id,
'move_dest_id': parent_move_id,
'state': 'waiting',
'company_id': production.company_id.id,
})
production.write('move_lines': [(4, move_id)]}, context=context)
return move_id
def action_confirm(self, cr, uid, ids, context=None):
""" Confirms production order.
@return: Newly generated Shipment Id.
"""
shipment_id = False
wf_service = netsvc.LocalService("workflow")
uncompute_ids = filter(lambda x:x, [not x.product_lines and x.id or False for x in self.browse(cr, uid, ids, context=context)])
self.action_compute(cr, uid, uncompute_ids, context=context)
for production in self.browse(cr, uid, ids, context=context):
shipment_id = self._make_production_internal_shipment(cr, uid, production, context=context)
produce_move_id = self._make_production_produce_line(cr, uid, production, context=context)
# Take routing location as a Source Location.
source_location_id = production.location_src_id.id
if production.bom_id.routing_id and production.bom_id.routing_id.location_id:
source_location_id = production.bom_id.routing_id.location_id.id
for line in production.product_lines:
consume_move_id = self._make_production_consume_line(cr, uid, line, produce_move_id, source_location_id=source_location_id, context=context)
shipment_move_id = self._make_production_internal_shipment_line(cr, uid, line, shipment_id, consume_move_id,\
destination_location_id=source_location_id, context=context)
self._make_production_line_procurement(cr, uid, line, shipment_move_id, context=context)
wf_service.trg_validate(uid, 'stock.picking', shipment_id, 'button_confirm', cr)
production.write({'state':'confirmed'}, context=context)
message = _("Manufacturing order '%s' is scheduled for the %s.") % (
production.name,
datetime.strptime(production.date_planned,'%Y-%m-%d %H:%M:%S').strftime('%m/%d/%Y'),
)
self.log(cr, uid, production.id, message)
return picking_id
return shipment_id
def force_production(self, cr, uid, ids, *args):
""" Assigns products.
+315 -84
View File
@@ -133,15 +133,12 @@
-->
<record id="mrp_routing_0" model="mrp.routing">
<field name="workcenter_lines">[1]</field>
<field name="name">Assembly Line 1</field>
</record>
<record id="mrp_routing_1" model="mrp.routing">
<field name="workcenter_lines">[2]</field>
<field name="name">Custom Assembly Line</field>
</record>
<record id="mrp_routing_2" model="mrp.routing">
<field name="workcenter_lines">[3]</field>
<field name="name">Component Manufacturing</field>
</record>
@@ -168,6 +165,13 @@
<field name="hour_nbr">3</field>
<field name="name">assembly main + processor + fan</field>
</record>
<record id="mrp_routing_workcenter_4" model="mrp.routing.workcenter">
<field name="routing_id" ref="mrp_routing_1"/>
<field name="workcenter_id" ref="mrp_workcenter_1"/>
<field name="name">Packing</field>
<field name="hour_nbr">0.5</field>
<field name="sequence">5</field>
</record>
<!--
Resource: mrp.bom
@@ -214,7 +218,7 @@
<field model="product.product" name="product_id" ref="product.product_product_20"/>
</record>
<record id="mrp_bom_5" model="mrp.bom">
<field name="name">RAM on demand</field>
<field name="name">RAM512 on demand</field>
<field name="sequence">18</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
@@ -254,12 +258,12 @@
<field model="product.product" name="product_id" ref="product.product_product_23"/>
</record>
<record id="mrp_bom_11" model="mrp.bom">
<field name="name">RAM on demand</field>
<field name="name">RAM256 on demand</field>
<field name="sequence">36</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">phantom</field>
<field model="product.product" name="product_id" ref="product.product_product_23"/>
<field model="product.product" name="product_id" ref="product.product_product_21"/>
</record>
<record id="mrp_bom_13" model="mrp.bom">
@@ -267,42 +271,28 @@
<field name="sequence">38</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="routing_id" ref="mrp_routing_1"/>
<field model="product.product" name="product_id" ref="product.product_product_cpu3"/>
</record>
<record id="mrp_bom_kit" model="mrp.bom">
<record id="mrp_bom_kit3" model="mrp.bom">
<field name="code">KIT</field>
<field name="name">Kit Mouse</field>
<field name="name">Kit Keyboard + Mouse</field>
<field name="sequence">40</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
<field name="type">phantom</field>
<field name="bom_id" ref="mrp_bom_10"/>
<field model="product.product" name="product_id" ref="product.product_product_25"/>
</record>
<record id="mrp_bom_clavier" model="mrp.bom">
<field name="name">Keyboard</field>
<field name="sequence">42</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_kit"/>
<field model="product.product" name="product_id" ref="product.product_product_24"/>
</record>
<record id="mrp_bom_mouse" model="mrp.bom">
<field name="name">Mouse</field>
<field name="sequence">44</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_kit"/>
<field model="product.product" name="product_id" ref="product.product_product_25"/>
<field model="product.product" name="product_id" ref="product.product_product_26"/>
</record>
<record id="mrp_bom_16" model="mrp.bom">
<field name="name">Moon PC</field>
<field name="sequence">45</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_10"/>
<field model="product.product" name="product_id" ref="product.product_product_pc1"/>
<field model="product.product" name="product_id" ref="product.product_product_pc2"/>
</record>
<record id="mrp_bom_18" model="mrp.bom">
<field name="name">Mainboard ASUStek A7N8X</field>
@@ -502,6 +492,35 @@
<field name="bom_id" ref="mrp_bom_0"/>
<field model="product.product" name="product_id" ref="product.product_product_ram"/>
</record>
<record id="mrp_bom_kit1" model="mrp.bom">
<field name="code">KIT</field>
<field name="sequence">15</field>
<field name="name">Kit Keyboard + Mouse</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
<field model="product.product" name="product_id" ref="product.product_product_26"/>
</record>
<record id="mrp_bom_mouse2" model="mrp.bom">
<field name="name">Mouse</field>
<field name="sequence">121</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_kit1"/>
<field model="product.product" name="product_id" ref="product.product_product_25"/>
</record>
<record id="mrp_bom_clavier2" model="mrp.bom">
<field name="name">Keyboard</field>
<field name="sequence">123</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_kit1"/>
<field model="product.product" name="product_id" ref="product.product_product_24"/>
</record>
<record id="mrp_bom_41" model="mrp.bom">
<field name="name">Regular processor config</field>
<field name="sequence">111</field>
@@ -536,26 +555,10 @@
<field name="name">Kit Keyboard + Mouse</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="type">normal</field>
<field name="type">phantom</field>
<field name="bom_id" ref="mrp_bom_9"/>
<field model="product.product" name="product_id" ref="product.product_product_26"/>
</record>
<record id="mrp_bom_mouse2" model="mrp.bom">
<field name="name">Mouse</field>
<field name="sequence">121</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_kit2"/>
<field model="product.product" name="product_id" ref="product.product_product_25"/>
</record>
<record id="mrp_bom_clavier2" model="mrp.bom">
<field name="name">Keyboard</field>
<field name="sequence">123</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_kit2"/>
<field model="product.product" name="product_id" ref="product.product_product_24"/>
</record>
<!--
Resource: mrp.bom new EVV
@@ -563,149 +566,379 @@
<record id="mrp_bom_defaultbomforshelfofcm0" model="mrp.bom">
<field name="name">Default BOM for Shelf of 100cm</field>
<field name="code">SHE100</field>
<field name="sequence">129</field>
<field name="sequence">129</field>
<field name="product_id" ref="product.product_product_shelfofcm0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="product_qty">1.0</field>
</record>
<record id="mrp_bom_assemblysection0" model="mrp.bom">
<field name="name">Assembly Section</field>
<field name="sequence">123</field>
<field name="sequence">123</field>
<field name="product_id" ref="product.product_product_assemblysection0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">4.0</field>
<field model="mrp.bom" name="bom_id" search="[('name', '=', u'Default BOM for Shelf of 100cm')]"/>
<field name="product_qty">4.0</field>
<field name="bom_id" ref="mrp_bom_defaultbomforshelfofcm0"/>
</record>
<record id="mrp_bom_sidepanel0" model="mrp.bom">
<field name="name">Side Panel</field>
<field name="sequence">125</field>
<field name="sequence">125</field>
<field name="product_id" ref="product.product_product_sidepanel0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">2.0</field>
<field model="mrp.bom" name="bom_id" search="[('name', '=', u'Default BOM for Shelf of 100cm')]"/>
<field name="product_qty">2.0</field>
<field name="bom_id" ref="mrp_bom_defaultbomforshelfofcm0"/>
</record>
<record id="mrp_bom_metalcleats0" model="mrp.bom">
<field name="name">Metal Cleats</field>
<field name="sequence">127</field>
<field name="sequence">127</field>
<field name="product_id" ref="product.product_product_metalcleats0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">12.0</field>
<field model="mrp.bom" name="bom_id" search="[('name', '=', u'Default BOM for Shelf of 100cm')]"/>
<field name="product_qty">12.0</field>
<field name="bom_id" ref="mrp_bom_defaultbomforshelfofcm0"/>
</record>
<record id="mrp_bom_rearpanelarm0" model="mrp.bom">
<field name="sequence">131</field>
<field name="sequence">131</field>
<field name="product_id" ref="product.product_product_rearpanelarm0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="bom_id" ref="mrp_bom_defaultbomforshelfofcm0"/>
<field name="product_qty">1.0</field>
<field name="product_qty">1.0</field>
<field name="name">Rear panel SHE100</field>
</record>
<record id="mrp_bom_shelf0" model="mrp.bom">
<field name="sequence">133</field>
<field name="sequence">133</field>
<field name="product_id" ref="product.product_product_shelf0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="bom_id" ref="mrp_bom_defaultbomforshelfofcm0"/>
<field name="product_qty">3.0</field>
<field name="product_qty">3.0</field>
<field name="name">Shelf 100</field>
</record>
<record id="mrp_bom_woodlintelm0" model="mrp.bom">
<field name="sequence">135</field>
<field name="sequence">135</field>
<field name="product_id" ref="product.product_product_woodlintelm0"/>
<field name="product_uom" ref="product.product_uom_meter"/>
<field name="bom_id" ref="mrp_bom_defaultbomforshelfofcm0"/>
<field name="product_qty">1.0</field>
<field model="mrp.bom" name="bom_id" search="[('name', '=', u'Assembly Section')]"/>
<field name="product_qty">1.0</field>
<field name="bom_id" ref="mrp_bom_assemblysection0"/>
<field name="name">Wood Lintel 4m</field>
</record>
<record id="mrp_bom_defaultbomforshelfofcm1" model="mrp.bom">
<field name="name">Default BOM for Shelf of 200cm</field>
<field name="code">SHE200</field>
<field name="sequence">137</field>
<field name="product_id" ref="product.product_product_shelfofcm0"/>
<field name="sequence">137</field>
<field name="product_id" ref="product.product_product_shelfofcm1"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="product_qty">1.0</field>
</record>
<record id="mrp_bom_defaultbomforkitshelfofcm0" model="mrp.bom">
<field name="name">Default BOM for KIT Shelf of 100cm</field>
<field name="code">SHE100KIT</field>
<field name="sequence">139</field>
<field name="sequence">139</field>
<field name="product_id" ref="product.product_product_kitshelfofcm0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="product_qty">1.0</field>
<field name="type">phantom</field>
</record>
<record id="mrp_bom_assemblysection2" model="mrp.bom">
<field name="name">Assembly Section</field>
<field name="sequence">143</field>
<field name="sequence">143</field>
<field name="product_id" ref="product.product_product_assemblysection0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">4.0</field>
<field name="product_qty">4.0</field>
<field name="bom_id" ref="mrp_bom_defaultbomforkitshelfofcm0"/>
</record>
<record id="mrp_bom_sidepanel2" model="mrp.bom">
<field name="name">Side Panel</field>
<field name="sequence">145</field>
<field name="sequence">145</field>
<field name="product_id" ref="product.product_product_sidepanel0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">2.0</field>
<field name="product_qty">2.0</field>
<field name="bom_id" ref="mrp_bom_defaultbomforkitshelfofcm0"/>
</record>
<record id="mrp_bom_rearpanelarm2" model="mrp.bom">
<field name="sequence">147</field>
<field name="product_id" ref="product.product_product_rearpanelarm0"/>
<field name="sequence">147</field>
<field name="product_id" ref="product.product_product_rearpanelarm1"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="bom_id" ref="mrp_bom_defaultbomforshelfofcm1"/>
<field name="product_qty">1.0</field>
<field name="product_qty">1.0</field>
<field name="name">Rear panel SHE200</field>
</record>
<record id="mrp_bom_assemblysection3" model="mrp.bom">
<field name="name">Assembly Section</field>
<field name="sequence">149</field>
<field name="sequence">149</field>
<field name="product_id" ref="product.product_product_assemblysection0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">4.0</field>
<field name="product_qty">4.0</field>
<field name="bom_id" ref="mrp_bom_defaultbomforshelfofcm1"/>
</record>
<record id="mrp_bom_sidepanel3" model="mrp.bom">
<field name="name">Side Panel</field>
<field name="sequence">151</field>
<field name="sequence">151</field>
<field name="product_id" ref="product.product_product_sidepanel0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">2.0</field>
<field name="product_qty">2.0</field>
<field name="bom_id" ref="mrp_bom_defaultbomforshelfofcm1"/>
</record>
<record id="mrp_bom_shelf2" model="mrp.bom">
<field name="sequence">153</field>
<field name="sequence">153</field>
<field name="product_id" ref="product.product_product_shelf1"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="bom_id" ref="mrp_bom_defaultbomforshelfofcm1"/>
<field name="product_qty">3.0</field>
<field name="product_qty">3.0</field>
<field name="name">Shelf 200</field>
</record>
<record id="mrp_bom_metalcleats3" model="mrp.bom">
<field name="name">Metal Cleats</field>
<field name="sequence">155</field>
<field name="sequence">155</field>
<field name="product_id" ref="product.product_product_metalcleats0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">12.0</field>
<field name="product_qty">12.0</field>
<field name="bom_id" ref="mrp_bom_defaultbomforshelfofcm1"/>
</record>
<record id="product.product_uom_dozen" model="product.uom">
<field name="category_id" ref="product.product_uom_categ_unit"/>
<field name="name">t</field>
<field name="factor" eval="1/12"/>
<field name="uom_type">bigger</field>
</record>
<record id="mrp_production_shelf100cm" model="mrp.production">
<field name="product_id" ref="product.product_product_shelfofcm0"/>
<field name="product_uom" ref="product.product.product_uom_dozen"/>
<field name="product_qty">5</field>
<field name="location_src_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_output"/>
<field name="bom_id" ref="mrp_bom_defaultbomforshelfofcm0"/>
<field name="routing_id" ref="mrp.mrp_routing_0"/>
</record>
<record id="product_uom_categ_fluid" model="product.uom.categ">
<field name="name">Fluid</field>
</record>
<record id="product_uom_litre" model="product.uom">
<field name="name">Litre</field>
<field name="category_id" ref="product_uom_categ_fluid"/>
<field name="factor">1.0</field>
</record>
<record id="product_orangejuice" model="product.product">
<field name="categ_id" ref="product.cat1"/>
<field name="name">Orange Juice</field>
<field name="procure_method">make_to_order</field>
<field name="supply_method">produce</field>
<field name="type">product</field>
<field name="uom_id" ref="product_uom_litre"/>
<field name="uom_po_id" ref="product_uom_litre"/>
</record>
<record id="product_orange" model="product.product">
<field name="categ_id" ref="product.cat1"/>
<field name="name">Orange</field>
<field name="procure_method">make_to_stock</field>
<field name="supply_method">buy</field>
<field name="type">product</field>
<field name="uom_id" ref="product.product_uom_kgm"/>
<field name="uom_po_id" ref="product.product_uom_kgm"/>
</record>
<record id="orange_supplier_asus" model="product.supplyinfo">
<field name="product_id" ref="product_orange"/>
<field name="name" ref="base.res_partner_asus"/>
<field name="product_uom" ref="product.product_uom_kgm"/>
</record>
<record id="product_sugar" model="product.product">
<field name="categ_id" ref="product.cat1"/>
<field name="name">Sugar</field>
<field name="procure_method">make_to_stock</field>
<field name="supply_method">buy</field>
<field name="type">product</field>
<field name="uom_id" ref="product.product_uom_kgm"/>
<field name="uom_po_id" ref="product.product_uom_kgm"/>
</record>
<record id="sugar_supplier_desertic" model="product.supplyinfo">
<field name="product_id" ref="product_sugar"/>
<field name="name" ref="base.res_partner_desertic_hispafuentes"/>
<field name="product_uom" ref="product.product_uom_kgm"/>
<field name="min_qty">2.0</field>
</record>
<record id="product_water" model="product.product">
<field name="categ_id" ref="product.cat1"/>
<field name="name">Water</field>
<field name="procure_method">make_to_order</field>
<field name="supply_method">buy</field>
<field name="type">consu</field>
<field name="uom_id" ref="product_uom_litre"/>
<field name="uom_po_id" ref="product_uom_litre"/>
</record>
<record id="water_supplier_agrolait" model="product.supplyinfo">
<field name="product_id" ref="product_water"/>
<field name="name" ref="base.res_partner_agrolait"/>
<field name="product_uom" ref="product_uom_litre"/>
<field name="min_qty">2.0</field>
</record>
<record id="mrp_bom_orangejuice" model="mrp.bom">
<field name="sequence">200</field>
<field name="product_id" ref="product_orangejuice"/>
<field name="product_uom" ref="product_uom_litre"/>
<field name="product_qty">1.0</field>
<field name="name">Orange Juice</field>
<field name="type">phantom</field>
</record>
<record id="raw_orangejuice_orange" model="mrp.bom">
<field name="sequence">201</field>
<field name="product_id" ref="product_orange"/>
<field name="product_uom" ref="product.product_uom_kgm"/>
<field name="product_qty">0.5</field>
<field name="name">Orange</field>
<field name="type">normal</field>
<field name="bom_id" ref="mrp_bom_orangejuice"/>
</record>
<record id="raw_orangejuice_sugar" model="mrp.bom">
<field name="sequence">202</field>
<field name="product_id" ref="product_sugar"/>
<field name="product_uom" ref="product.product_uom_kgm"/>
<field name="product_qty">0.02</field>
<field name="name">Sugar</field>
<field name="type">normal</field>
<field name="bom_id" ref="mrp_bom_orangejuice"/>
</record>
<record id="raw_orangejuice_water" model="mrp.bom">
<field name="sequence">203</field>
<field name="product_id" ref="product_water"/>
<field name="product_uom" ref="product_uom_litre"/>
<field name="product_qty">0.80</field>
<field name="name">Water</field>
<field name="type">normal</field>
<field name="bom_id" ref="mrp_bom_orangejuice"/>
</record>
<record id="stock_rule_orange" model="stock.warehouse.orderpoint">
<field name="product_id" ref="product_orange"/>
<field name="product_uom" ref="product.product_uom_kgm"/>
<field name="product_max_qty">10.0</field>
<field name="product_min_qty">5.0</field>
<field name="qty_multiple">1</field>
<field name="warehouse_id" ref="stock.warehouse0"/>
<field name="location_id" ref="stock.stock_location_stock"/>
</record>
<record id="stock_rule_sugar" model="stock.warehouse.orderpoint">
<field name="product_id" ref="product_sugar"/>
<field name="product_uom" ref="product.product_uom_kgm"/>
<field name="product_max_qty">4.0</field>
<field name="product_min_qty">2.0</field>
<field name="qty_multiple">1</field>
<field name="logic">max</field>
<field name="warehouse_id" ref="stock.warehouse0"/>
<field name="location_id" ref="stock.stock_location_stock"/>
</record>
<record id="mrp_production_orangejuice" model="mrp.production">
<field name="product_id" ref="product_orangejuice"/>
<field name="product_uom" ref="product_uom_litre"/>
<field name="location_src_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_output"/>
<field name="bom_id" ref="mrp_bom_orangejuice"/>
<field name="product_qty">100.00</field>
</record>
<record id="product_shirt" model="product.product">
<field name="categ_id" ref="product.cat1"/>
<field name="name">Shirt</field>
<field name="procure_method">make_to_stock</field>
<field name="supply_method">produce</field>
<field name="type">product</field>
<field name="uom_id" ref="product.product_uom_unit"/>
<field name="uom_po_id" ref="product.product_uom_unit"/>
</record>
<record id="product_cloth" model="product.product">
<field name="categ_id" ref="product.cat1"/>
<field name="name">Cloth</field>
<field name="procure_method">make_to_order</field>
<field name="supply_method">buy</field>
<field name="type">product</field>
<field name="uom_id" ref="product.product_uom_unit"/>
<field name="uom_po_id" ref="product.product_uom_unit"/>
</record>
<record id="cloth_supplier_maxtor" model="product.supplyinfo">
<field name="product_id" ref="product_cloth"/>
<field name="name" ref="base.res_partner_maxtor"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="min_qty">300.0</field>
</record>
<record id="product_buttons" model="product.product">
<field name="categ_id" ref="product.cat1"/>
<field name="name">Shirt Buttons</field>
<field name="procure_method">make_to_stock</field>
<field name="supply_method">buy</field>
<field name="type">product</field>
<field name="uom_id" ref="product.product_uom_unit"/>
<field name="uom_po_id" ref="product.product_uom_unit"/>
</record>
<record id="buttons_supplier_asus" model="product.supplyinfo">
<field name="product_id" ref="product_buttons"/>
<field name="name" ref="base.res_partner_asus"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="min_qty">100.0</field>
</record>
<record id="mrp_bom_shirt" model="mrp.bom">
<field name="sequence">300</field>
<field name="product_id" ref="product_shirt"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="name">Shirt</field>
</record>
<record id="raw_shirt_cloth" model="mrp.bom">
<field name="sequence">301</field>
<field name="product_id" ref="product_cloth"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">1.0</field>
<field name="name">Cloth</field>
<field name="type">normal</field>
<field name="bom_id" ref="mrp_bom_shirt"/>
</record>
<record id="raw_shirt_buttons" model="mrp.bom">
<field name="sequence">302</field>
<field name="product_id" ref="product_buttons"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_qty">8.0</field>
<field name="name">Shirt Buttons</field>
<field name="type">normal</field>
<field name="bom_id" ref="mrp_bom_shirt"/>
</record>
<record id="stock_shirt_buttons" model="stock.warehouse.orderpoint">
<field name="product_id" ref="product_buttons"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_max_qty">50.0</field>
<field name="product_min_qty">10.0</field>
<field name="qty_multiple">1</field>
<field name="logic">max</field>
<field name="warehouse_id" ref="stock.warehouse0"/>
<field name="location_id" ref="stock.stock_location_stock"/>
</record>
<record id="mrp_production_shirt" model="mrp.production">
<field name="product_id" ref="product_shirt"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="location_src_id" ref="stock.stock_location_stock"/>
<field name="location_dest_id" ref="stock.stock_location_output"/>
<field name="bom_id" ref="mrp_bom_shirt"/>
</record>
<record id="mrp_production_order1" model="mrp.production">
<field name="product_id" ref="product.product_product_pc1"/>
<field name="product_uom" ref="product.product_uom_unit"/>
@@ -714,11 +947,9 @@
<field name="bom_id" ref="mrp.mrp_bom_9"/>
<field name="routing_id" ref="mrp.mrp_routing_0"/>
</record>
<workflow action="button_confirm" model="mrp.production" ref="mrp_production_order1"/>
<!-- Run Scheduler -->
<function model="procurement.order" name="run_scheduler"/>
</data>
</openerp>
+1 -1
View File
@@ -317,7 +317,7 @@
<field name="arch" type="xml">
<form string="Bill of Material">
<group colspan="4" col="6">
<field name="product_id" on_change="onchange_product_id(product_id, name)" select="1"/>
<field name="product_id" on_change="onchange_product_id(product_id, name, context)" select="1"/>
<field name="name" select="1"/>
<field name="code" select="1" string="Reference" groups="base.group_extended"/>
<newline/>
+24 -22
View File
@@ -26,28 +26,30 @@ from tools.translate import _
class product_product(osv.osv):
_inherit = "product.product"
def get_product_accounts(self, cr, uid, product_id, context=None):
""" To get the stock input account, stock output account and stock journal related to product.
@param product_id: product id
@return: dictionary which contains information regarding stock input account, stock output account and stock journal
"""
product_obj = self.pool.get('product.product').browse(cr, uid, product_id, False)
res = super(product_product,self).get_product_accounts(cr, uid, product_id, context=context)
stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False
if not stock_input_acc:
stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False
stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False
if not stock_output_acc:
stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False
journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False
res.update({'stock_account_input': stock_input_acc})
res.update({'stock_account_output': stock_output_acc})
res.update({'stock_journal': journal_id})
return res
# TODO: DEAD CODE: This function was called from do_change_standard_price,
# but as that function is removed for the fix of lp:747056, its not reached
# def get_product_accounts(self, cr, uid, product_id, context=None):
# """ To get the stock input account, stock output account and stock journal related to product.
# @param product_id: product id
# @return: dictionary which contains information regarding stock input account, stock output account and stock journal
# """
# product_obj = self.pool.get('product.product').browse(cr, uid, product_id, False)
# res = super(product_product,self).get_product_accounts(cr, uid, product_id, context=context)
# stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False
# if not stock_input_acc:
# stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False
#
# stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False
# if not stock_output_acc:
# stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False
#
# journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False
#
# res.update({'stock_account_input': stock_input_acc})
# res.update({'stock_account_output': stock_output_acc})
# res.update({'stock_journal': journal_id})
#
# return res
_columns = {
+28
View File
@@ -0,0 +1,28 @@
-
In order to test effect of cancelling Internal picking on production order, I first confirm order for PC3.
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_order3}
-
I check that the related internal picking is waiting availability.
-
!assert {model: mrp.production, id: mrp_production_order3}:
- picking_id.state == 'confirmed'
-
In order to cancel the production order, I first cancel its picking.
-
!function {model: stock.picking, name: action_cancel}:
- model: mrp.production
eval: "[obj(ref('mrp_production_order3')).picking_id.id]"
-
Now I cancel the production order.
-
!workflow {model: mrp.production, action: button_cancel, ref: mrp_production_order3}
-
Now I check that the production order is cancelled.
-
!assert {model: mrp.production, id: mrp_production_order3}:
- state == 'cancel'
-
I remove this production order.
-
!delete {model: mrp.production, id: mrp_production_order3}
-103
View File
@@ -1,103 +0,0 @@
-
In order to test the Packs in OpenERP, we will try to sell a "Pack of 24
beers" which is composed of 24 "Beers" and a "Beers Pack".
-
I start by creating the Beers product.
-
!record {model: product.product, id: product_product_beers0}:
categ_id: product.cat1
name: Beers
procure_method: make_to_stock
seller_ids:
- delay: 1
name: base.res_partner_agrolait
min_qty: 2.0
supply_method: buy
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
-
I create the "Beers Pack" product.
-
!record {model: product.product, id: product_product_beerspack0}:
categ_id: product.cat1
name: Beers Pack
procure_method: make_to_stock
seller_ids:
- delay: 1
name: base.res_partner_asus
min_qty: 2.0
supply_method: buy
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
-
I create the "Pack of 24 beers" product
-
!record {model: product.product, id: product_product_packofbeers0}:
categ_id: product.cat1
name: Pack of 24 Beers
procure_method: make_to_order
supply_method: produce
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
-
I define the Phantom Bill of Material for the "Pack of 24 beers"
-
!record {model: mrp.bom, id: mrp_bom_packofbeers0}:
bom_lines:
- company_id: base.main_company
name: Beers
product_id: product_product_beers0
product_qty: 24.0
product_uom: product.product_uom_unit
type: normal
- company_id: base.main_company
name: Beers Pack
product_id: product_product_beerspack0
product_qty: 1.0
product_uom: product.product_uom_unit
type: normal
name: Pack of 24 Beers
product_id: product_product_packofbeers0
product_qty: 1.0
product_uom: product.product_uom_unit
type: phantom
-
As all my data are created, I will create an outgoing order picking for a
"Pack of 24 Beers"
-
!record {model: stock.picking, id: picking_out}:
address_id: base.res_partner_address_tang
company_id: base.main_company
invoice_state: none
move_lines:
- company_id: base.main_company
location_dest_id: stock.stock_location_customers
location_id: stock.stock_location_stock
name: Pack of 24 Beers
product_id: product_product_packofbeers0
product_qty: 2.0
product_uom: product.product_uom_unit
move_type: direct
type: out
-
I validate the newly created picking.
-
!python {model: stock.picking}: |
self.draft_validate(cr, uid, [ref("picking_out")], {
"active_ids": [ref("stock.menu_action_picking_tree")],
"active_id": ref("stock.menu_action_picking_tree"), }
)
-
I check that my Picking of a "Pack of 24 beers" has been automatically
converted to a picking of 24 beers and a pack of beer, so that my
stock of beers remains exact.
-
!assert {model: stock.picking, id: picking_out, string: pack_of_beer_splitted}:
- len(move_lines) >= 2
- move_lines[0].product_id.id <> move_lines[1].product_id.id
- move_lines[0].product_id.id in (ref('product_product_beers0'), ref('product_product_beerspack0'))
- move_lines[1].product_id.id in (ref('product_product_beers0'), ref('product_product_beerspack0'))
-273
View File
@@ -1,273 +0,0 @@
-
In order to test the mrp phantom bom type in OpenERP, I will create products
and then I will create Phantom bom structure for those products.
-
I create BOM category fluid for Orange Juice
-
!record {model: product.uom.categ, id: product_uom_categ_fluid}:
name: Fluid
-
I create the products required to produce some orange juices with Oranges, Sugar and Water.
-
!record {model: product.uom, id: product_uom_litre0}:
category_id: product_uom_categ_fluid
factor: 1.0
name: Litre
rounding: 0.01
-
I create record for product Orange Juice.
-
!record {model: product.product, id: product_product_orangejuice0}:
categ_id: product.cat1
name: Orange Juice
procure_method: make_to_order
supply_method: produce
type: product
uom_id: product_uom_litre0
uom_po_id: product_uom_litre0
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
property_stock_production: stock.location_production
-
I create record for product Orange.
-
!record {model: product.product, id: product_product_orange0}:
categ_id: product.cat1
name: Orange
procure_method: make_to_stock
seller_ids:
- delay: 1
name: base.res_partner_asus
min_qty: 1.0
product_uom: product.product_uom_kgm
supply_method: buy
type: product
uom_id: product.product_uom_kgm
uom_po_id: product.product_uom_kgm
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
property_stock_production: stock.location_production
-
I create record for product Sugar.
-
!record {model: product.product, id: product_product_sugar0}:
categ_id: product.cat1
name: Sugar
procure_method: make_to_stock
seller_ids:
- delay: 1
name: base.res_partner_desertic_hispafuentes
min_qty: 2.0
product_uom: product.product_uom_kgm
supply_method: buy
type: product
uom_id: product.product_uom_kgm
uom_po_id: product.product_uom_kgm
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
property_stock_production: stock.location_production
-
I create record for product Water.
-
!record {model: product.product, id: product_product_water0}:
categ_id: product.cat1
name: Water
procure_method: make_to_order
seller_ids:
- delay: 1
name: base.res_partner_agrolait
product_uom: product_uom_litre0
min_qty: 2.0
supply_method: buy
type: consu
uom_id: product_uom_litre0
uom_po_id: product_uom_litre0
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
property_stock_production: stock.location_production
-
I define the BoM to produce an orange juice.
-
!record {model: mrp.bom, id: mrp_bom_orangejuice0}:
company_id: base.main_company
name: Orange Juice
product_efficiency: 1.0
product_id: product_product_orangejuice0
product_qty: 1.0
product_uom: product_uom_litre0
type: phantom
-
changes UOM and name if product change.
-
!python {model: mrp.bom}: |
production_id = self.browse(cr, uid, [ref('mrp_bom_orangejuice0')], context=context)[0]
self.onchange_product_id(cr, uid, [ref('mrp_bom_orangejuice0')], production_id.product_id.id, False)
-
I create bom lines for BoM for Orange Juice.
-
!record {model: mrp.bom, id: mrp_bom_orangejuice0}:
bom_lines:
- bom_id: mrp_bom_orangejuice0
company_id: base.main_company
name: Orange
product_efficiency: 1.0
product_id: product_product_orange0
product_qty: 0.5
product_uom: product.product_uom_kgm
type: normal
- bom_id: mrp_bom_orangejuice0
company_id: base.main_company
name: Sugar
product_efficiency: 1.0
product_id: product_product_sugar0
product_qty: 0.02
product_uom: product.product_uom_kgm
type: normal
- bom_id: mrp_bom_orangejuice0
company_id: base.main_company
name: Water
product_efficiency: 1.0
product_id: product_product_water0
product_qty: 0.80000000000000004
product_uom: product_uom_litre0
type: normal
-
I define Minimum stock rules for my stockable product "Orange".
-
!record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op0}:
company_id: base.main_company
location_id: stock.stock_location_stock
logic: max
name: OP/00002
product_id: product_product_orange0
product_max_qty: 10.0
product_min_qty: 5.0
product_uom: product.product_uom_kgm
qty_multiple: 1
warehouse_id: stock.warehouse0
-
I define Minimum stock rules for my stockable product "Sugar".
-
!record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op1}:
company_id: base.main_company
location_id: stock.stock_location_stock
logic: max
name: OP/00003
product_id: product_product_sugar0
product_max_qty: 4.0
product_min_qty: 2.0
product_uom: product.product_uom_kgm
qty_multiple: 1
warehouse_id: stock.warehouse0
-
I want to produce 100 litres of Orange juice. I am creating a manufacturing order for this.
I want to see how much quantities of sub products I need, to produce the Orange juice.
-
I compute the data. I get the bill of material of Orange juice and list of
scheduled products according to my bom.
-
!record {model: mrp.production, id: mrp_production_mo0}:
company_id: base.main_company
date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
location_dest_id: stock.stock_location_output
location_src_id: stock.stock_location_stock
product_id: product_product_orangejuice0
product_qty: 100.0
product_uom: product_uom_litre0
-
Creating an mrp.production record. Computing Bills of materials.
-
!record {model: mrp.production, id: mrp_production_mo0}:
bom_id: mrp.mrp_bom_orangejuice0
date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
location_dest_id: stock.stock_location_output
location_src_id: stock.stock_location_stock
product_id: mrp.product_product_orangejuice0
product_lines:
- name: Orange
product_id: mrp.product_product_orange0
product_qty: 50.0
product_uom: product.product_uom_kgm
production_id: mrp_production_mo0
- name: Sugar
product_id: mrp.product_product_sugar0
product_qty: 2.0
product_uom: product.product_uom_kgm
production_id: mrp_production_mo0
- name: Water
product_id: mrp.product_product_water0
product_qty: 80.0
product_uom: mrp.product_uom_litre0
production_id: mrp_production_mo0
product_qty: 100.0
product_uom: mrp.product_uom_litre0
-
I confirm the order.
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo0}
-
I am checking Procurement orders. There are 3 orders generated for Oranges, Sugar and Water.
-
!python {model: procurement.order}: |
proc_ids = self.search(cr, uid, [('product_id','in',[ref('product_product_orange0'),ref('product_product_sugar0'),ref('product_product_water0')])])
assert proc_ids, 'No Procurements!'
-
The scheduler runs.
-
!function {model: procurement.order, name: run_scheduler}:
- model: procurement.order
search: "[]"
-
I am checking Internal picking. I see one picking for Orange juice and its
stock moves for Oranges, Sugar and Water made correctly.
-
!python {model: stock.picking}: |
pick_ids = self.search(cr, uid, [('type','=','internal')])
assert pick_ids, 'No Internal Pickings!'
-
According to minimum stock rules. I have 2 purchase orders for
Sugar with 6 Kg from Axelor and Orange 60 Kg from ASUStek.
-
I confirm the purchase order of Sugar and Orange.
-
!python {model: purchase.order}: |
import netsvc
purch_ids = self.search(cr, uid, [('state','=','draft')])
assert purch_ids, 'No Purchase Orders were made!'
wf_service = netsvc.LocalService("workflow")
for p_id in purch_ids:
wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_confirm', cr)
-
I see two incoming pickings for Orange and Sugar, and receive them.
-
!python {model: stock.picking}: |
pick_ids = self.search(cr, uid, [('type','=','in')])
assert pick_ids, 'No Incoming Shipments found!'
stock_partial_picking = self.pool.get('stock.partial.picking')
for pick_id in pick_ids:
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [pick_id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
Again the scheduler runs.
-
!function {model: procurement.order, name: run_scheduler}:
- model: procurement.order
search: "[]"
-
I check my internal picking of "Orange Juice" is done.
-
!python {model: stock.picking}: |
pick_ids = self.search(cr, uid, [('type','=','internal'),('state','=','done')])
assert pick_ids, 'Internal Picking is not done yet!'
-
I check my manufacturing order for "Orange Juice" is ready or not.
-
!python {model: mrp.production}: |
prod_ids = self.search(cr, uid, [('state','=','ready'),('id','=',ref('mrp_production_mo0'))])
assert prod_ids, 'Manufacturing order is not ready!'
-
I start the production order.
-
!workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo0}
-278
View File
@@ -1,278 +0,0 @@
-
In order to test the flow of procurement orders. I will put some orders with
different procurement methods. I have installed sale, mrp and purchase modules.
-
I am creating products.
-
I create record for product Shirt.
-
!record {model: product.product, id: product_product_shirt0}:
categ_id: product.cat1
cost_method: standard
list_price: 350.0
mes_type: fixed
name: Shirt
procure_method: make_to_stock
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
property_stock_production: stock.location_production
seller_delay: '1'
standard_price: 300.0
supply_method: produce
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
volume: 0.0
warranty: 0.0
weight: 0.0
weight_net: 0.0
-
I create record for product Cloth.
-
!record {model: product.product, id: product_product_cloth0}:
categ_id: product.cat1
cost_method: standard
mes_type: fixed
name: Cloth
procure_method: make_to_order
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
property_stock_production: stock.location_production
seller_delay: '1'
seller_ids:
- delay: 1
name: base.res_partner_maxtor
product_uom: product.product_uom_unit
min_qty: 300.0
standard_price: 1.0
supply_method: buy
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
volume: 0.0
warranty: 0.0
weight: 0.0
weight_net: 0.0
-
I create record for product Buttons.
-
!record {model: product.product, id: product_product_buttons0}:
categ_id: product.cat1
cost_method: standard
mes_type: fixed
name: Buttons
procure_method: make_to_stock
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
property_stock_production: stock.location_production
seller_delay: '1'
seller_ids:
- delay: 1
name: base.res_partner_asus
product_uom: product.product_uom_kgm
min_qty: 100.0
standard_price: 1.0
supply_method: buy
type: product
uom_id: product.product_uom_kgm
uom_po_id: product.product_uom_kgm
volume: 0.0
warranty: 0.0
weight: 0.0
weight_net: 0.0
-
I am creating bills of material for 'Shirt'.
-
I create bills of material for Shirt.
-
!record {model: mrp.bom, id: mrp_bom_shirt0}:
bom_lines:
- company_id: base.main_company
name: Cloth
product_efficiency: 1.0
product_id: product_product_cloth0
product_qty: 1.0
product_uom: product.product_uom_unit
product_uos_qty: 0.0
sequence: 0.0
type: normal
- company_id: base.main_company
name: Buttons
product_efficiency: 1.0
product_id: product_product_buttons0
product_qty: 8.0
product_uom: product.product_uom_kgm
product_uos_qty: 0.0
sequence: 0.0
type: normal
company_id: base.main_company
name: Shirt
product_efficiency: 1.0
product_id: product_product_shirt0
product_qty: 1.0
product_uom: product.product_uom_unit
product_uos_qty: 0.0
sequence: 0.0
type: normal
-
I create minimum stock rule for product Buttons
-
!record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op0}:
company_id: base.main_company
location_id: stock.stock_location_stock
logic: max
name: OP/00007
product_id: mrp.product_product_buttons0
product_max_qty: 50.0
product_min_qty: 10.0
product_uom: product.product_uom_kgm
qty_multiple: 1
warehouse_id: stock.warehouse0
-
I create a procurement order for product Shirt.
-
!record {model: procurement.order, id: procurement_order_shirt0}:
name: 'PROC: Shirt'
product_id: product_product_shirt0
product_qty: 5.00
location_id: stock.stock_location_stock
product_uom: product.product_uom_unit
-
I confirm the procurement order.
-
!workflow {model: procurement.order, action: button_confirm, ref: procurement_order_shirt0}
-
I run the procurement.
-
!workflow {model: procurement.order, action: button_check, ref: procurement_order_shirt0}
-
I see that there is a manufacturing order for Shirt.
-
!python {model: mrp.production}: |
from tools.translate import _
order_ids = self.search(cr, uid, [('product_id','=',ref('product_product_shirt0'))])
assert order_ids, 'No Manufacturing Order.'
-
I also check that there are two more procurement orders for sub products Cloth and Buttons.
-
!python {model: procurement.order}: |
from tools.translate import _
proc_ids = self.search(cr, uid, [('product_id','in',[ref('product_product_cloth0'),ref('product_product_buttons0')])])
assert proc_ids, 'No Procurements.'
-
The scheduler runs.
-
!function {model: procurement.order, name: run_scheduler}:
- model: procurement.order
search: "[]"
-
I check that there is one purchase order for Cloth.
-
!python {model: purchase.order}: |
purch_ids = self.search(cr, uid, [('partner_id.name','=','Maxtor')])
assert purch_ids, 'No Purchase Orders.'
-
I confirm purchase order for Cloth.
-
!python {model: purchase.order}: |
import netsvc
purch_ids = self.search(cr, uid, [('partner_id.name','=','Maxtor')])
wf_service = netsvc.LocalService("workflow")
for p_id in purch_ids:
wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_confirm', cr)
-
I confirm purchase order for Buttons.
-
!python {model: purchase.order}: |
import netsvc
purch_ids = self.search(cr, uid, [('partner_id.name','=','ASUStek')])
wf_service = netsvc.LocalService("workflow")
for p_id in purch_ids:
wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_confirm', cr)
-
I Check incoming shipments for cloth. And receive products.
-
!python {model: stock.picking}: |
pick_ids = self.search(cr, uid, [('address_id.name','=','Wong'),('state','=','assigned')])
assert pick_ids, 'No Incoming Shipments found!'
stock_partial_picking = self.pool.get('stock.partial.picking')
for pick_id in pick_ids:
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [pick_id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
I Check incoming shipments for buttons and receive products.
-
!python {model: stock.picking}: |
pick_ids = self.search(cr, uid, [('address_id.name','=','Tang'),('state','=','assigned')])
assert pick_ids, 'No Incoming Shipments found!'
stock_partial_picking = self.pool.get('stock.partial.picking')
for pick_id in pick_ids:
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [pick_id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
Run scheduler again.
-
!function {model: procurement.order, name: run_scheduler}:
- model: procurement.order
search: "[]"
-
Check state of manufacturing order for Shirt.
-
!python {model: mrp.production}: |
from tools.translate import _
order_ids = self.search(cr, uid, [('product_id','=',ref('product_product_shirt0')),('state','=','ready')])
assert order_ids, 'No Manufacturing Order in Ready state.'
-
I start production order for Shirt.
-
!python {model: mrp.production}: |
from tools.translate import _
import netsvc
prod_ids = self.search(cr, uid, [('state','=','ready')])
assert prod_ids, _('No Ready Manufacturing Orders found!')
wf_service = netsvc.LocalService("workflow")
for p_id in prod_ids:
wf_service.trg_validate(uid, 'mrp.production', p_id, 'button_produce', cr)
-
I create record for producing products with quantity 5.00.
-
!record {model: mrp.product.produce, id: mrp_product_produce0}:
product_qty: 2.00
mode: 'consume_produce'
-
I produce 2 products with 5.00 quantities each.
-
!python {model: mrp.product.produce}: |
prod_obj = self.pool.get('mrp.production')
prod_ids = prod_obj.search(cr, uid, [('product_id.name','=','Shirt')])
self.do_produce(cr, uid, [ref('mrp_product_produce0')], context={'active_ids': prod_ids})
-
I create record for remaining products with quantity 35.00.
-
!record {model: stock.move.consume, id: stock_move_consume0}:
product_id: product_product_buttons0
product_qty: 35.00
product_uom: product.product_uom_unit
location_id: stock.stock_location_stock
-
I produce remaining product Buttons with 35.00 quantity.
-
!python {model: stock.move.consume}: |
from tools.translate import _
stock_obj = self.pool.get('stock.move')
stock_ids = stock_obj.search(cr, uid, [('product_id.name','=','Buttons')])
self.do_move_consume(cr, uid, [ref('stock_move_consume0')], context={'active_ids': stock_ids})
-
And finally production order is done.
-
!python {model: mrp.product.produce}: |
prod_obj = self.pool.get('mrp.production')
prod_ids = prod_obj.search(cr, uid, [('product_id.name','=','Shirt')])
self.do_produce(cr, uid, [ref('mrp_product_produce0')], context={'active_ids': prod_ids})
-29
View File
@@ -1,29 +0,0 @@
-
In order to test the manufacturing order in Openerp,
I am creating one manufacturing order
-
!record {model: mrp.production, id: mrp_production_mo1}:
company_id: base.main_company
date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
location_dest_id: stock.stock_location_stock
location_src_id: stock.stock_location_stock
product_id: product.product_product_pc1
name: MO/01234
product_qty: 5.0
product_uom: product.product_uom_unit
product_uos_qty: 0.0
-
I confirm the order.
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1}
-
In order to cancel the MO, I first cancel its picking.
-
!python {model: stock.picking}: |
mrp_obj = self.pool.get('mrp.production')
mo = mrp_obj.browse(cr, uid, ref("mrp_production_mo1"))
self.action_cancel(cr, uid, [mo.picking_id.id], context=None)
-
Then I Cancel the production order and related stock moves.
-
!workflow {model: mrp.production, action: button_cancel, ref: mrp_production_mo1}
-119
View File
@@ -1,119 +0,0 @@
-
In order to test the manufacturing order working with procurements I will use
some products with different supply method and procurement method, also check
the bills of material for the products.
-
I am creating one manufacturing order.
-
!record {model: mrp.production, id: mrp_production_mo1}:
company_id: base.main_company
date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
location_dest_id: stock.stock_location_stock
location_src_id: stock.stock_location_stock
product_id: product.product_product_pc1
name: MO/0123
product_qty: 5.0
product_uom: product.product_uom_unit
product_uos_qty: 0.0
-
I compute the data.
-
!python {model: mrp.production}: |
self.action_compute(cr, uid, [ref("mrp_production_mo1")])
-
I confirm the order.
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1}
-
I create record for changing production quantity to 6.00
-
!record {model: change.production.qty, id: mrp_production_qty}:
product_qty: 6.0
-
Changes the Quantity of Product.
-
!python {model: change.production.qty}: |
context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_mo1")], "tz": False, "active_id":ref('mrp_production_mo1')}
self.default_get(cr, uid, ["product_qty"], context)
self.change_prod_qty(cr, uid, [ref("mrp_production_qty")], context=context)
-
I check now quantity of the production order is 6 or not.
-
!assert {model: mrp.production, id: mrp_production_mo1}:
- product_qty == 6
-
I am checking Procurement orders for components of PC1.
-
!python {model: procurement.order}: |
from tools.translate import _
production_obj = self.pool.get('mrp.production')
production = production_obj.browse(cr, uid, ref('mrp_production_mo1'))
product_ids = map(lambda x:x.product_id.id, production.move_lines)
proc_ids = self.search(cr, uid, [('product_id','in',product_ids)])
assert proc_ids, _('No Procurements!')
-
The scheduler runs.
-
!function {model: procurement.order, name: run_scheduler}:
- model: procurement.order
search: "[]"
-
I am checking Internal picking.
-
!python {model: stock.picking}: |
from tools.translate import _
pick_ids = self.search(cr, uid, [('type','=','internal')])
assert pick_ids, _('No Internal Pickings!')
-
I see that there is a manufacturing order for the sub product CPU_GEN with ready state and I start production of it.
-
!python {model: mrp.production}: |
from tools.translate import _
order_ids = self.search(cr, uid, [('state','=','ready'), ('product_id', '=', ref('product.product_product_cpu_gen'))])
assert order_ids, _('No manufacturing order in Ready state!')
import netsvc
wf_service = netsvc.LocalService("workflow")
for order in order_ids:
wf_service.trg_validate(uid, 'mrp.production', order, 'button_produce', cr)
-
I create record for producing products with quantity 1.00.
-
!record {model: mrp.product.produce, id: mrp_product_produce0}:
product_qty: 1.00
mode: 'consume_produce'
-
I produce the product.
-
!python {model: mrp.product.produce}: |
prod_obj = self.pool.get('mrp.production')
prod_ids = prod_obj.search(cr, uid, [('state','=','in_production'), ('product_id', '=', ref('product.product_product_cpu_gen'))])
self.do_produce(cr, uid, [ref('mrp_product_produce0')], context={'active_ids': prod_ids})
-
Now the manufacturing order for subproduct CPU_GEN is done and manufacturing
order for PC1 is in ready state.
-
!python {model: mrp.production}: |
from tools.translate import _
prod_ids = self.search(cr, uid, [('state','=','done'), ('product_id', '=', ref('product.product_product_cpu_gen'))])
assert prod_ids, _('Manufacturing order for CPU_GEN is yet not done!')
-
I start producing the product PC1.
-
!workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo1}
-
I create record for producing products with quantity 6.00.
-
!record {model: mrp.product.produce, id: mrp_product_produce1}:
product_qty: 6.00
mode: 'consume_produce'
-
Finally my production order is done.
-
!python {model: mrp.product.produce}: |
context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_mo1")], "tz": False, "active_id":ref('mrp_production_mo1')}
self.do_produce(cr, uid, [ref('mrp_product_produce1')], context=context)
-
I check now the production order for PC1 is done.
-
!assert {model: mrp.production, id: mrp_production_mo1}:
- state == 'done'
-38
View File
@@ -1,38 +0,0 @@
-
In order to test the PDF reports defined on a MRP, we will print a BOM Structure Report
-
!python {model: mrp.bom}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.bom.structure').create(cr, uid, [ref('mrp.mrp_bom_0'),ref('mrp.mrp_bom_1'),ref('mrp.mrp_bom_2'),ref('mrp.mrp_bom_23'),ref('mrp.mrp_bom_1901'),ref('mrp.mrp_bom_assemblysection0'),ref('mrp.mrp_bom_sidepanel0'),ref('mrp.mrp_bom_defaultbomforshelfofcm1'),ref('mrp.mrp_bom_sidepanel3')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'mrp-bom_structure_report.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a MRP, we will print Production Order Report
-
!python {model: mrp.production}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.mrp.production.order').create(cr, uid, [ref('mrp.mrp_production_mo1')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'mrp-production_order_report.'+format), 'wb+').write(data)
-
Print Product Price Report through the wizard
-
!python {model: product.product}: |
ctx={}
ctx.update({'model': 'product.product','active_ids': [1,2,3,5]})
data_dict = {'number': 1}
from tools import test_reports
test_reports.try_report_action(cr, uid, 'action_view_mrp_product_price_wizard',wiz_data=data_dict, context=ctx, our_module='mrp')
-
Print Work Center Load Report through the wizard
-
!python {model: mrp.workcenter}: |
ctx={}
ctx.update({'model': 'mrp.workcenter','active_ids': [ref('mrp_workcenter_0'),ref('mrp_workcenter_1')]})
data_dict = {'time_unit': 'day', 'measure_unit': 'hours'}
from tools import test_reports
test_reports.try_report_action(cr, uid, 'action_mrp_workcenter_load_wizard',wiz_data=data_dict, context=ctx, our_module='mrp')
+12
View File
@@ -0,0 +1,12 @@
-
!record {model: mrp.bom, id: mrp_bom_metalcleats3}:
product_id: product.product_product_metalcleats0
-
!record {model: mrp.production, id: mrp_production_shelf}:
location_src_id: stock.stock_location_stock
location_dest_id: stock.stock_location_output
product_id: product.product_product_shelfofcm0
bom_id: mrp_bom_defaultbomforshelfofcm0
product_qty: 5.0
+215
View File
@@ -0,0 +1,215 @@
-
I change production qty with 3 Dozen Shelf 100cm.
-
!python {model: change.production.qty}: |
context.update({'active_id': ref('mrp_production_shelf100cm')})
-
!record {model: change.production.qty, id: mrp_production_qty}:
product_qty: 3.0
-
!python {model: change.production.qty}: |
self.change_prod_qty(cr, uid, [ref("mrp_production_qty")], context=context)
-
I check qty after changed in production order.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp_production_shelf100cm"))
assert move.product_uom.id == ref("product.product_uom_dozen"), "UOM is not correspond."
assert move.product_qty == 3, "Qty is not changed."
-
I compute the production order.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp_production_shelf100cm"), context=context)
order.action_compute()
-
I check production lines after compute.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp_production_shelf100cm"), context=context)
assert len(order.move_lines), "Production lines are not generated."
for line in order.move_lines:
if line.product_id.id == ref('product.product_product_assemblysection0'):
assert line.product_qty == (4.0*3.0*12.0), "Qty is not correspond."
assert line.product_uom.id == ref('product.product_uom_unit'), "UOM is not correspond"
elif line.product_id.id == ref('product.product_product_sidepanel0'):
assert line.product_qty == (2.0*3.0*12.0), "Qty is not correspond."
assert line.product_uom.id == ref('product.product_uom_unit'), "UOM is not correspond"
elif line.product_id.id == ref('product.product_product_metalcleats0'):
assert line.product_qty == (12.0*3.0*12.0), "Qty is not correspond."
assert line.product_uom.id == ref('product.product_uom_unit'), "UOM is not correspond"
elif line.product_id.id == ref('product.product_product_rearpanelarm0'):
assert line.product_qty == (1.0*3.0*12.0), "Qty is not correspond."
assert line.product_uom.id == ref('product.product_uom_unit'), "UOM is not correspond"
elif line.product_id.id == ref('product.product_product_shelf0'):
assert line.product_qty == (3.0*3.0*12.0), "Qty is not correspond."
assert line.product_uom.id == ref('product.product_uom_unit'), "UOM is not correspond"
else:
assert_exception("Lines are not correspond.")
-
I confirm the Production Order.
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_shelf100cm}
-
I check details of Produce Move of Production Order to trace Final Product.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp_production_shelf100cm"))
assert order.state == 'confirmed', "Production order should be confirmed."
assert order.move_created_ids, "Trace Record is not created for Final Product."
move = order.move_created_ids[0]
source_location_id = order.product_id.product_tmpl_id.property_stock_production.id
assert move.date == order.date_planned, "Planned date is not correspond."
assert move.product_id.id == order.product_id.id, "Product is not correspond."
assert move.product_uom.id == order.product_uom.id, "UOM is not correspond."
assert move.product_qty == order.product_qty, "Qty is not correspond."
assert move.product_uos == order.product_uos, "UOS is not correspond."
assert move.product_uos_qty == order.product_uos_qty, "UOS qty is not correspond."
assert move.location_id.id == source_location_id, "Source Location is not correspond."
assert move.location_dest_id.id == order.location_dest_id.id, "Destination Location is not correspond."
routing_loc = None
if production.bom_id.routing_id and production.bom_id.routing_id.location_id:
routing_loc = production.bom_id.routing_id.location_id.id
for move_line in order.move_lines:
for order_line in order.product_lines:
if line.product_id.type not in ('product', 'consu'):
continue
if move_line.product_id.id == order_line.product_id.id:
assert move_line.date == date_planned, "Planned date is not correspond in 'To consume line'."
assert move_line.product_qty == order_line.product_qty, "Qty is not correspond in 'To consume line'."
assert move_line.product_uom.id == order_line.product_uom.id, "UOM is not correspond in 'To consume line'."
assert move_line.product_uos_qty == order_line.product_uos and order_line.product_uos_qty or False, "UOS qty is not correspond in 'To consume line'."
assert move_line.product_uos == order_line.product_uos and order_line.product_uos.id or False, "UOS is not correspond in 'To consume line'."
assert move_line.location_id.id == routing_loc or production.location_src_id.id, "Source location is not correspond in 'To consume line'."
assert move_line.location_dest_id.id == source_location_id, "Destination Location is not correspond in 'To consume line'."
-
I check details of an Internal Shipment after confirmed production order to bring components in Raw Materials Location.
-
!python {model: mrp.production}: |
procurement = self.pool.get('procurement.order')
order = self.browse(cr, uid, ref("mrp_production_shelf100cm"))
assert order.picking_id, 'Internal Shipment should be created!'
routing_loc = None
pick_type = 'internal'
address_id = False
if production.bom_id.routing_id and production.bom_id.routing_id.location_id:
routing_loc = production.bom_id.routing_id.location_id
if routing_loc.usage <> 'internal':
pick_type = 'out'
address_id = routing_loc.address_id and routing_loc.address_id.id or False
routing_loc = routing_loc.id
assert order.picking_id.type == pick_type, "Shipment should be Internal."
assert order.picking_id.address_id == address_id, "Shipment Address is not correspond with Adderss of Routing Location."
date_planned = production.date_planned
for move_line in order.picking_id.move_lines:
for order_line in order.product_lines:
if line.product_id.type not in ('product', 'consu'):
continue
if move_line.product_id.id == order_line.product_id.id:
assert move_line.date == date_planned, "Planned date is not correspond."
assert move_line.product_qty == order_line.product_qty, "Qty is not correspond."
assert move_line.product_uom.id == order_line.product_uom.id, "UOM is not correspond."
assert move_line.product_uos_qty == order_line.product_uos and order_line.product_uos_qty or False, "UOS qty is not correspond."
assert move_line.product_uos == order_line.product_uos and order_line.product_uos.id or False, "UOS is not correspond."
assert move_line.location_id.id == production.location_src_id.id, "Source location is not correspond."
assert move_line.location_dest_id.id == routing_loc or production.location_src_id.id, "Destination Location is not correspond."
procurement_ids = procurement.search(cr, uid, [('move_id','=',move_line.id)]
assert procurement_ids, "Procurement should be created for shipment line of raw materials."
shipment_procurement = procurement.browse(cr, uid, procurement_ids[0], context=context)
assert shipment_procurement.date_planned == date_planned, "Planned date is not correspond in procurement."
assert shipment_procurement.product_id.id == order_line.product_id.id, "Product is not correspond in procurement."
assert shipment_procurement.product_qty == order_line.product_qty, "Qty is not correspond in procurement."
assert shipment_procurement.product_uom.id == order_line.product_uom.id, "UOM is not correspond in procurement."
assert shipment_procurement.product_uos_qty == order_line.product_uos and order_line.product_qty or False, "UOS qty is not correspond in procurement."
assert shipment_procurement.product_uos.id == order_line.product_uos and order_line.product_uos.id or False, "UOS is not correspond in procurement."
assert shipment_procurement.location_id.id == production.location_src_id.id, "Location is not correspond in procurement."
assert shipment_procurement.procure_method == order_line.product_id.procure_method, "Procure method is not correspond in procurement."
-
I run scheduler.
-
!python {model: procurement.order}: |
self.run_scheduler(cr, uid)
-
The production order is Waiting Goods, I forcefully done internal shipment.
-
!python {model: mrp.production}: |
self.force_production(cr, uid, [ref("mrp_production_shelf100cm")])
-
I check that production order in ready state after forcefully done internal shipment.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp_production_shelf100cm"))
assert order.state == 'ready', 'Production order should be in Ready State.'
assert order.picking_id.state == 'done', 'Internal shipment should be done.'
-
Now I start production.
-
!workflow {model: mrp.production, action: button_produce, ref: mrp_production_shelf100cm}
-
I check that production order in production state after start production.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp_production_shelf100cm"))
assert order.state == 'in_production', 'Production order should be in production State.'
-
I consume raw materials and put one material in scrap location due to waste it.
-
!python {model: mrp.production}: |
scrap_location_ids = self.pool.get('stock.location').search(cr, uid, [('scrap_location','=',True)])
scrap_location_id = scrap_location_ids[0]
order = self.browse(cr, uid, ref("mrp_production_shelf100cm"))
for move in order.move_lines:
move.action_consume(move.product_qty)
if move.product_id.id == ref("product.product_product_metalcleats0"):
move.action_scrap(5.0, scrap_location_id)
-
I produce product.
-
!python {model: mrp.product.produce}: |
context.update({'active_id': ref('mrp_production_shelf100cm')})
-
!record {model: mrp.product.produce, id: mrp_product_produce1}:
mode: 'consume_produce'
-
!python {model: mrp.product.produce}: |
self.do_produce(cr, uid, [ref('mrp_product_produce1')], context=context)
-
I check production order after produced.
-
!assert {model: mrp.production, id: mrp_production_shelf100cm}:
- state == 'done'
-
I print a "BOM Structure".
-
!python {model: mrp.production}: |
import netsvc, tools, os
order = self.browse(cr, uid, ref("mrp_production_shelf100cm"))
(data, format) = netsvc.LocalService('report.bom.structure').create(cr, uid, [order.bom_id.id], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'mrp-bom_structure_report.'+format), 'wb+').write(data)
-
I print "Production Order".
-
!python {model: mrp.production}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.mrp.production.order').create(cr, uid, [ref("mrp_production_shelf100cm")], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'mrp-production_order_report.'+format), 'wb+').write(data)
-
I print "Work Center Load Report".
-
!python {model: mrp.workcenter}: |
ctx = context.copy()
ctx.update({'model': 'mrp.workcenter','active_ids': [ref('mrp_workcenter_0'),ref('mrp_workcenter_1')]})
data_dict = {'time_unit': 'day', 'measure_unit': 'hours'}
from tools import test_reports
test_reports.try_report_action(cr, uid, 'action_mrp_workcenter_load_wizard',wiz_data=data_dict, context=ctx, our_module='mrp')
+3 -3
View File
@@ -71,10 +71,10 @@ class mrp_product_produce(osv.osv_memory):
if context is None:
context = {}
prod_obj = self.pool.get('mrp.production')
move_ids = context.get('active_ids', [])
production_ids = context.get('active_ids', [])
for data in self.browse(cr, uid, ids, context=context):
for move_id in move_ids:
prod_obj.action_produce(cr, uid, move_id,
for production_id in production_ids:
prod_obj.action_produce(cr, uid, production_id,
data.product_qty, data.mode, context=context)
return {}
+6 -2
View File
@@ -64,8 +64,12 @@ So that we can compare the theoretic delay and real delay.
'report/mrp_workorder_analysis_view.xml',
'process/mrp_operation_process.xml'
],
'demo_xml': ['mrp_operation_data.xml'],
'test': ['test/mrp_operations.yml', 'test/mrp_operations_report.yml','test/mrp_operation_test.yml'],
'demo_xml': ['mrp_operation_data.xml',
'mrp_operations_demo.yml'],
'test': ['test/check_mo2operations.yml',
'test/check_operations2mo.yml',
'test/check_mo_cancel.yml',
'test/mrp_operations_report.yml'],
'installable': True,
'active': False,
'certificate': '0056233813133',
@@ -0,0 +1,24 @@
-
!record {model: mrp.production, id: mrp_production_op}:
location_src_id: stock.stock_location_stock
product_id: product.product_product_cpu3
product_qty: 5.0
allow_reorder: True
-
!record {model: mrp.production, id: mrp_production_op1}:
location_src_id: stock.stock_location_stock
product_id: product.product_product_cpu3
product_qty: 2.0
-
!function {model: mrp.production, name: action_compute, id: mrp_production_op1}:
- model: mrp.production
eval: "[obj(ref('mrp_production_op1')).id]"
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_op1}
-
!record {model: mrp.production, id: mrp_production_mo1}:
location_src_id: stock.stock_location_stock
product_id: product.product_product_cpu_gen
product_qty: 5.0
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1}
@@ -0,0 +1,59 @@
-
In order to test effect of relation between production orders and work orders, first I will see how changing production order will effect work orders,
-
I am computing the data.
-
!python {model: mrp.production}: |
self.action_compute(cr, uid, [ref("mrp_production_op")], {"lang": "en_US", "tz":
False, "search_default_current": 1, "active_model": "ir.ui.menu", "active_ids":
[ref("mrp.menu_mrp_production_action")], "active_id": ref("mrp.menu_mrp_production_action"),
})
-
I calculate planned end date of the production order.
-
!python {model: mrp.production}: |
mo = self.browse(cr, uid, ref("mrp_production_op"))
self._production_date_end(cr, uid, [ref("mrp_production_op")], mo.date_planned, False)
-
Now I confirm the production order.
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_op}
-
I check that there are two work orders generated for this production order.
-
!assert {model: mrp.production, id: mrp_production_op, string: There are 2 work orders.}:
- len(workcenter_lines) == 2
-
The production order is Waiting Goods, so I force reservation of components.
-
!python {model: mrp.production}:
self.force_production(cr, uid, [ref("mrp_production_op")])
-
Now I start the production order.
-
!workflow {model: mrp.production, action: button_produce, ref: mrp_production_op}
-
I check that the related work order is in progress state.
-
!assert {model: mrp.production, id: mrp_production_op, string: Operation is started.}:
- workcenter_lines[0].state == 'startworking'
-
I am creating a mrp.product.produce record.
-
!record {model: mrp.product.produce, id: mrp_product_produce_0}:
mode: consume_produce
product_qty: 5.0
-
I produce the products by clicking on 'Produce'.
-
!python {model: mrp.product.produce}: |
self.do_produce(cr, uid, [ref("mrp_product_produce_0")], {"lang": "en_US", "tz":
False, "search_default_current": 1, "active_model": "mrp.production", "active_ids":
[ref("mrp_production_op")], "active_id": ref("mrp_production_op"), })
-
I check all the related work orders for this production order are now done.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_op')),('state','=','done')])
assert order_id, _('The work orders related to this production order are not done yet!')
@@ -0,0 +1,29 @@
-
I check that there is one Work order generated related to the production order of 5 CPU_GEN.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo1')),('state','=','draft')])
assert order_id, _('No work order defined for this production order!')
-
In order to cancel the production order, I first cancel its picking.
-
!function {model: stock.picking, name: action_cancel}:
- model: mrp.production
eval: "[obj(ref('mrp_production_mo1')).picking_id.id]"
-
Now I cancel the production order.
-
!workflow {model: mrp.production, action: button_cancel, ref: mrp_production_mo1}
-
Now I check that the production order is cancelled.
-
!assert {model: mrp.production, id: mrp_production_mo1}:
- state == 'cancel'
-
I check that the work order related to the production order that is cancelled or not.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo1')),('state','=','cancel')])
assert order_id, _('Work order is not cancelled for this production order!')
@@ -0,0 +1,51 @@
-
I check that there are two work orders generated for the production order of 2 CPU3.
-
!assert {model: mrp.production, id: mrp_production_op1, string: Operation is started.}:
- len(workcenter_lines) == 2
-
I change the scheduled date of first work order and then I start it.
-
!python {model: mrp.production.workcenter.line}: |
order_ids = self.search(cr, uid, [('production_id','=', ref('mrp_production_op1'))])
from datetime import datetime
self.write(cr, uid, [order_ids[0]], {'date_planned': datetime.today().strftime("%Y-%m-%d 10:00:00")})
import netsvc
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_ids[0], 'button_start_working', cr)
-
I check now the production order is in production state.
-
!assert {model: mrp.production, id: mrp_production_op1, string: Production order is started.}:
- state == 'in_production'
-
The first work order is done, so I mark it as done.
-
!python {model: mrp.production.workcenter.line}: |
order_ids = self.search(cr, uid, [('production_id','=', ref('mrp_production_op1'))])
import netsvc
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_ids[0], 'button_done', cr)
-
Now I start second work order then pause it and then resume it.
-
!python {model: mrp.production.workcenter.line}: |
order_ids = self.search(cr, uid, [('production_id','=', ref('mrp_production_op1'))])
import netsvc
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_ids[-1], 'button_start_working', cr)
wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_ids[-1], 'button_pause', cr)
wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_ids[-1], 'button_resume', cr)
-
I mark second work order as done.
-
!python {model: mrp.production.workcenter.line}: |
order_ids = self.search(cr, uid, [('production_id','=', ref('mrp_production_op1'))])
import netsvc
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_ids[-1], 'button_done', cr)
-
I check that the production order is now done.
-
!assert {model: mrp.production, id: mrp_production_op1}:
- state == 'done'
@@ -1,56 +0,0 @@
-
In order to test mrp_operations module in OpenERP,
I create a production order.
-
!record {model: mrp.production, id: mrp_production_mo1}:
company_id: base.main_company
date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
location_dest_id: stock.stock_location_stock
location_src_id: stock.stock_location_stock
name: MO/01234567
product_id: product.product_product_pc1
product_qty: 5.0
product_uom: product.product_uom_unit
product_uos_qty: 5.0
-
Now I confirm the production order.
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1}
-
I check that there is one Work order generated related to the production order.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo1')),('state','=','draft')])
assert order_id, _('No work order defined for this production order!')
-
The scheduler runs.
-
!function {model: procurement.order, name: run_scheduler}:
- model: procurement.order
search: "[('state','=','confirmed')]"
-
I am checking Internal picking.
-
!python {model: mrp.production}: |
from tools.translate import _
pick_ids = self.browse(cr, uid, ref("mrp_production_mo1"))
assert pick_ids.picking_id.id, _('No Internal Picking generated!')
-
In order to cancel the MO, first cancel its picking
-
!python {model: stock.picking}: |
mrp_obj = self.pool.get('mrp.production')
mo = mrp_obj.browse(cr, uid, ref("mrp_production_mo1"))
self.action_cancel(cr, uid, [mo.picking_id.id], context=None)
-
Then cancel The Manufacturing order.
-
!workflow {model: mrp.production, action: button_cancel, ref: mrp_production_mo1}
-
I check that there is one Work order generated related to the production order that is cancelled or not.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo1')),('state','=','cancel')])
assert order_id, _('Work order is not cancelled for this production order!')
@@ -1,158 +0,0 @@
-
In order to test mrp_operations module in OpenERP I will put a Production order
and check its effects on Work orders.
-
I create a production order.
-
!record {model: mrp.production, id: mrp_production_mo0}:
company_id: base.main_company
date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
location_dest_id: stock.stock_location_stock
location_src_id: stock.stock_location_stock
name: MO/0123456
product_id: product.product_product_pc1
product_qty: 5.0
product_uom: product.product_uom_unit
product_uos_qty: 5.0
allow_reorder: True
-
I am computing the data.
-
!python {model: mrp.production}: |
self.action_compute(cr, uid, [ref("mrp_production_mo0")], {"lang": "en_US", "tz":
False, "search_default_current": 1, "active_model": "ir.ui.menu", "active_ids":
[ref("mrp.menu_mrp_production_action")], "active_id": ref("mrp.menu_mrp_production_action"),
})
-
Now I confirm my production order.
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo0}
-
I check that there is one Work order generated related to my production order.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo0')),('state','=','draft')])
assert order_id, _('No Work order define for this production order!')
-
The scheduler runs.
-
!function {model: procurement.order, name: run_scheduler}:
- model: procurement.order
search: "[('state','=','confirmed')]"
-
I am checking Internal picking.
-
!python {model: stock.picking}: |
from tools.translate import _
pick_ids = self.search(cr, uid, [('state','!=','done'),('type','=','internal')])
assert pick_ids, _('No Internal Pickings!')
-
I see that there is a manufacturing order for the sub product CPU_GEN of PC1 with ready state.
-
!python {model: mrp.production}: |
from tools.translate import _
order_ids = self.search(cr, uid, [('state','=','ready'),('origin','like','%MO/0123456')])
assert order_ids, _('No new manufacturing order!')
-
I check that there one more work order created for new production order.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
prod_obj = self.pool.get('mrp.production')
prod_order_ids = prod_obj.search(cr, uid, [('state','=','ready'),('origin','like','%MO/0123456')])
workorder_id = self.search(cr, uid, [('production_id','=', prod_order_ids[0]),('state','=','draft')])
assert workorder_id, _('No Work order define for this production order!')
-
I start the second production order of the CPU_GEN product.
-
!python {model: mrp.production}: |
import netsvc
wf_service = netsvc.LocalService("workflow")
prod_order_ids = self.search(cr, uid, [('state','=','ready'),('origin','like','%MO/0123456')])
for po in prod_order_ids:
wf_service.trg_validate(uid, 'mrp.production', po, 'button_produce', cr)
-
I am creating a mrp.product.produce record
-
!record {model: mrp.product.produce, id: mrp_product_produce_0}:
mode: consume_produce
product_qty: 5.0
-
I produce the product CPU_GEN.
-
!python {model: mrp.product.produce}: |
prod_obj = self.pool.get('mrp.production')
prod_order_ids = prod_obj.search(cr, uid, [('origin','like','%MO/0123456')])
self.do_produce(cr, uid, [ref("mrp_product_produce_0")], {"lang": "en_US", "tz":
False, "search_default_current": 1, "active_model": "mrp.production", "active_ids":
prod_order_ids, "active_id": prod_order_ids[0], })
-
I check that my production order and its related work order is in done state.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
prod_obj = self.pool.get('mrp.production')
prod_order_ids = prod_obj.search(cr, uid, [('origin','like','%MO/0123456')])
assert prod_order_ids, _('Workorder not found')
workorder_id = self.search(cr, uid, [('production_id','=', prod_order_ids[0])])
workorder_bro = self.browse(cr, uid, workorder_id[0])
assert workorder_bro.state == 'done', _('Work order is not done! It is %s') % workorder_bro.state
-
Now I check my original production order is now ready.
-
!python {model: mrp.production}: |
from tools.translate import _
prod_ids = self.search(cr, uid, [('id','=',ref('mrp_production_mo0')),('state','=','ready')])
assert prod_ids, _('Production order is not ready!')
-
I check that both internal pickings are done.
-
!python {model: stock.picking}: |
from tools.translate import _
pick_ids = self.search(cr, uid, [('state','=','done'),('type','=','internal')])
assert pick_ids, _('Internal pickings are not done!')
-
Now I start my first production order.
-
!workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo0}
-
I check that the related work order is in progress state.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo0')),('state','=','startworking')])
assert order_id, _('Work order not started yet!')
-
I am creating a mrp.product.produce record.
-
!record {model: mrp.product.produce, id: mrp_product_produce_0}:
mode: consume_produce
product_qty: 5.0
-
I produce the product PC1.
-
!python {model: mrp.product.produce}: |
prod_obj = self.pool.get('mrp.production')
prod_order_ids = prod_obj.search(cr, uid, [('state','=','in_production')])
self.do_produce(cr, uid, [ref("mrp_product_produce_0")], {"lang": "en_US", "tz":
False, "search_default_current": 1, "active_model": "mrp.production", "active_ids":
[ref("mrp_production_mo0")], "active_id": ref("mrp_production_mo0"), })
-
I check the related work order is done.
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo0')),('state','=','done')])
assert order_id, _('Work order not done yet!')
-
Calculates start date for stock moves finding interval from resource calendar.
-
!python {model: mrp.production}: |
self._move_pass(cr, uid, [ref('mrp_production_mo0')], context=None)
-
Calculates planned end date of production order.
-
!python {model: mrp.production}: |
mo = self.browse(cr, uid, ref("mrp_production_mo0"))
self._production_date_end(cr, uid, [ref("mrp_production_mo0")], mo.date_planned, False, context=None)