openerp-india team mailing list archive
-
openerp-india team
-
Mailing list archive
-
Message #27300
[Bug 1281558] Re: When duplicating a picking, the default values of the new moves should be done in stock_move.copy_data
** Also affects: ocb-addons
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/1281558
Title:
When duplicating a picking, the default values of the new moves should
be done in stock_move.copy_data
Status in OpenERP Community Backports (Addons):
New
Status in OpenERP Addons (modules):
New
Bug description:
As you can see here:
http://bazaar.launchpad.net/~openerp/openobject-addons/7.0/view/head:/stock/stock.py#L716
`stock_picking.copy()` writes on all the copied stock moves in order
to empty the fields 'tracking_id', 'prodlot_id', 'move_history_ids2',
'move_history_ids'.
It should be replaced by a correct inheritance of the
`stock_move.copy_data` method.
The current implementation has possible side effects, as the moves are
first copied with the fields, and then they are emptied. Even if this
happens in the same transaction, code could not work as we would
expect with the copy method.
A good demonstration is to add such a constraint that ensures that a
pack cannot be shared between pickings:
class stock_move(orm.Model):
_inherit = 'stock.move'
def _check_tracking(self, cr, uid, ids, context=None):
for move in self.browse(cr, uid, ids, context=context):
if not move.tracking_id:
continue
picking = move.picking_id
if any(tm.picking_id != picking for
tm in move.tracking_id.move_ids):
return False
return True
_constraints = [
(_check_tracking,
'The tracking cannot be shared accross '
'different Delivery Orders / Shipments.',
['tracking_id']),
]
Now f I create a picking OUT/00015 with:
- move 1
- move 2
And put the moves in new packs:
- 1: 00000017
- 2: 00000024
And I duplicate the picking OUT/00015, `stock_picking.copy()` creates a picking OUT/00016 with:
- 1copy: 00000017
- 2copy: 00000024
***
And then it empties the `tracking_id` field so we have:
- 1copy:
- 2copy:
But we never reach this final state, because the constraint is raised
where I wrote ***.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ocb-addons/+bug/1281558/+subscriptions
References