diff --git a/addons/delivery/delivery_view.xml b/addons/delivery/delivery_view.xml
index 5a8047b4d9b..8b91d3cf198 100644
--- a/addons/delivery/delivery_view.xml
+++ b/addons/delivery/delivery_view.xml
@@ -143,6 +143,30 @@
+
+
+ stock.picking_withweight.in.form.view
+ form
+ stock.picking
+
+
+
+
+
+
+
+
+
+ stock.picking_withweight.internal.form.view
+ form
+ stock.picking
+
+
+
+
+
+
+
delivery.stock.picking_withcarrier.delivery.form.view
@@ -168,6 +192,102 @@
{'contact_display': 'partner'}
+
+
+ delivery.stock.picking_withcarrier.out.move.form.view
+ form
+ stock.picking
+
+
+
+
+
+
+
+
+
+ stock.picking_withweight.in.move.form.view
+ form
+ stock.picking
+
+
+
+
+
+
+
+
+ stock.picking_withweight.internal.move.form.view
+ form
+ stock.picking
+
+
+
+
+
+
+
+
+
+ delivery.stock.picking_withcarrier.delivery.move.form.view
+ form
+ stock.picking
+
+
+
+
+
+
+
+
+
+ stock.move.tree.weight
+ tree
+ stock.move
+
+
+
+
+
+
+
+
+
+ stock.move.form.weight
+ form
+ stock.move
+
+
+
+
+
+
+
+
+
+ stock.move.reception.packing.tree.weight
+ tree
+ stock.move
+
+
+
+
+
+
+
+
+
+ stock.move.reception.packing.form.weight
+ form
+ stock.move
+
+
+
+
+
+
+
+
diff --git a/addons/delivery/stock.py b/addons/delivery/stock.py
index 29a3003ff52..6d8d5a17bd1 100644
--- a/addons/delivery/stock.py
+++ b/addons/delivery/stock.py
@@ -34,15 +34,11 @@ class stock_picking(osv.osv):
def _cal_weight(self, cr, uid, ids, name, args, context=None):
res = {}
- data_picking = self.browse(cr, uid, ids, context)
- for picking in data_picking:
+ uom_obj = self.pool.get('product.uom')
+ for picking in self.browse(cr, uid, ids, context):
total_weight = 0.00
- if picking.move_lines:
- weight = 0.00
- for move in picking.move_lines:
- if move.product_id.weight > 0.00:
- weight = (move.product_uos_qty * move.product_id.weight)
- total_weight += weight
+ for move in picking.move_lines:
+ total_weight += move.weight
res[picking.id] = total_weight
return res
@@ -56,7 +52,7 @@ class stock_picking(osv.osv):
_columns = {
'carrier_id':fields.many2one("delivery.carrier","Carrier"),
'volume': fields.float('Volume'),
- 'weight': fields.function(_cal_weight, method=True, type='float', string='Weight',digits_compute= dp.get_precision('Stock Weight'),
+ 'weight': fields.function(_cal_weight, method=True, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'),
store={
'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['move_lines'], 20),
'stock.move': (_get_picking_line, ['product_id','product_uos_qty'], 20),
@@ -127,5 +123,32 @@ class stock_picking(osv.osv):
stock_picking()
+class stock_move(osv.osv):
+ _inherit = 'stock.move'
+
+ def _cal_move_weight(self, cr, uid, ids, name, args, context=None):
+ res = {}
+ uom_obj = self.pool.get('product.uom')
+ for move in self.browse(cr, uid, ids, context):
+ weight = 0.00
+ if move.product_id.weight > 0.00:
+ converted_qty = move.product_qty
+
+ if move.product_uom.id <> move.product_id.uom_id.id:
+ converted_qty = uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, move.product_id.uom_id.id)
+
+ weight = (converted_qty * move.product_id.weight)
+ res[move.id] = weight
+ return res
+
+ _columns = {
+ 'weight': fields.function(_cal_move_weight, method=True, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'),
+ store={
+ 'stock.move': (lambda self, cr, uid, ids, c={}: ids, ['product_id', 'product_qty', 'product_uom'], 20),
+ }),
+ }
+
+stock_move()
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: