diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 155f157ae50..b726b05a19f 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -659,7 +659,6 @@ class sale_order(osv.osv): 'invoice_state': (order.order_policy=='picking' and '2binvoiced') or 'none', 'company_id': order.company_id.id, }) - move_id = self.pool.get('stock.move').create(cr, uid, { 'name': line.name[:64], 'picking_id': picking_id, @@ -721,7 +720,6 @@ class sale_order(osv.osv): val['state'] = 'manual' break self.write(cr, uid, [order.id], val) - return True def action_ship_end(self, cr, uid, ids, context=None): @@ -941,10 +939,11 @@ class sale_order_line(osv.osv): for line in self.browse(cr, uid, ids, context=context): if line.invoiced: raise osv.except_osv(_('Invalid action !'), _('You cannot cancel a sale order line that has already been invoiced !')) -# if line.order_id.picking_ids: -# raise osv.except_osv( -# _('Could not cancel sale order line!'), -# _('You must first cancel stock move attached to this sale order line.')) + for pick in line.order_id.picking_ids: + if pick.state != 'cancel': + raise osv.except_osv( + _('Could not cancel sale order line!'), + _('You must first cancel all pickings attached with sale order.')) message = _('Sale order line') + " '" + line.name + "' "+_("is cancelled") self.log(cr, uid, id, message) return self.write(cr, uid, ids, {'state': 'cancel'}) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index a0ccca91ddb..4e62e10f637 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1591,8 +1591,9 @@ class stock_move(osv.osv): 'stock_journal_id': todo[0][1][3], 'company_id': todo[0][1][4] or res_obj._company_default_get(cr, uid, 'stock.company', context), 'address_id': picking.address_id.id, - - 'invoice_state': 'none' + 'invoice_state': 'none', + 'date': picking.date, + 'sale_id': picking.sale_id.id }) for move, (loc, auto, delay, journal, company_id, ptype) in todo: new_id = self.pool.get('stock.move').copy(cr, uid, move.id, { diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 6f744ce784d..2eb218da275 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -894,9 +894,9 @@ - + @@ -1093,7 +1093,6 @@ -