imporvement lot system
bzr revid: hmo@tinyerp.com-20080920135644-kn7ppbi5hg5f19by
This commit is contained in:
commit
ba7f591217
|
@ -228,7 +228,6 @@ product_category()
|
|||
class product_template(osv.osv):
|
||||
_name = "product.template"
|
||||
_description = "Product Template"
|
||||
|
||||
def _calc_seller_delay(self, cr, uid, ids, name, arg, context={}):
|
||||
result = {}
|
||||
for product in self.browse(cr, uid, ids, context):
|
||||
|
@ -269,7 +268,9 @@ class product_template(osv.osv):
|
|||
help='Coefficient to convert UOM to UOS\n'
|
||||
' uom = uos * coeff'),
|
||||
'mes_type': fields.selection((('fixed', 'Fixed'), ('variable', 'Variable')), 'Measure Type', required=True),
|
||||
'tracking': fields.boolean('Track Lots', help="Force to use a Production Lot number during stock operations for traceability."),
|
||||
'track_production' : fields.boolean('Track Production Lots' , help="Force to use a Production Lot number during Production"),
|
||||
'track_incoming' : fields.boolean('Track Incomming Lots', help="Force to use a Production Lot number during Purchase"),
|
||||
'track_outgoing' : fields.boolean('Track Outging Lots', help="Force to use a Production Lot number during Sale"),
|
||||
'seller_delay': fields.function(_calc_seller_delay, method=True, type='integer', string='Supplier Lead Time', help="This is the average delay in days between the purchase order confirmation and the reception of goods for this product and for the default supplier. It is used by the scheduler to order requests based on reordering delays."),
|
||||
'seller_ids': fields.one2many('product.supplierinfo', 'product_id', 'Partners'),
|
||||
'loc_rack': fields.char('Rack', size=16),
|
||||
|
@ -424,7 +425,6 @@ class product_product(osv.osv):
|
|||
uom_obj=self.pool.get('product.uom')
|
||||
uom=uom_obj.browse(cursor,user,[uom_id])[0]
|
||||
uom_po=uom_obj.browse(cursor,user,[uom_po_id])[0]
|
||||
print uom.category_id.id , uom_po.category_id.id
|
||||
if uom.category_id.id != uom_po.category_id.id:
|
||||
return {'value': {'uom_po_id': uom_id}}
|
||||
return False
|
||||
|
|
|
@ -68,10 +68,17 @@
|
|||
</group>
|
||||
|
||||
<group colspan="2" col="2" name="uom">
|
||||
<separator string="Lots" colspan="2"/>
|
||||
<separator string="UOM" colspan="2"/>
|
||||
<field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)"/>
|
||||
<field name="uom_po_id"/>
|
||||
<field name="tracking"/>
|
||||
</group>
|
||||
<group colspan="4" col="4" name="lot">
|
||||
<separator string="Lots" colspan="4"/>
|
||||
<field name="track_production" />
|
||||
<field name="track_incoming" />
|
||||
<field name="track_outgoing" />
|
||||
|
||||
|
||||
</group>
|
||||
|
||||
<group colspan="2" col="2" name="uos" groups="product.group_uos">
|
||||
|
|
|
@ -373,7 +373,6 @@ class stock_picking(osv.osv):
|
|||
_name = "stock.picking"
|
||||
_description = "Packing list"
|
||||
def _set_maximum_date(self, cr, uid, ids, name, value, arg, context):
|
||||
print 'max', ids, name, value, arg, context
|
||||
if not value: return False
|
||||
for pick in self.browse(cr, uid, ids, context):
|
||||
cr.execute("""update stock_move set
|
||||
|
@ -381,11 +380,9 @@ class stock_picking(osv.osv):
|
|||
where
|
||||
picking_id=%d and
|
||||
(date_planned=%s or date_planned>%s)""", (value,pick.id,pick.max_date,value))
|
||||
print 'Ok'
|
||||
return True
|
||||
|
||||
def _set_minimum_date(self, cr, uid, ids, name, value, arg, context):
|
||||
print 'min', ids, name, value, arg, context
|
||||
if not value: return False
|
||||
for pick in self.browse(cr, uid, ids, context):
|
||||
cr.execute("""update stock_move set
|
||||
|
@ -393,7 +390,6 @@ class stock_picking(osv.osv):
|
|||
where
|
||||
picking_id=%d and
|
||||
(date_planned=%s or date_planned<%s)""", (value,pick.id,pick.min_date,value))
|
||||
print 'Ok'
|
||||
return True
|
||||
|
||||
def get_min_max_date(self, cr, uid, ids, field_name, arg, context={}):
|
||||
|
@ -415,7 +411,6 @@ class stock_picking(osv.osv):
|
|||
for pick, dt1,dt2 in cr.fetchall():
|
||||
res[pick]['min_date'] = dt1
|
||||
res[pick]['max_date'] = dt2
|
||||
print res, ids
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
|
@ -788,6 +783,7 @@ class stock_production_lot(osv.osv):
|
|||
name=name+'/'+record['ref']
|
||||
res.append((record['id'], name))
|
||||
return res
|
||||
|
||||
|
||||
_name = 'stock.production.lot'
|
||||
_description = 'Production lot'
|
||||
|
@ -804,8 +800,8 @@ class stock_production_lot(osv.osv):
|
|||
from
|
||||
stock_report_prodlots
|
||||
where
|
||||
location_id in ('''+','.join(map(str, locations))+''' and
|
||||
prodlot_id in ('''+','.join(map(str, ids))+'''
|
||||
location_id in ('''+','.join(map(str, locations))+''') and
|
||||
prodlot_id in ('''+','.join(map(str, ids))+''')
|
||||
group by
|
||||
prodlot_id
|
||||
''')
|
||||
|
@ -864,7 +860,27 @@ class stock_move(osv.osv):
|
|||
return (res and res[0]) or False
|
||||
_name = "stock.move"
|
||||
_description = "Stock Move"
|
||||
|
||||
def _check_tracking(self, cr, uid, ids):
|
||||
for move in self.browse(cr, uid, ids):
|
||||
if not move.prodlot_id and \
|
||||
(move.state == 'done' and \
|
||||
( \
|
||||
(move.product_id.track_production and move.location_id.usage=='production') or \
|
||||
(move.product_id.track_production and move.location_dest_id.usage=='production') or \
|
||||
(move.product_id.track_incoming and move.location_id.usage=='supplier') or \
|
||||
(move.product_id.track_outgoing and move.location_dest_id.usage=='customer') \
|
||||
)):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def _check_product_lot(self, cr, uid, ids):
|
||||
for move in self.browse(cr, uid, ids):
|
||||
if move.prodlot_id and (move.prodlot_id.product_id.id != move.product_id.id):
|
||||
return False
|
||||
return True
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True, select=True),
|
||||
'priority': fields.selection([('0','Not urgent'),('1','Urgent')], 'Priority'),
|
||||
|
@ -901,6 +917,15 @@ class stock_move(osv.osv):
|
|||
'price_unit': fields.float('Unit Price',
|
||||
digits=(16, int(config['price_accuracy']))),
|
||||
}
|
||||
|
||||
_constraints = [
|
||||
(_check_tracking,
|
||||
'Production lot must be set',
|
||||
['prodlot_id']),
|
||||
(_check_product_lot,
|
||||
'Move Production lot must be on the same Product Production lot',
|
||||
['prodlot_id'])]
|
||||
|
||||
def _default_location_destination(self, cr, uid, context={}):
|
||||
if context.get('move_line', []):
|
||||
return context['move_line'][0][2]['location_dest_id']
|
||||
|
@ -939,6 +964,16 @@ class stock_move(osv.osv):
|
|||
cursor.commit()
|
||||
|
||||
|
||||
def onchange_lot_id(self, cr, uid, context, prodlot_id=False,product_qty=False, loc_id=False):
|
||||
if not prodlot_id or not loc_id:
|
||||
return {}
|
||||
prodlot = self.pool.get('stock.production.lot').browse(cr, uid, [prodlot_id])[0]
|
||||
location=self.pool.get('stock.location').browse(cr,uid,[loc_id])[0]
|
||||
warning={}
|
||||
if not prodlot.stock_available or (location.usage == 'internal' and product_qty < prodlot.stock_available):
|
||||
warning={'title':'Warning!','message':'Less stock available than given quantity'}
|
||||
return {'warning':warning}
|
||||
|
||||
def onchange_product_id(self, cr, uid, context, prod_id=False, loc_id=False, loc_dest_id=False):
|
||||
if not prod_id:
|
||||
return {}
|
||||
|
@ -969,8 +1004,11 @@ class stock_move(osv.osv):
|
|||
return result
|
||||
|
||||
def action_confirm(self, cr, uid, moves, context={}):
|
||||
ids = map(lambda m: m.id, moves)
|
||||
ids = moves
|
||||
if not type(moves) == type([]):
|
||||
ids = map(lambda m: m.id, moves)
|
||||
self.write(cr, uid, ids, {'state':'confirmed'})
|
||||
moves= self.pool.get('stock.move').browse(cr, uid, moves)
|
||||
for picking, todo in self._chain_compute(cr, uid, moves, context).items():
|
||||
ptype = self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
|
||||
pickid = self.pool.get('stock.picking').create(cr, uid, {
|
||||
|
@ -1176,10 +1214,6 @@ class stock_move(osv.osv):
|
|||
'ref': ref,
|
||||
})
|
||||
|
||||
|
||||
if (move.product_id.tracking and not move.prodlot_id):
|
||||
raise osv.except_osv('Warning ! ','You should put a production lot for : '+move.product_id.name)
|
||||
|
||||
self.write(cr, uid, ids, {'state':'done'})
|
||||
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
|
|
|
@ -1163,7 +1163,7 @@
|
|||
<field name="priority"/>
|
||||
<field name="address_id" select="1" context="{'context_display':'partner'}"/>
|
||||
<newline/>
|
||||
<field name="prodlot_id" select="1" context="{'location_id':location_id, 'product_id':product_id}" domain="[('product_id','=',product_id)]"/>
|
||||
<field name="prodlot_id" select="1" context="{'location_id':location_id, 'product_id':product_id}" on_change="onchange_lot_id(prodlot_id,product_qty, location_id)" domain="[('product_id','=',product_id)]"/>
|
||||
<field name="tracking_id" select="1"/>
|
||||
<newline/>
|
||||
<label/>
|
||||
|
|
|
@ -155,14 +155,16 @@ class sale_order_line(osv.osv):
|
|||
if product_info.sale_line_warn:
|
||||
title= "Message",
|
||||
message= product_info.sale_line_warn_msg
|
||||
|
||||
result = super(sale_order_line, self).product_id_change( cr, uid, ids, pricelist, product, qty=0,
|
||||
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
|
||||
lang=False, update_tax=True, date_order=False, packaging=False)['value']
|
||||
result = super(sale_order_line, self).product_id_change( cr, uid, ids, pricelist, product, qty,
|
||||
uom, qty_uos, uos, name, partner_id,
|
||||
lang, update_tax, date_order, packaging)
|
||||
if title and message:
|
||||
warning['title']=title[0]
|
||||
warning['message']=message
|
||||
if result.get('warning',False):
|
||||
warning['title']=title and title+' & '+result['warning']['title'] or result['warning']['title']
|
||||
warning['message']=message and message +' '+result['warning']['message'] or result['warning']['message']
|
||||
return {'value': result, 'warning':warning}
|
||||
warning['title']= title and title[0]+' & '+result['warning']['title'] or result['warning']['title']
|
||||
warning['message']=message and message +'\n\n'+result['warning']['message'] or result['warning']['message']
|
||||
return {'value': result['value'], 'warning':warning}
|
||||
|
||||
sale_order_line()
|
||||
|
||||
|
@ -175,15 +177,21 @@ class purchase_order_line(osv.osv):
|
|||
return {'value': {'price_unit': 0.0, 'name':'','notes':'', 'product_uom' : False}, 'domain':{'product_uom':[]}}
|
||||
product_obj = self.pool.get('product.product')
|
||||
product_info = product_obj.browse(cr, uid, product)
|
||||
title=False
|
||||
message=False
|
||||
if product_info.purchase_line_warn:
|
||||
warning={
|
||||
'title': "Message",
|
||||
'message': product_info.purchase_line_warn_msg
|
||||
}
|
||||
title = "Message"
|
||||
message = product_info.purchase_line_warn_msg
|
||||
|
||||
result = super(purchase_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty, uom,
|
||||
partner_id, date_order=False)['value']
|
||||
return {'value': result, 'warning':warning}
|
||||
partner_id, date_order)
|
||||
if title and message:
|
||||
warning['title']=title[0]
|
||||
warning['message']=message
|
||||
if result.get('warning',False):
|
||||
warning['title']= title and title[0]+' & '+result['warning']['title'] or result['warning']['title']
|
||||
warning['message']=message and message +'\n\n'+result['warning']['message'] or result['warning']['message']
|
||||
return {'value': result['value'], 'warning':warning}
|
||||
|
||||
purchase_order_line()
|
||||
|
||||
|
|
Loading…
Reference in New Issue