diff options
| author | Jay (OpenERP) <jvo@tinyerp.com> | 2010-08-31 15:50:45 +0530 |
|---|---|---|
| committer | Jay (OpenERP) <jvo@tinyerp.com> | 2010-08-31 15:50:45 +0530 |
| commit | d7849d322d05e992cf0ca3fe2d5ca6a07ea3b940 (patch) | |
| tree | 4b02a9ecac0d54ca7a4a84377743296bdfbd0ba1 /addons | |
| parent | 906948cb8d998f9c17fe24e91aeff2ec27e7659d (diff) | |
[FIX] MRP : Cancellation of procurement allowed if it has no moves attached
lp bug: https://launchpad.net/bugs/626695 fixed
bzr revid: jvo@tinyerp.com-20100831102045-p9r88j380x515k25
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/procurement/procurement.py | 8 | ||||
| -rw-r--r-- | addons/stock/stock.py | 7 |
2 files changed, 8 insertions, 7 deletions
diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index dc072cc520a..298d9b05449 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -179,7 +179,7 @@ class procurement_order(osv.osv): @param proc: Current procurement. @return: Quantity or False. """ - if proc.product_id.type == 'product': + if proc.product_id.type == 'product' and proc.move_id: if proc.move_id.product_uos: return proc.move_id.product_uos_qty return False @@ -189,7 +189,7 @@ class procurement_order(osv.osv): @param proc: Current procurement. @return: UoS or False. """ - if proc.product_id.type == 'product': + if proc.product_id.type == 'product' and proc.move_id: if proc.move_id.product_uos: return proc.move_id.product_uos.id return False @@ -405,7 +405,7 @@ class procurement_order(osv.osv): todo2 = [] move_obj = self.pool.get('stock.move') for proc in self.browse(cr, uid, ids): - if proc.close_move: + if proc.close_move and proc.move_id: if proc.move_id.state not in ('done', 'cancel'): todo2.append(proc.move_id.id) else: @@ -430,7 +430,7 @@ class procurement_order(osv.osv): """ ok = False for procurement in self.browse(cr, uid, ids): - if procurement.move_id.state == 'assigned' or procurement.move_id.state == 'done': + if procurement.move_id and procurement.move_id.state == 'assigned' or procurement.move_id.state == 'done': self.action_done(cr, uid, [procurement.id]) ok = True return ok diff --git a/addons/stock/stock.py b/addons/stock/stock.py index aac1ac869ed..e19e36b641f 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1003,7 +1003,7 @@ class stock_picking(osv.osv): def unlink(self, cr, uid, ids, context=None): move_obj = self.pool.get('stock.move') - if not context: + if context is None: context = {} for pick in self.browse(cr, uid, ids, context=context): if pick.state in ['done','cancel']: @@ -1886,12 +1886,13 @@ class stock_move(osv.osv): def unlink(self, cr, uid, ids, context=None): if context is None: context = {} + ctx = context.copy() for move in self.browse(cr, uid, ids, context=context): - if move.state != 'draft': + if move.state != 'draft' and not ctx.get('call_unlink',False): raise osv.except_osv(_('UserError'), _('You can only delete draft moves.')) return super(stock_move, self).unlink( - cr, uid, ids, context=context) + cr, uid, ids, context=ctx) def _create_lot(self, cr, uid, ids, product_id, prefix=False): """ Creates production lot |
