[IMP]stock :Fixed
* processing of product with different uom is working, * made tracking field as function field, * better validation for uom for partial picking Quantity(wizard) check with picking Qty: * production lot required if product have track incoming/outgoing true [TOCHECK: in one2many field of wizard even if we have prodlot required and we donot fill it, and click of process it will not give any warning like correct red fields, but if we open that line in one2many field and then click on process it will give warning] bzr revid: ron@tinyerp.com-20110411124204-25bcgs2024lln14n
This commit is contained in:
@@ -1162,6 +1162,7 @@ class stock_picking(osv.osv):
|
||||
complete, too_many, too_few = [], [], []
|
||||
move_product_qty = {}
|
||||
prodlot_ids = {}
|
||||
product_uoms = {}
|
||||
product_avail = {}
|
||||
for move in pick.move_lines:
|
||||
if move.state in ('done', 'cancel'):
|
||||
@@ -1174,6 +1175,7 @@ class stock_picking(osv.osv):
|
||||
product_currency = partial_data.get('product_currency',False)
|
||||
prodlot_id = partial_data.get('prodlot_id')
|
||||
prodlot_ids[move.id] = prodlot_id
|
||||
product_uoms[move.id] = product_uom
|
||||
if move.product_qty == product_qty:
|
||||
complete.append(move)
|
||||
elif move.product_qty > product_qty:
|
||||
@@ -1232,7 +1234,7 @@ class stock_picking(osv.osv):
|
||||
'state': 'assigned',
|
||||
'move_dest_id': False,
|
||||
'price_unit': move.price_unit,
|
||||
'product_uom':product_uom,
|
||||
'product_uom':product_uoms[move.id],
|
||||
}
|
||||
prodlot_id = prodlot_ids[move.id]
|
||||
if prodlot_id:
|
||||
@@ -1248,7 +1250,7 @@ class stock_picking(osv.osv):
|
||||
if new_picking:
|
||||
move_obj.write(cr, uid, [c.id for c in complete], {'picking_id': new_picking})
|
||||
for move in complete:
|
||||
defaults = {'product_uom': product_uom}
|
||||
defaults = {'product_uom': product_uoms[move.id]}
|
||||
if prodlot_ids.get(move.id):
|
||||
defaults.update({'prodlot_id': prodlot_ids[move.id]})
|
||||
move_obj.write(cr, uid, move.id, defaults)
|
||||
@@ -1257,7 +1259,7 @@ class stock_picking(osv.osv):
|
||||
defaults = {
|
||||
'product_qty' : product_qty,
|
||||
'product_uos_qty': product_qty, #TODO: put correct uos_qty
|
||||
'product_uom': product_uom
|
||||
'product_uom': product_uoms[move.id]
|
||||
}
|
||||
prodlot_id = prodlot_ids.get(move.id)
|
||||
if prodlot_ids.get(move.id):
|
||||
|
||||
@@ -25,6 +25,17 @@ import time
|
||||
|
||||
|
||||
class stock_partial_move_memory_out(osv.osv_memory):
|
||||
|
||||
def _tracking(self, cursor, user, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for tracklot in self.browse(cursor, user, ids, context=context):
|
||||
tracking = False
|
||||
if (tracklot.move_id.picking_id.type == 'in' and tracklot.product_id.track_incoming == True) or \
|
||||
(tracklot.move_id.picking_id.type == 'out' and tracklot.product_id.track_outgoing == True):
|
||||
tracking = True
|
||||
res[tracklot.id] = tracking
|
||||
return res
|
||||
|
||||
_name = "stock.move.memory.out"
|
||||
_rec_name = 'product_id'
|
||||
_columns = {
|
||||
@@ -36,7 +47,7 @@ class stock_partial_move_memory_out(osv.osv_memory):
|
||||
'wizard_id' : fields.many2one('stock.partial.move', string="Wizard"),
|
||||
'cost' : fields.float("Cost", help="Unit Cost for this product line"),
|
||||
'currency' : fields.many2one('res.currency', string="Currency", help="Currency in which Unit cost is expressed"),
|
||||
'tracking': fields.related('product_id', 'track_production', type='boolean', relation='product.product', string='Tracking'),
|
||||
'tracking': fields.function(_tracking, method=True, string='Tracking', type='boolean'),
|
||||
}
|
||||
|
||||
class stock_partial_move_memory_in(osv.osv_memory):
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<field name="product_id" />
|
||||
<field name="quantity" />
|
||||
<field name="product_uom" />
|
||||
<field name="prodlot_id" domain="[('product_id', '=', product_id)]" attrs="{'required':[('tracking','=',True)]}" groups="base.group_extended" />
|
||||
<field name="prodlot_id" domain="[('product_id', '=', product_id)]" groups="base.group_extended" />
|
||||
<field name="tracking" invisible="1"/>
|
||||
<field name="cost" />
|
||||
<field name="currency" />
|
||||
@@ -64,7 +64,7 @@
|
||||
<field name="product_id" />
|
||||
<field name="quantity" />
|
||||
<field name="product_uom" />
|
||||
<field name="prodlot_id" domain="[('product_id', '=', product_id)]" attrs="{'required':[('tracking','=',True)]}" groups="base.group_extended" />
|
||||
<field name="prodlot_id" domain="[('product_id', '=', product_id)]" groups="base.group_extended" />
|
||||
<field name="tracking" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
@@ -142,6 +142,7 @@ class stock_partial_picking(osv.osv_memory):
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
uom_obj = self.pool.get('product.uom')
|
||||
|
||||
picking_ids = context.get('active_ids', False)
|
||||
partial = self.browse(cr, uid, ids[0], context=context)
|
||||
@@ -152,10 +153,14 @@ class stock_partial_picking(osv.osv_memory):
|
||||
for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
|
||||
picking_type = self.get_picking_type(cr, uid, pick, context=context)
|
||||
moves_list = picking_type == 'in' and partial.product_moves_in or partial.product_moves_out
|
||||
|
||||
picking_qty = 0.0
|
||||
partial_qty = 0.0
|
||||
for get_qty in pick.move_lines:
|
||||
picking_qty += get_qty.product_qty
|
||||
for move in moves_list:
|
||||
partial_qty += uom_obj._compute_qty(cr, uid, move.product_uom.id, move.quantity, move.product_id.uom_id.id)
|
||||
if move.product_uom.category_id.id <> move.product_id.uom_id.category_id.id:
|
||||
raise osv.except_osv(_('Error !'), _('Product UoM category %s must be same with Product Default UoM Category %s!.') % (move.product_uom.category_id.name,move.product_id.uom_id.category_id.name,))
|
||||
raise osv.except_osv(_('Error !'), _('You are selected product uom category %s not same with picking product uom Category %s!.') % (move.product_uom.category_id.name,move.product_id.uom_id.category_id.name,))
|
||||
partial_datas['move%s' % (move.move_id.id)] = {
|
||||
'product_id': move.id,
|
||||
'product_qty': move.quantity,
|
||||
@@ -167,6 +172,8 @@ class stock_partial_picking(osv.osv_memory):
|
||||
'product_price' : move.cost,
|
||||
'product_currency': move.currency.id,
|
||||
})
|
||||
if picking_qty < partial_qty:
|
||||
raise osv.except_osv(_('Error !'), _('You cannot select Quantity %s more then Picking Quantity %s.') % (partial_qty, picking_qty,))
|
||||
pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user