[IMP] stock,mrp:Changes in the way scrap products are handled.Considered as consumed product & Same products entries are created indicating that products are required for manufacturing.

bzr revid: mso@mso-20100309063133-giiqvwqewlg61nm2
This commit is contained in:
mso 2010-03-09 12:01:33 +05:30
parent 748a44059e
commit 91d45aa7a1
2 changed files with 38 additions and 3 deletions

View File

@ -506,7 +506,7 @@
<field colspan="2" name="move_lines2" nolabel="1" domain="[('state','in', ('done', 'cancel'))]"
widget="one2many_list" mode="tree,form" height="275">
<tree string="Consumed Products" editable="bottom">
<tree string="Consumed Products" editable="bottom" colors="red:state=='cancel';black:state=='done';">
<field name="product_id" readonly="1"/>
<field name="product_qty" readonly="1"/>
<field name="product_uom" readonly="1" />

View File

@ -1309,7 +1309,40 @@ class stock_move(osv.osv):
wf_service.trg_trigger(uid, 'stock.move', id, cr)
#self.action_cancel(cr,uid, ids2, context)
return True
def action_scrap(self, cr, uid, ids,context=None):
'''
add the damaged product into consumed product by updating its state to cancel and
add same product since we need that product to manufacture the parent product.
:param cr: the database cursor
:param uid: the user id
:param ids: ids of product object to be scraped
:param context: context arguments
:return:
'''
# to find the parent id(manufacturing order) of the active record(product to consume),
# obtain active record id 1st and then get the production_id from mrp_production_move_ids
active_id=ids[0]
cr.execute("select production_id from mrp_production_move_ids where move_id=%s" % (active_id))
# it gives parent id in [list(tuple)] format so extract it [(21,)]
parent_id = int(cr.fetchall()[0][0])
# get the parent object
parent_obj = self.pool.get('mrp.production').browse(cr, uid, parent_id)
# create copy for multiple id processing for product to consume which r scraped
for id in ids:
#create copy of the product records which are scraped due to damage since they are
#still required to manufacture the product.
new_rec_id = self.copy(cr, uid, id, {'state': 'waiting'}, context)
#assign all new products which will replace damaged product to the current manufacturing order
cr.execute('insert into mrp_production_move_ids (production_id,move_id) values (%s,%s)', (parent_id, new_rec_id))
# all damaged product needs to be in consumed product window having cancel state.
vals={'state': 'cancel', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S')}
self.pool.get('stock.move').write(cr, uid, ids,vals )
return True
def action_done(self, cr, uid, ids, context=None):
track_flag = False
picking_ids = []
@ -1563,7 +1596,9 @@ class stock_move(osv.osv):
self.write(cr, uid, [move.id], update_val)
if consume:
self.action_done(cr, uid, res)
self.action_done(cr, uid, res)
else:
self.action_scrap(cr, uid, res,context)
return res
def scrap_moves(self, cr, uid, ids, quantity, location_dest_id, context=None):