From a7e61a9e65fb5b6ff4272c0aca8eae5e25de7588 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Mon, 11 Apr 2011 12:20:10 +0530
Subject: [PATCH 01/17] [FIX]stock :Fixed * changing UOM on partial picking
wizard * made product field readonly, * 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]
lp bug: https://launchpad.net/bugs/751222 fixed
bzr revid: ron@tinyerp.com-20110411065010-hps176e1a4zvow3d
---
addons/stock/stock.py | 7 +++++--
addons/stock/wizard/stock_partial_move.py | 3 ++-
addons/stock/wizard/stock_partial_move_view.xml | 12 ++++++++----
addons/stock/wizard/stock_partial_picking.py | 2 ++
4 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 96f5855166e..0064dc4bf0a 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1180,7 +1180,6 @@ class stock_picking(osv.osv):
too_few.append(move)
else:
too_many.append(move)
-
# Average price computation
if (pick.type == 'in') and (move.product_id.cost_method == 'average'):
product = product_obj.browse(cr, uid, move.product_id.id)
@@ -1233,6 +1232,7 @@ class stock_picking(osv.osv):
'state': 'assigned',
'move_dest_id': False,
'price_unit': move.price_unit,
+ 'product_uom':product_uom,
}
prodlot_id = prodlot_ids[move.id]
if prodlot_id:
@@ -1248,13 +1248,16 @@ 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}
if prodlot_ids.get(move.id):
- move_obj.write(cr, uid, move.id, {'prodlot_id': prodlot_ids[move.id]})
+ defaults.update({'prodlot_id': prodlot_ids[move.id]})
+ move_obj.write(cr, uid, move.id, defaults)
for move in too_many:
product_qty = move_product_qty[move.id]
defaults = {
'product_qty' : product_qty,
'product_uos_qty': product_qty, #TODO: put correct uos_qty
+ 'product_uom': product_uom
}
prodlot_id = prodlot_ids.get(move.id)
if prodlot_ids.get(move.id):
diff --git a/addons/stock/wizard/stock_partial_move.py b/addons/stock/wizard/stock_partial_move.py
index 874b22844d1..2f0959f247a 100644
--- a/addons/stock/wizard/stock_partial_move.py
+++ b/addons/stock/wizard/stock_partial_move.py
@@ -28,7 +28,7 @@ class stock_partial_move_memory_out(osv.osv_memory):
_name = "stock.move.memory.out"
_rec_name = 'product_id'
_columns = {
- 'product_id' : fields.many2one('product.product', string="Product", required=True),
+ 'product_id' : fields.many2one('product.product', string="Product", required=True, readonly=True),
'quantity' : fields.float("Quantity", required=True),
'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True),
'prodlot_id' : fields.many2one('stock.production.lot', 'Production Lot'),
@@ -36,6 +36,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'),
}
class stock_partial_move_memory_in(osv.osv_memory):
diff --git a/addons/stock/wizard/stock_partial_move_view.xml b/addons/stock/wizard/stock_partial_move_view.xml
index ec33dff083b..0647c2ba76c 100644
--- a/addons/stock/wizard/stock_partial_move_view.xml
+++ b/addons/stock/wizard/stock_partial_move_view.xml
@@ -30,7 +30,8 @@
-
+
+
@@ -46,7 +47,8 @@
-
+
+
@@ -62,7 +64,8 @@
-
+
+
@@ -76,7 +79,8 @@
-
+
+
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index 421bcae10ba..4fd6030269d 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -154,6 +154,8 @@ class stock_partial_picking(osv.osv_memory):
moves_list = picking_type == 'in' and partial.product_moves_in or partial.product_moves_out
for move in moves_list:
+ 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,))
partial_datas['move%s' % (move.move_id.id)] = {
'product_id': move.id,
'product_qty': move.quantity,
From f8a2f424824514d46e3be34fd206cec8dfea73e8 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Mon, 11 Apr 2011 18:12:04 +0530
Subject: [PATCH 02/17] [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
---
addons/stock/stock.py | 8 +++++---
addons/stock/wizard/stock_partial_move.py | 13 ++++++++++++-
addons/stock/wizard/stock_partial_move_view.xml | 4 ++--
addons/stock/wizard/stock_partial_picking.py | 11 +++++++++--
4 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 0064dc4bf0a..748b1278cc1 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -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):
diff --git a/addons/stock/wizard/stock_partial_move.py b/addons/stock/wizard/stock_partial_move.py
index 2f0959f247a..72c151c8ddf 100644
--- a/addons/stock/wizard/stock_partial_move.py
+++ b/addons/stock/wizard/stock_partial_move.py
@@ -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):
diff --git a/addons/stock/wizard/stock_partial_move_view.xml b/addons/stock/wizard/stock_partial_move_view.xml
index 0647c2ba76c..02dd63fe5dd 100644
--- a/addons/stock/wizard/stock_partial_move_view.xml
+++ b/addons/stock/wizard/stock_partial_move_view.xml
@@ -30,7 +30,7 @@
-
+
@@ -64,7 +64,7 @@
-
+
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index 4fd6030269d..e03af945604 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -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'}
From 4624ad802949fd486a663a4ddbe1990ad25d1ceb Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Tue, 12 Apr 2011 15:02:36 +0530
Subject: [PATCH 03/17] [IMP]stock:Fixed => processing of product with
different uom is working and Refector code of do_partial picking
bzr revid: ron@tinyerp.com-20110412093236-cjl8sp2m848sjog4
---
addons/stock/stock.py | 36 +++++++++---------------------------
1 file changed, 9 insertions(+), 27 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 748b1278cc1..d0287987afa 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1159,11 +1159,8 @@ class stock_picking(osv.osv):
wf_service = netsvc.LocalService("workflow")
for pick in self.browse(cr, uid, ids, context=context):
new_picking = None
- complete, too_many, too_few = [], [], []
- move_product_qty = {}
- prodlot_ids = {}
- product_uoms = {}
- product_avail = {}
+ complete, too_few = [], []
+ move_product_qty,prodlot_ids, product_uoms, product_avail, partial_qty = {}, {}, {}, {}, {}
for move in pick.move_lines:
if move.state in ('done', 'cancel'):
continue
@@ -1176,12 +1173,11 @@ class stock_picking(osv.osv):
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:
+ partial_qty[move.id] = uom_obj._compute_qty(cr, uid, product_uoms[move.id], product_qty, move.product_uom.id)
+ if move.product_qty == partial_qty[move.id]:
complete.append(move)
- elif move.product_qty > product_qty:
- too_few.append(move)
else:
- too_many.append(move)
+ too_few.append(move)
# Average price computation
if (pick.type == 'in') and (move.product_id.cost_method == 'average'):
product = product_obj.browse(cr, uid, move.product_id.id)
@@ -1218,7 +1214,6 @@ class stock_picking(osv.osv):
for move in too_few:
product_qty = move_product_qty[move.id]
-
if not new_picking:
new_picking = self.copy(cr, uid, pick.id,
{
@@ -1243,31 +1238,18 @@ class stock_picking(osv.osv):
move_obj.write(cr, uid, [move.id],
{
- 'product_qty' : move.product_qty - product_qty,
- 'product_uos_qty':move.product_qty - product_qty, #TODO: put correct uos_qty
+ 'product_qty' : move.product_qty - partial_qty[move.id],
+ 'product_uos_qty':move.product_qty - partial_qty[move.id], #TODO: put correct uos_qty
})
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_uoms[move.id]}
+ product_qty = move_product_qty[move.id]
+ defaults = {'product_uom': product_uoms[move.id],'product_qty': product_qty}
if prodlot_ids.get(move.id):
defaults.update({'prodlot_id': prodlot_ids[move.id]})
move_obj.write(cr, uid, move.id, defaults)
- for move in too_many:
- product_qty = move_product_qty[move.id]
- defaults = {
- 'product_qty' : product_qty,
- 'product_uos_qty': product_qty, #TODO: put correct uos_qty
- 'product_uom': product_uoms[move.id]
- }
- prodlot_id = prodlot_ids.get(move.id)
- if prodlot_ids.get(move.id):
- defaults.update(prodlot_id=prodlot_id)
- if new_picking:
- defaults.update(picking_id=new_picking)
- move_obj.write(cr, uid, [move.id], defaults)
-
# At first we confirm the new picking (if necessary)
if new_picking:
From e4e94b12da78bc8b077ea2df79a717f89e77093f Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Thu, 14 Apr 2011 14:36:20 +0530
Subject: [PATCH 04/17] [IMP]stock :Fixed:Add proper validation and refector
code of do_partial picking
bzr revid: ron@tinyerp.com-20110414090620-qx3o3cb5hum36yku
---
addons/stock/stock.py | 3 ++-
addons/stock/wizard/stock_partial_picking.py | 17 +++++++++--------
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index d0287987afa..7e427e0eef6 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1213,6 +1213,8 @@ class stock_picking(osv.osv):
for move in too_few:
+ if move.product_qty < partial_qty[move.id]:
+ raise osv.except_osv(_('Error !'), _('You cannot select Quantity %s more then Picking Quantity %s.') % (partial_qty[move.id],move.product_qty,))
product_qty = move_product_qty[move.id]
if not new_picking:
new_picking = self.copy(cr, uid, pick.id,
@@ -1235,7 +1237,6 @@ class stock_picking(osv.osv):
if prodlot_id:
defaults.update(prodlot_id=prodlot_id)
move_obj.copy(cr, uid, move.id, defaults)
-
move_obj.write(cr, uid, [move.id],
{
'product_qty' : move.product_qty - partial_qty[move.id],
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index e03af945604..61ae803d423 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -153,14 +153,15 @@ 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)
+ picking_qty = 0.0
+ partial_qty = 0.0
if move.product_uom.category_id.id <> move.product_id.uom_id.category_id.id:
- 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,))
+ raise osv.except_osv(_('Error !'), _('You have 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,))
+ for originalmove in pick.move_lines:
+ if originalmove.product_id.id == move.product_id.id:
+ picking_qty += uom_obj._compute_qty(cr, uid, originalmove.product_uom.id, originalmove.product_qty, originalmove.product_id.uom_id.id)
+ partial_qty += uom_obj._compute_qty(cr, uid, move.product_uom.id, move.quantity, move.product_id.uom_id.id)
partial_datas['move%s' % (move.move_id.id)] = {
'product_id': move.id,
'product_qty': move.quantity,
@@ -172,8 +173,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,))
+ 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'}
From e2f26467617e74fbc40d7ecebfc36893e788728a Mon Sep 17 00:00:00 2001
From: "Rucha (Open ERP)"
Date: Fri, 15 Apr 2011 16:00:26 +0530
Subject: [PATCH 05/17] [IMP]: stock: Improvement in computation and error
messages
bzr revid: rpa@tinyerp.com-20110415103026-jcnz0a3gudl8ap3m
---
addons/stock/wizard/stock_partial_picking.py | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index 61ae803d423..793c1266b1b 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -154,14 +154,16 @@ class stock_partial_picking(osv.osv_memory):
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
for move in moves_list:
- picking_qty = 0.0
- partial_qty = 0.0
- if move.product_uom.category_id.id <> move.product_id.uom_id.category_id.id:
- raise osv.except_osv(_('Error !'), _('You have 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,))
- for originalmove in pick.move_lines:
- if originalmove.product_id.id == move.product_id.id:
- picking_qty += uom_obj._compute_qty(cr, uid, originalmove.product_uom.id, originalmove.product_qty, originalmove.product_id.uom_id.id)
- partial_qty += uom_obj._compute_qty(cr, uid, move.product_uom.id, move.quantity, move.product_id.uom_id.id)
+ move_uom = move.move_id.product_uom
+ process_uom = move.product_uom
+ if move_uom.category_id.id != process_uom.category_id.id:
+ raise osv.except_osv(_('Warning'), _('You can not process %s %s as it\'s category is different than category of %s of this move!') % (move.quantity, process_uom.name, move_uom.name))
+ if move_uom.factor < process_uom.factor:
+ raise osv.except_osv(_('Warning'), _('You can not process in UOM"%s" which is smaller than UOM "%s" of the current move.') % (process_uom.name, move_uom.name))
+
+ toprocess = uom_obj._compute_qty(cr, uid, move.product_uom.id, move.quantity, move.move_id.product_uom.id)
+ if toprocess > move.move_id.product_qty:
+ raise osv.except_osv(_('Warning'), _('You can not process "%s %s" as the qty is more than "%s %s" of respective move.') % (toprocess, process_uom.name, move.move_id.product_qty, move_uom.name))
partial_datas['move%s' % (move.move_id.id)] = {
'product_id': move.id,
'product_qty': move.quantity,
From c7546b327406c5378a2edeab07453f80946d0f1c Mon Sep 17 00:00:00 2001
From: "Rucha (Open ERP)"
Date: Fri, 15 Apr 2011 16:59:29 +0530
Subject: [PATCH 06/17] [FIX]: stock: FIxed warning string values
bzr revid: rpa@tinyerp.com-20110415112929-qszbxnz52dxp7tel
---
addons/stock/wizard/stock_partial_picking.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index 793c1266b1b..11ee6d4babb 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -159,11 +159,11 @@ class stock_partial_picking(osv.osv_memory):
if move_uom.category_id.id != process_uom.category_id.id:
raise osv.except_osv(_('Warning'), _('You can not process %s %s as it\'s category is different than category of %s of this move!') % (move.quantity, process_uom.name, move_uom.name))
if move_uom.factor < process_uom.factor:
- raise osv.except_osv(_('Warning'), _('You can not process in UOM"%s" which is smaller than UOM "%s" of the current move.') % (process_uom.name, move_uom.name))
+ raise osv.except_osv(_('Warning'), _('You can not process in UOM "%s" which is smaller than UOM "%s" of the current move.') % (process_uom.name, move_uom.name))
toprocess = uom_obj._compute_qty(cr, uid, move.product_uom.id, move.quantity, move.move_id.product_uom.id)
if toprocess > move.move_id.product_qty:
- raise osv.except_osv(_('Warning'), _('You can not process "%s %s" as the qty is more than "%s %s" of respective move.') % (toprocess, process_uom.name, move.move_id.product_qty, move_uom.name))
+ raise osv.except_osv(_('Warning'), _('You can not process "%s %s" as the qty is more than "%s %s" of respective move.') % (move.quantity, process_uom.name, move.move_id.product_qty, move_uom.name))
partial_datas['move%s' % (move.move_id.id)] = {
'product_id': move.id,
'product_qty': move.quantity,
From a1008551774d5abe2e70f5504a132dc62344e321 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Fri, 15 Apr 2011 18:03:04 +0530
Subject: [PATCH 07/17] [MERGE]:merged with lp:trunk-bug-751222-ron
bzr revid: ron@tinyerp.com-20110415123304-4oebtzs7tklkxbap
---
addons/stock/wizard/stock_partial_picking.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index 11ee6d4babb..245ed38cb80 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -175,8 +175,6 @@ 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'}
From 54e24571b64031e2d3c5101f3933671c6bd04f2f Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Fri, 15 Apr 2011 18:07:07 +0530
Subject: [PATCH 08/17] [IMP]stock:add warning message for quantiny<=0
bzr revid: ron@tinyerp.com-20110415123707-7n06d8vgmbjptqna
---
addons/stock/wizard/stock_partial_picking.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index 245ed38cb80..a69686eff28 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -156,6 +156,8 @@ class stock_partial_picking(osv.osv_memory):
for move in moves_list:
move_uom = move.move_id.product_uom
process_uom = move.product_uom
+ if move.quantity <= 0:
+ raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
if move_uom.category_id.id != process_uom.category_id.id:
raise osv.except_osv(_('Warning'), _('You can not process %s %s as it\'s category is different than category of %s of this move!') % (move.quantity, process_uom.name, move_uom.name))
if move_uom.factor < process_uom.factor:
From 61ee65d9f0738bd3771911b4a3806a5acc85d373 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Mon, 18 Apr 2011 17:52:43 +0530
Subject: [PATCH 09/17] [IMP]stock:Add tooltip for Average costing method
bzr revid: ron@tinyerp.com-20110418122243-idxew1aizo6ubzjw
---
addons/stock/wizard/stock_partial_move.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/stock/wizard/stock_partial_move.py b/addons/stock/wizard/stock_partial_move.py
index 72c151c8ddf..6802bedbf84 100644
--- a/addons/stock/wizard/stock_partial_move.py
+++ b/addons/stock/wizard/stock_partial_move.py
@@ -45,7 +45,7 @@ class stock_partial_move_memory_out(osv.osv_memory):
'prodlot_id' : fields.many2one('stock.production.lot', 'Production Lot'),
'move_id' : fields.many2one('stock.move', "Move"),
'wizard_id' : fields.many2one('stock.partial.move', string="Wizard"),
- 'cost' : fields.float("Cost", help="Unit Cost for this product line"),
+ 'cost' : fields.float("Cost", help="Unit Cost for this product line per Unit of Measure"),
'currency' : fields.many2one('res.currency', string="Currency", help="Currency in which Unit cost is expressed"),
'tracking': fields.function(_tracking, method=True, string='Tracking', type='boolean'),
}
From 2b83cdfff6cad28301e0956286b178e56792b165 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Wed, 27 Apr 2011 16:48:22 +0530
Subject: [PATCH 10/17] [ADD]stock:stock_partial_picking.py ADD comments for
increase readability of code
bzr revid: ron@tinyerp.com-20110427111822-ow49y4b5l99yeh07
---
addons/stock/wizard/stock_partial_move_view.xml | 7 ++++++-
addons/stock/wizard/stock_partial_picking.py | 8 ++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/addons/stock/wizard/stock_partial_move_view.xml b/addons/stock/wizard/stock_partial_move_view.xml
index 02dd63fe5dd..6121e0bab5a 100644
--- a/addons/stock/wizard/stock_partial_move_view.xml
+++ b/addons/stock/wizard/stock_partial_move_view.xml
@@ -20,7 +20,6 @@
-
stock.move.memory.tree
stock.move.memory.in
@@ -30,6 +29,9 @@
+
@@ -64,6 +66,9 @@
+
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index a69686eff28..f1a5ad29dcd 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -156,14 +156,22 @@ class stock_partial_picking(osv.osv_memory):
for move in moves_list:
move_uom = move.move_id.product_uom
process_uom = move.product_uom
+ #Quantiny must be Positive
if move.quantity <= 0:
raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
+
+ #category id must be same for respective move
if move_uom.category_id.id != process_uom.category_id.id:
raise osv.except_osv(_('Warning'), _('You can not process %s %s as it\'s category is different than category of %s of this move!') % (move.quantity, process_uom.name, move_uom.name))
+
+ #Pikcing move product UOM factor must be bigger with respective wizard move product uom factor
if move_uom.factor < process_uom.factor:
raise osv.except_osv(_('Warning'), _('You can not process in UOM "%s" which is smaller than UOM "%s" of the current move.') % (process_uom.name, move_uom.name))
+ #Compute the wizard Quantity for respective move.
toprocess = uom_obj._compute_qty(cr, uid, move.product_uom.id, move.quantity, move.move_id.product_uom.id)
+
+ #Compare wizard Quantity with respective picking move quantity if wizard move quantity bigger then it's giving warning.
if toprocess > move.move_id.product_qty:
raise osv.except_osv(_('Warning'), _('You can not process "%s %s" as the qty is more than "%s %s" of respective move.') % (move.quantity, process_uom.name, move.move_id.product_qty, move_uom.name))
partial_datas['move%s' % (move.move_id.id)] = {
From af951d8ed69f2f175f1f9c8c4089e8ad5603c861 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Wed, 29 Jun 2011 12:37:15 +0530
Subject: [PATCH 11/17] [IMP]stock:put attrs in tree view
bzr revid: ron@tinyerp.com-20110629070715-034200f7ehabtrph
---
addons/stock/wizard/stock_partial_move_view.xml | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/addons/stock/wizard/stock_partial_move_view.xml b/addons/stock/wizard/stock_partial_move_view.xml
index 6121e0bab5a..461146157cc 100644
--- a/addons/stock/wizard/stock_partial_move_view.xml
+++ b/addons/stock/wizard/stock_partial_move_view.xml
@@ -29,10 +29,7 @@
-
-
+
@@ -66,10 +63,7 @@
-
-
+
From 4e26a9025d7f380eb4cddccf927703e6572f5395 Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Thu, 10 Nov 2011 11:46:39 +0530
Subject: [PATCH 12/17] [IMP] stock: Refectoring whole code after merged with
addons
bzr revid: ron@tinyerp.com-20111110061639-urd36emcw2gl6ne2
---
addons/stock/stock.py | 11 +++----
addons/stock/wizard/stock_partial_picking.py | 32 ++++++++++++++++++-
.../wizard/stock_partial_picking_view.xml | 6 ++--
3 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 576c23366fa..0f1e47ec17a 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1168,7 +1168,7 @@ class stock_picking(osv.osv):
for pick in self.browse(cr, uid, ids, context=context):
new_picking = None
complete, too_few = [], []
- move_product_qty,prodlot_ids, product_uoms, product_avail, partial_qty = {}, {}, {}, {}, {}
+ move_product_qty, prodlot_ids, product_avail, partial_qty, product_uoms = {},{}, {},{},{}
for move in pick.move_lines:
if move.state in ('done', 'cancel'):
continue
@@ -1221,8 +1221,6 @@ class stock_picking(osv.osv):
for move in too_few:
- if move.product_qty < partial_qty[move.id]:
- raise osv.except_osv(_('Error !'), _('You cannot select Quantity %s more then Picking Quantity %s.') % (partial_qty[move.id],move.product_qty,))
product_qty = move_product_qty[move.id]
if not new_picking:
new_picking = self.copy(cr, uid, pick.id,
@@ -1239,7 +1237,7 @@ class stock_picking(osv.osv):
'state': 'assigned',
'move_dest_id': False,
'price_unit': move.price_unit,
- 'product_uom':product_uoms[move.id],
+ 'product_uom':product_uoms[move.id]
}
prodlot_id = prodlot_ids[move.id]
if prodlot_id:
@@ -1254,11 +1252,10 @@ 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:
- product_qty = move_product_qty[move.id]
- defaults = {'product_uom': product_uoms[move.id],'product_qty': product_qty}
+ defaults = {'product_uom': product_uoms[move.id],'product_qty': move_product_qty[move.id]}
if prodlot_ids.get(move.id):
defaults.update({'prodlot_id': prodlot_ids[move.id]})
- move_obj.write(cr, uid, move.id, defaults)
+ move_obj.write(cr, uid, [move.id], defaults)
# At first we confirm the new picking (if necessary)
if new_picking:
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index d617ea2b5da..8b71e6502eb 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -22,12 +22,25 @@
import time
from osv import fields, osv
from tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
+from tools.translate import _
class stock_partial_picking_line(osv.TransientModel):
+
+ 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.partial.picking.line"
_rec_name = 'product_id'
_columns = {
- 'product_id' : fields.many2one('product.product', string="Product", required=True, ondelete='CASCADE'),
+ 'product_id' : fields.many2one('product.product', string="Product", required=True, readonly=True, ondelete='CASCADE'),
'quantity' : fields.float("Quantity", required=True),
'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True, ondelete='CASCADE'),
'prodlot_id' : fields.many2one('stock.production.lot', 'Production Lot', ondelete='CASCADE'),
@@ -38,6 +51,7 @@ class stock_partial_picking_line(osv.TransientModel):
'update_cost': fields.boolean('Need cost update'),
'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", ondelete='CASCADE'),
+ 'tracking': fields.function(_tracking, method=True, string='Tracking', type='boolean'),
}
class stock_partial_picking(osv.osv_memory):
@@ -103,13 +117,29 @@ class stock_partial_picking(osv.osv_memory):
assert len(ids) == 1, 'Partial picking processing may only be done one at a time'
stock_picking = self.pool.get('stock.picking')
stock_move = self.pool.get('stock.move')
+ uom_obj = self.pool.get('product.uom')
partial = self.browse(cr, uid, ids[0], context=context)
partial_data = {
'delivery_date' : partial.date
}
picking_type = partial.picking_id.type
for move in partial.move_ids:
+ move_uom = move.move_id.product_uom
+ process_uom = move.product_uom
move_id = move.move_id.id
+
+ #Quantiny must be Positive
+ if move.quantity <= 0:
+ raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
+ #Pikcing move product UOM factor must be bigger with respective wizard move product uom factor
+ if move_uom.factor < process_uom.factor:
+ raise osv.except_osv(_('Warning'), _('You can not process in UOM "%s" which is smaller than UOM "%s" of the current move.') % (process_uom.name, move_uom.name))
+ #Compute the wizard Quantity for respective move.
+ toprocess = uom_obj._compute_qty(cr, uid, process_uom.id, move.quantity, move_uom.id)
+ #Compare wizard Quantity with respective picking move quantity if wizard move quantity bigger then it's giving warning.
+ if toprocess > move.move_id.product_qty:
+ raise osv.except_osv(_('Warning'), _('You can not process "%s %s" as the qty is more than "%s %s" of respective move.') % (move.quantity, process_uom.name, move.move_id.product_qty, move_uom.name))
+
if not move_id:
seq_obj_name = 'stock.picking.' + picking_type
move_id = stock_move.create(cr,uid,{'name' : self.pool.get('ir.sequence').get(cr, uid, seq_obj_name),
diff --git a/addons/stock/wizard/stock_partial_picking_view.xml b/addons/stock/wizard/stock_partial_picking_view.xml
index be85d266673..396c53694e3 100644
--- a/addons/stock/wizard/stock_partial_picking_view.xml
+++ b/addons/stock/wizard/stock_partial_picking_view.xml
@@ -38,7 +38,8 @@
-
+
+
@@ -56,7 +57,8 @@
-
+
+
From cf97a4e213113dc9b69da3d14307c55380a1b05b Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Thu, 10 Nov 2011 12:04:50 +0530
Subject: [PATCH 13/17] [IMP] stock: Removed tracking field from
stock_partial_move_view.xml
bzr revid: ron@tinyerp.com-20111110063450-fq105wmuxd65b1iq
---
addons/stock/wizard/stock_partial_move_view.xml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/addons/stock/wizard/stock_partial_move_view.xml b/addons/stock/wizard/stock_partial_move_view.xml
index 5e8e33e69fd..2df6adcc9e7 100644
--- a/addons/stock/wizard/stock_partial_move_view.xml
+++ b/addons/stock/wizard/stock_partial_move_view.xml
@@ -45,9 +45,8 @@
-
+
-
From 59a9f469dac55fa9ce9febc72f4f1632875e815e Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Thu, 10 Nov 2011 12:17:23 +0530
Subject: [PATCH 14/17] [IMP] Improved PEP standard
bzr revid: ron@tinyerp.com-20111110064723-phv553e5si9meyfb
---
addons/stock/stock.py | 8 ++++----
addons/stock/wizard/stock_partial_move.py | 1 -
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 0f1e47ec17a..e049fb5a84f 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1168,7 +1168,7 @@ class stock_picking(osv.osv):
for pick in self.browse(cr, uid, ids, context=context):
new_picking = None
complete, too_few = [], []
- move_product_qty, prodlot_ids, product_avail, partial_qty, product_uoms = {},{}, {},{},{}
+ move_product_qty, prodlot_ids, product_avail, partial_qty, product_uoms = {}, {}, {}, {}, {}
for move in pick.move_lines:
if move.state in ('done', 'cancel'):
continue
@@ -1237,7 +1237,7 @@ class stock_picking(osv.osv):
'state': 'assigned',
'move_dest_id': False,
'price_unit': move.price_unit,
- 'product_uom':product_uoms[move.id]
+ 'product_uom': product_uoms[move.id]
}
prodlot_id = prodlot_ids[move.id]
if prodlot_id:
@@ -1246,13 +1246,13 @@ class stock_picking(osv.osv):
move_obj.write(cr, uid, [move.id],
{
'product_qty' : move.product_qty - partial_qty[move.id],
- 'product_uos_qty':move.product_qty - partial_qty[move.id], #TODO: put correct uos_qty
+ 'product_uos_qty': move.product_qty - partial_qty[move.id], #TODO: put correct uos_qty
})
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_uoms[move.id],'product_qty': move_product_qty[move.id]}
+ defaults = {'product_uom': product_uoms[move.id], 'product_qty': move_product_qty[move.id]}
if prodlot_ids.get(move.id):
defaults.update({'prodlot_id': prodlot_ids[move.id]})
move_obj.write(cr, uid, [move.id], defaults)
diff --git a/addons/stock/wizard/stock_partial_move.py b/addons/stock/wizard/stock_partial_move.py
index 453964a4895..ec348656ce0 100644
--- a/addons/stock/wizard/stock_partial_move.py
+++ b/addons/stock/wizard/stock_partial_move.py
@@ -23,7 +23,6 @@ from osv import fields, osv
from tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
import time
-
class stock_partial_move_line(osv.osv_memory):
_inherit = "stock.partial.picking.line"
_name = "stock.partial.move.line"
From f3aa929bb0e7f26b86a5d4565c4caf173f8cf4ef Mon Sep 17 00:00:00 2001
From: "ron@tinyerp.com" <>
Date: Wed, 16 Nov 2011 18:02:51 +0530
Subject: [PATCH 15/17] [IMP, REF] stock: Removed constrain of uom factor
comparision and add warning on rounding uom quantity
bzr revid: ron@tinyerp.com-20111116123251-7b63br1570yapt0b
---
addons/stock/stock.py | 21 ++++++++++++++++++--
addons/stock/wizard/stock_partial_picking.py | 18 ++++++++++-------
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index e049fb5a84f..90ed24cd362 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1167,7 +1167,7 @@ class stock_picking(osv.osv):
wf_service = netsvc.LocalService("workflow")
for pick in self.browse(cr, uid, ids, context=context):
new_picking = None
- complete, too_few = [], []
+ complete, too_many, too_few = [], [], []
move_product_qty, prodlot_ids, product_avail, partial_qty, product_uoms = {}, {}, {}, {}, {}
for move in pick.move_lines:
if move.state in ('done', 'cancel'):
@@ -1184,8 +1184,11 @@ class stock_picking(osv.osv):
partial_qty[move.id] = uom_obj._compute_qty(cr, uid, product_uoms[move.id], product_qty, move.product_uom.id)
if move.product_qty == partial_qty[move.id]:
complete.append(move)
- else:
+ elif move.product_qty > partial_qty[move.id]:
too_few.append(move)
+ else:
+ too_many.append(move)
+
# Average price computation
if (pick.type == 'in') and (move.product_id.cost_method == 'average'):
product = product_obj.browse(cr, uid, move.product_id.id)
@@ -1247,6 +1250,7 @@ class stock_picking(osv.osv):
{
'product_qty' : move.product_qty - partial_qty[move.id],
'product_uos_qty': move.product_qty - partial_qty[move.id], #TODO: put correct uos_qty
+
})
if new_picking:
@@ -1256,6 +1260,19 @@ class stock_picking(osv.osv):
if prodlot_ids.get(move.id):
defaults.update({'prodlot_id': prodlot_ids[move.id]})
move_obj.write(cr, uid, [move.id], defaults)
+ for move in too_many:
+ product_qty = move_product_qty[move.id]
+ defaults = {
+ 'product_qty' : product_qty,
+ 'product_uos_qty': product_qty, #TODO: put correct uos_qty
+ 'product_uom': product_uoms[move.id]
+ }
+ prodlot_id = prodlot_ids.get(move.id)
+ if prodlot_ids.get(move.id):
+ defaults.update(prodlot_id=prodlot_id)
+ if new_picking:
+ defaults.update(picking_id=new_picking)
+ move_obj.write(cr, uid, [move.id], defaults)
# At first we confirm the new picking (if necessary)
if new_picking:
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index ef592282088..d72f582d6cc 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -129,16 +129,20 @@ class stock_partial_picking(osv.osv_memory):
move_id = move.move_id.id
#Quantiny must be Positive
- if move.quantity <= 0:
+ if move.quantity < 0:
raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
- #Pikcing move product UOM factor must be bigger with respective wizard move product uom factor
- if move_uom.factor < process_uom.factor:
- raise osv.except_osv(_('Warning'), _('You can not process in UOM "%s" which is smaller than UOM "%s" of the current move.') % (process_uom.name, move_uom.name))
+
#Compute the wizard Quantity for respective move.
toprocess = uom_obj._compute_qty(cr, uid, process_uom.id, move.quantity, move_uom.id)
- #Compare wizard Quantity with respective picking move quantity if wizard move quantity bigger then it's giving warning.
- if toprocess > move.move_id.product_qty:
- raise osv.except_osv(_('Warning'), _('You can not process "%s %s" as the qty is more than "%s %s" of respective move.') % (move.quantity, process_uom.name, move.move_id.product_qty, move_uom.name))
+
+ #Check rounding Quantity.ex.
+ #picking: 1kg, uom kg rounding = 0.01 (rounding to 10g),
+ #partial delivery: 253g
+ #=> result= refused, as the qty left on picking would be 0.747kg and only 0.75 is accepted by the uom.
+ if process_uom.factor and process_uom.factor <> 0 and move_uom.factor:
+ without_rounding_qty = (move.quantity / process_uom.factor) * move_uom.factor
+ if toprocess <> without_rounding_qty:
+ raise osv.except_osv(_('Warning'), _('Quantity left on picking would be "%s %s" but "%s %s" is accepted by the uom.') % (without_rounding_qty, process_uom.name, toprocess, process_uom.name))
if not move_id:
seq_obj_name = 'stock.picking.' + picking_type
From c7c5bc19d3c002042bfbb6073b241b5a45dc90b0 Mon Sep 17 00:00:00 2001
From: "Quentin (OpenERP)"
Date: Thu, 29 Dec 2011 14:57:12 +0100
Subject: [PATCH 16/17] [FIX] enhancement of the fix of bug 751222
lp bug: https://launchpad.net/bugs/751222 fixed
bzr revid: qdp-launchpad@openerp.com-20111229135712-q42ro7x0de5q3ggj
---
addons/stock/wizard/stock_partial_picking.py | 65 +++++++++++--------
.../wizard/stock_partial_picking_view.xml | 14 +++-
2 files changed, 51 insertions(+), 28 deletions(-)
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index 8671f27f193..937d50014a2 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -22,8 +22,8 @@
import time
from osv import fields, osv
from tools.misc import DEFAULT_SERVER_DATETIME_FORMAT
-from tools.translate import _
import decimal_precision as dp
+from tools.translate import _
class stock_partial_picking_line(osv.TransientModel):
@@ -52,16 +52,24 @@ class stock_partial_picking_line(osv.TransientModel):
'update_cost': fields.boolean('Need cost update'),
'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", ondelete='CASCADE'),
- 'tracking': fields.function(_tracking, method=True, string='Tracking', type='boolean'),
+ 'tracking': fields.function(_tracking, string='Tracking', type='boolean'),
}
class stock_partial_picking(osv.osv_memory):
_name = "stock.partial.picking"
_description = "Partial Picking Processing Wizard"
+
+ def _hide_tracking(self, cursor, user, ids, name, arg, context=None):
+ res = {}
+ for wizard in self.browse(cursor, user, ids, context=context):
+ res[wizard.id] = any([not(x.tracking) for x in wizard.move_ids])
+ return res
+
_columns = {
'date': fields.datetime('Date', required=True),
'move_ids' : fields.one2many('stock.partial.picking.line', 'wizard_id', 'Product Moves'),
'picking_id': fields.many2one('stock.picking', 'Picking', required=True, ondelete='CASCADE'),
+ 'hide_tracking': fields.function(_hide_tracking, string='Tracking', type='boolean', help='This field is for internal purpose. It is used to decide if the column prodlot has to be shown on the move_ids field or not'),
}
def default_get(self, cr, uid, fields, context=None):
@@ -86,7 +94,7 @@ class stock_partial_picking(osv.osv_memory):
def _product_cost_for_average_update(self, cr, uid, move):
"""Returns product cost and currency ID for the given move, suited for re-computing
the average product cost.
-
+
:return: map of the form::
{'cost': 123.34,
@@ -124,48 +132,51 @@ class stock_partial_picking(osv.osv_memory):
'delivery_date' : partial.date
}
picking_type = partial.picking_id.type
- for move in partial.move_ids:
- move_uom = move.move_id.product_uom
- process_uom = move.product_uom
- move_id = move.move_id.id
+ for wizard_line in partial.move_ids:
+ initial_uom = wizard_line.move_id.product_uom
+ line_uom = wizard_line.product_uom
+ move_id = wizard_line.move_id.id
#Quantiny must be Positive
- if move.quantity < 0:
+ if wizard_line.quantity < 0:
raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
- #Compute the wizard Quantity for respective move.
- toprocess = uom_obj._compute_qty(cr, uid, process_uom.id, move.quantity, move_uom.id)
+ #Compute the quantity for respective wizard_line in the line uom and in the initial uom
+ qty_in_initial_uom = uom_obj._compute_qty(cr, uid, line_uom.id, wizard_line.quantity, initial_uom.id)
+ qty_in_line_uom = uom_obj._compute_qty(cr, uid, line_uom.id, wizard_line.quantity, line_uom.id) #this just do the rounding if necessary
#Check rounding Quantity.ex.
#picking: 1kg, uom kg rounding = 0.01 (rounding to 10g),
#partial delivery: 253g
#=> result= refused, as the qty left on picking would be 0.747kg and only 0.75 is accepted by the uom.
- if process_uom.factor and process_uom.factor <> 0 and move_uom.factor:
- without_rounding_qty = (move.quantity / process_uom.factor) * move_uom.factor
- if toprocess <> without_rounding_qty:
- raise osv.except_osv(_('Warning'), _('Quantity left on picking would be "%s %s" but "%s %s" is accepted by the uom.') % (without_rounding_qty, process_uom.name, toprocess, process_uom.name))
+ if line_uom.factor and line_uom.factor <> 0 and initial_uom.factor:
+ if qty_in_line_uom <> wizard_line.quantity:
+ raise osv.except_osv(_('Warning'), _('The uom rounding does not allow you to ship "%s %s", only roundings of "%s %s" is accepted by the uom.') % (wizard_line.quantity, line_uom.name, line_uom.rounding, line_uom.name))
+ without_rounding_qty = (wizard_line.quantity / line_uom.factor) * initial_uom.factor
+ if qty_in_initial_uom <> without_rounding_qty:
+ raise osv.except_osv(_('Warning'), _('The rounding of the initial uom does not allow you to ship "%s %s", as it would let a quantity of "%s %s" to ship and only roundings of "%s %s" is accepted by the uom.') % (wizard_line.quantity, line_uom.name, wizard_line.move_id.product_qty - without_rounding_qty, initial_uom.name, initial_uom.rounding, initial_uom.name))
if not move_id:
seq_obj_name = 'stock.picking.' + picking_type
move_id = stock_move.create(cr,uid,{'name' : self.pool.get('ir.sequence').get(cr, uid, seq_obj_name),
- 'product_id': move.product_id.id,
- 'product_qty': move.quantity,
- 'product_uom': move.product_uom.id,
- 'prodlot_id': move.prodlot_id.id,
- 'location_id' : move.location_id.id,
- 'location_dest_id' : move.location_dest_id.id,
+ 'product_id': wizard_line.product_id.id,
+ 'product_qty': wizard_line.quantity,
+ 'product_uom': wizard_line.product_uom.id,
+ 'prodlot_id': wizard_line.prodlot_id.id,
+ 'location_id' : wizard_line.location_id.id,
+ 'location_dest_id' : wizard_line.location_dest_id.id,
'picking_id': partial.picking_id.id
},context=context)
stock_move.action_confirm(cr, uid, [move_id], context)
partial_data['move%s' % (move_id)] = {
- 'product_id': move.product_id.id,
- 'product_qty': move.quantity,
- 'product_uom': move.product_uom.id,
- 'prodlot_id': move.prodlot_id.id,
+ 'product_id': wizard_line.product_id.id,
+ 'product_qty': wizard_line.quantity,
+ 'product_uom': wizard_line.product_uom.id,
+ 'prodlot_id': wizard_line.prodlot_id.id,
}
- if (picking_type == 'in') and (move.product_id.cost_method == 'average'):
- partial_data['move%s' % (move.move_id.id)].update(product_price=move.cost,
- product_currency=move.currency.id)
+ if (picking_type == 'in') and (wizard_line.product_id.cost_method == 'average'):
+ partial_data['move%s' % (wizard_line.move_id.id)].update(product_price=wizard_line.cost,
+ product_currency=wizard_line.currency.id)
stock_picking.do_partial(cr, uid, [partial.picking_id.id], partial_data, context=context)
return {'type': 'ir.actions.act_window_close'}
diff --git a/addons/stock/wizard/stock_partial_picking_view.xml b/addons/stock/wizard/stock_partial_picking_view.xml
index 4194d7129c5..5e6ac6ead8b 100644
--- a/addons/stock/wizard/stock_partial_picking_view.xml
+++ b/addons/stock/wizard/stock_partial_picking_view.xml
@@ -15,8 +15,20 @@
form