When duplicating a picking, the default values of the new moves should be done in stock_move.copy_data

Bug #1281558 reported by Guewen Baconnier @ Camptocamp
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Committed
Low
OpenERP Publisher's Warranty Team
OpenERP Community Backports (Addons)
New
Undecided
Unassigned

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 ***.

Tags: maintenance

Related branches

Changed in openobject-addons:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Changed in openobject-addons:
importance: Undecided → Low
status: New → Fix Committed
Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote :

I I'm not mistaken this is fixed in trunk-wms.

Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Hello,

Thanks for the report and patch. We have merged it into 7.0

revno: 10004 [merge]
revision-id: <email address hidden>

Regards

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.