Removed the tracking field, on the product and replaced by 4 boolean fields and put constraint in stock (stock.move) for tracking lot according to that, Changes in warning module for multi-warning, bug resolving while comfirming stock move
bzr revid: ruchakpatel@gmail.com-20080920115438-vd9sqqyc74ao3il8
This commit is contained in:
parent
b84a23475a
commit
e286419e1f
|
@ -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,10 @@ 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"),
|
||||
'track_other' : fields.boolean('Track Lots', help="Force to use a Production Lot number during stock operations for traceability."),
|
||||
'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 +426,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
|
||||
|
|
|
@ -67,11 +67,20 @@
|
|||
<field groups="base.group_extended" name="product_manager" select="2"/>
|
||||
</group>
|
||||
|
||||
<group colspan="2" col="2" name="uom">
|
||||
<group colspan="2" col="2" name="lot">
|
||||
<separator string="Lots" colspan="2"/>
|
||||
<group colspan="2" col="2" name="uom">
|
||||
<field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)"/>
|
||||
<field name="uom_po_id"/>
|
||||
<field name="tracking"/>
|
||||
</group>
|
||||
<group colspan="1" col="2" name="tracking1">
|
||||
<field name="track_production"/>
|
||||
<field name="track_incoming"/>
|
||||
</group>
|
||||
<group colspan="1" col="2" name="tracking2">
|
||||
<field name="track_outgoing"/>
|
||||
<field name="track_other"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<group colspan="2" col="2" name="uos" groups="product.group_uos">
|
||||
|
|
|
@ -361,7 +361,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
|
||||
|
@ -369,11 +368,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
|
||||
|
@ -381,7 +378,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={}):
|
||||
|
@ -403,7 +399,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 = {
|
||||
|
@ -852,7 +847,20 @@ class stock_move(osv.osv):
|
|||
return (res and res[0]) or False
|
||||
_name = "stock.move"
|
||||
_description = "Stock Move"
|
||||
|
||||
|
||||
def _check_product_tracking(self, cr, uid, ids):
|
||||
for move in self.browse(cr, uid, ids):
|
||||
if move.state == 'done' and not move.prodlot_id:
|
||||
if move.product_id.track_production and ((move.location_id.usage=='production') or (move.location_dest_id.usage=='production')):
|
||||
return False
|
||||
if move.product_id.track_incoming and ((move.location_id.usage=='supplier') or (move.location_dest_id.usage=='supplier')):
|
||||
return False
|
||||
if move.product_id.track_outgoing and ((move.location_id.usage=='track_outgoing') or (move.location_dest_id.usage=='track_outgoing')):
|
||||
return False
|
||||
if move.product_id.track_other:
|
||||
return False
|
||||
return True
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True, select=True),
|
||||
'priority': fields.selection([('0','Not urgent'),('1','Urgent')], 'Priority'),
|
||||
|
@ -889,6 +897,12 @@ class stock_move(osv.osv):
|
|||
'price_unit': fields.float('Unit Price',
|
||||
digits=(16, int(config['price_accuracy']))),
|
||||
}
|
||||
|
||||
_constraints = [
|
||||
(_check_product_tracking,
|
||||
'You must have to set 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']
|
||||
|
@ -957,8 +971,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, {
|
||||
|
|
|
@ -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