openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #03850
[Merge] lp:~camptocamp/ocb-addons/7.0-duplicate-picking-1281558 into lp:ocb-addons
Guewen Baconnier @ Camptocamp has proposed merging lp:~camptocamp/ocb-addons/7.0-duplicate-picking-1281558 into lp:ocb-addons.
Commit message:
[FIX] use copy_data rather than doing a write after that the moves are created
Requested reviews:
OpenERP Community Backports Team (ocb)
Related bugs:
Bug #1281558 in OpenERP Community Backports (Addons): "When duplicating a picking, the default values of the new moves should be done in stock_move.copy_data"
https://bugs.launchpad.net/ocb-addons/+bug/1281558
For more details, see:
https://code.launchpad.net/~camptocamp/ocb-addons/7.0-duplicate-picking-1281558/+merge/206925
Fixes: lp:1281558
Explanation on the bug report.
With this patch, the tracking_id and prodlot_id are also removed when duplicating stock moves directly, which makes more sense IMO than the current behavior that remove them only when the moves are copied from a picking.
Equivalent proposal on the official addons: https://code.launchpad.net/~camptocamp/openobject-addons/7.0-duplicate-picking-1281558/+merge/206922
--
https://code.launchpad.net/~camptocamp/ocb-addons/7.0-duplicate-picking-1281558/+merge/206925
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~camptocamp/ocb-addons/7.0-duplicate-picking-1281558 into lp:ocb-addons.
=== modified file 'stock/stock.py'
--- stock/stock.py 2014-01-22 13:38:22 +0000
+++ stock/stock.py 2014-02-18 12:53:25 +0000
@@ -727,10 +727,6 @@
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):
@@ -1830,12 +1826,17 @@
_('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)
Follow ups