Skip to content

Commit

Permalink
[FIX] use copy_data rather than doing a write after that the moves ar…
Browse files Browse the repository at this point in the history
…e created

lp bug: https://launchpad.net/bugs/1281558 fixed

bzr revid: guewen.baconnier@camptocamp.com-20140218123211-3l3bvi3at1s91lfi
  • Loading branch information
guewen committed Feb 18, 2014
1 parent b201dc7 commit 1daeaed
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions addons/stock/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,6 @@ def copy(self, cr, uid, id, default=None, context=None):
if 'invoice_state' not in default and picking_obj.invoice_state == 'invoiced':
default['invoice_state'] = '2binvoiced'
res = super(stock_picking, self).copy(cr, uid, id, default, context)
if res:
picking_obj = self.browse(cr, uid, res, context=context)
for move in picking_obj.move_lines:
move_obj.write(cr, uid, [move.id], {'tracking_id': False, 'prodlot_id': False, 'move_history_ids2': [(6, 0, [])], 'move_history_ids': [(6, 0, [])]})
return res

def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
Expand Down Expand Up @@ -1806,12 +1802,17 @@ def write(self, cr, uid, ids, vals, context=None):
_('Quantities, Units of Measure, Products and Locations cannot be modified on stock moves that have already been processed (except by the Administrator).'))
return super(stock_move, self).write(cr, uid, ids, vals, context=context)

def copy(self, cr, uid, id, default=None, context=None):
def copy_data(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
default = default.copy()
default.update({'move_history_ids2': [], 'move_history_ids': []})
return super(stock_move, self).copy(cr, uid, id, default, context=context)
default.update({
'tracking_id': False,
'prodlot_id': False,
'move_history_ids2': [],
'move_history_ids': []
})
return super(stock_move, self).copy_data(cr, uid, id, default, context=context)

def _auto_init(self, cursor, context=None):
res = super(stock_move, self)._auto_init(cursor, context=context)
Expand Down

0 comments on commit 1daeaed

Please sign in to comment.