From 636294e1ef1686c2b9a3039babeb59adb504336c Mon Sep 17 00:00:00 2001
From: Josse Colpaert <jco@odoo.com>
Date: Tue, 16 Sep 2014 12:05:52 +0200
Subject: [PATCH] [IMP] Scheduled time, weights, remove routing on lines

---
 addons/delivery/stock.py      | 8 ++------
 addons/mrp/mrp_view.xml       | 1 -
 addons/stock/stock.py         | 6 +++---
 addons/stock_account/stock.py | 2 +-
 4 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/addons/delivery/stock.py b/addons/delivery/stock.py
index 8e7b5836355a..6f2d2a07ca02 100644
--- a/addons/delivery/stock.py
+++ b/addons/delivery/stock.py
@@ -147,10 +147,6 @@ class stock_move(osv.osv):
             weight = weight_net = 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)
 
                 if move.product_id.weight_net > 0.00:
@@ -165,11 +161,11 @@ class stock_move(osv.osv):
     _columns = {
         'weight': fields.function(_cal_move_weight, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_move_weight',
                   store={
-                 'stock.move': (lambda self, cr, uid, ids, c=None: ids, ['product_id', 'product_qty', 'product_uom'], 20),
+                 'stock.move': (lambda self, cr, uid, ids, c=None: ids, ['product_id', 'product_uom_qty', 'product_uom'], 30),
                  }),
         'weight_net': fields.function(_cal_move_weight, type='float', string='Net weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_move_weight',
                   store={
-                 'stock.move': (lambda self, cr, uid, ids, c=None: ids, ['product_id', 'product_qty', 'product_uom'], 20),
+                 'stock.move': (lambda self, cr, uid, ids, c=None: ids, ['product_id', 'product_uom_qty', 'product_uom'], 30),
                  }),
         'weight_uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True,readonly="1",help="Unit of Measure (Unit of Measure) is the unit of measurement for Weight",),
         }
diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml
index 160bd2e0c3d4..9240c369a0e4 100644
--- a/addons/mrp/mrp_view.xml
+++ b/addons/mrp/mrp_view.xml
@@ -383,7 +383,6 @@
                                     <field name="product_uom" on_change="onchange_uom(product_id, product_uom)" groups="product.group_uom"/>
                                     <field name="date_start"/>
                                     <field name="date_stop"/>
-                                    <field name="routing_id"/>
                                     <field name="attribute_value_ids" widget="many2many_tags"/>
                                 </tree>
                             </field>
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 815caeb3bb93..8b7b8a2ebdd0 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -789,12 +789,12 @@ class stock_picking(osv.osv):
                 * Cancelled: has been cancelled, can't be confirmed anymore"""
         ),
         'priority': fields.function(get_min_max_date, multi="min_max_date", fnct_inv=_set_priority, type='selection', selection=procurement.PROCUREMENT_PRIORITIES, string='Priority',
-                                    store={'stock.move': (_get_pickings, ['priority'], 20)}, states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, select=1, help="Priority for this picking. Setting manually a value here would set it as priority for all the moves", 
+                                    store={'stock.move': (_get_pickings, ['priority', 'picking_id'], 20)}, states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, select=1, help="Priority for this picking. Setting manually a value here would set it as priority for all the moves",
                                     track_visibility='onchange', required=True),
         'min_date': fields.function(get_min_max_date, multi="min_max_date", fnct_inv=_set_min_date,
-                 store={'stock.move': (_get_pickings, ['date_expected'], 20)}, type='datetime', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, string='Scheduled Date', select=1, help="Scheduled time for the first part of the shipment to be processed. Setting manually a value here would set it as expected date for all the stock moves.", track_visibility='onchange'),
+                 store={'stock.move': (_get_pickings, ['date_expected', 'picking_id'], 20)}, type='datetime', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, string='Scheduled Date', select=1, help="Scheduled time for the first part of the shipment to be processed. Setting manually a value here would set it as expected date for all the stock moves.", track_visibility='onchange'),
         'max_date': fields.function(get_min_max_date, multi="min_max_date",
-                 store={'stock.move': (_get_pickings, ['date_expected'], 20)}, type='datetime', string='Max. Expected Date', select=2, help="Scheduled time for the last part of the shipment to be processed"),
+                 store={'stock.move': (_get_pickings, ['date_expected', 'picking_id'], 20)}, type='datetime', string='Max. Expected Date', select=2, help="Scheduled time for the last part of the shipment to be processed"),
         'date': fields.datetime('Creation Date', help="Creation Date, usually the time of the order", select=True, states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, track_visibility='onchange'),
         'date_done': fields.datetime('Date of Transfer', help="Date of Completion", states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, copy=False),
         'move_lines': fields.one2many('stock.move', 'picking_id', 'Internal Moves', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, copy=True),
diff --git a/addons/stock_account/stock.py b/addons/stock_account/stock.py
index 555ced13758f..aecf8d32694c 100644
--- a/addons/stock_account/stock.py
+++ b/addons/stock_account/stock.py
@@ -191,7 +191,7 @@ class stock_picking(osv.osv):
         pick = self.browse(cr, uid, picking_id, context=context)
         moves = [x.id for x in pick.move_lines]
         move_obj= self.pool.get("stock.move")
-        move_obj.write(cr, uid, moves, {'invoice_state': pick.invoice_state})
+        move_obj.write(cr, uid, moves, {'invoice_state': pick.invoice_state}, context=context)
 
     _columns = {
         'invoice_state': fields.function(__get_invoice_state, type='selection', selection=[
-- 
GitLab