From 21aaec282d5cfafaf8c0b4ba52fbe1750470aa5c Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Fri, 12 Sep 2014 16:31:45 +0200 Subject: [PATCH 1/7] [FIX] Theoretical quantity for created inventory adjustment should take into account location in context of stock --- addons/stock/wizard/stock_change_product_qty.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock/wizard/stock_change_product_qty.py b/addons/stock/wizard/stock_change_product_qty.py index 1e7b19fef71..961eb2e0aef 100644 --- a/addons/stock/wizard/stock_change_product_qty.py +++ b/addons/stock/wizard/stock_change_product_qty.py @@ -98,7 +98,8 @@ class stock_change_product_qty(osv.osv_memory): 'product_id': data.product_id.id, 'location_id': data.location_id.id, 'lot_id': data.lot_id.id}, context=context) - th_qty = data.product_id.qty_available + product = data.product_id.with_context(location=data.location_id.id) + th_qty = product.qty_available line_data = { 'inventory_id': inventory_id, 'product_qty': data.new_quantity, From 636294e1ef1686c2b9a3039babeb59adb504336c Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 16 Sep 2014 12:05:52 +0200 Subject: [PATCH 2/7] [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 8e7b5836355..6f2d2a07ca0 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 160bd2e0c3d..9240c369a0e 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -383,7 +383,6 @@ - diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 815caeb3bb9..8b7b8a2ebdd 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 555ced13758..aecf8d32694 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=[ From 0f9a9fbae3f0303456e0325832db4e31f4f2a24e Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Mon, 15 Sep 2014 19:24:08 +0200 Subject: [PATCH 3/7] [IMP] Purchase order wkf optim --- addons/purchase/purchase.py | 8 ++------ addons/purchase/purchase_view.xml | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index be2803261e7..4688b752578 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -679,12 +679,11 @@ class purchase_order(osv.osv): def action_cancel(self, cr, uid, ids, context=None): for purchase in self.browse(cr, uid, ids, context=context): for pick in purchase.picking_ids: - if pick.state not in ('draft', 'cancel'): + if pick.state not in ('draft', 'cancel', 'confirmed'): raise osv.except_osv( _('Unable to cancel the purchase order %s.') % (purchase.name), _('First cancel all receipts related to this purchase order.')) - self.pool.get('stock.picking') \ - .signal_workflow(cr, uid, map(attrgetter('id'), purchase.picking_ids), 'button_cancel') + self.pool.get('stock.picking').action_cancel(cr, uid, map(attrgetter('id'), purchase.picking_ids), context=context) for inv in purchase.invoice_ids: if inv and inv.state not in ('cancel', 'draft'): raise osv.except_osv( @@ -692,9 +691,6 @@ class purchase_order(osv.osv): _('You must first cancel all invoices related to this purchase order.')) self.pool.get('account.invoice') \ .signal_workflow(cr, uid, map(attrgetter('id'), purchase.invoice_ids), 'invoice_cancel') - self.pool['purchase.order.line'].write(cr, uid, [l.id for l in purchase.order_line], - {'state': 'cancel'}) - self.write(cr, uid, ids, {'state': 'cancel'}) self.set_order_line_status(cr, uid, ids, 'cancel', context=context) self.signal_workflow(cr, uid, ids, 'purchase_cancel') return True diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 239bc990ff2..1ccd8af6011 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -202,8 +202,7 @@