Merge lp:~camptocamp/openobject-addons/6.1-fix-1025703_delivery_chained_pickings-AFE into lp:openobject-addons/6.1

Proposed by Alexandre Fayolle - camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/openobject-addons/6.1-fix-1025703_delivery_chained_pickings-AFE
Merge into: lp:openobject-addons/6.1
Diff against target: 84 lines (+50/-1)
3 files modified
delivery/__openerp__.py (+1/-0)
delivery/stock.py (+12/-1)
delivery/test/delivery_chained_pickings.yml (+37/-0)
To merge this branch: bzr merge lp:~camptocamp/openobject-addons/6.1-fix-1025703_delivery_chained_pickings-AFE
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp (community) Approve
OpenERP R&D Addons Team 2 Pending
OpenERP Core Team Pending
Review via email: mp+171252@code.launchpad.net

Description of the change

propagate delivery-specific fields on chained moves

add a test for this.

To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

tests are green on runbot

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

l33-37 Just about coding style, a dict update of values wouldn't be cleaner?

Otherwise LGTM

review: Approve

Unmerged revisions

7232. By Alexandre Fayolle - camptocamp

[FIX] delivery: propagate additional fields in chained pickings

7231. By Alexandre Fayolle - camptocamp

[TEST] add test illustrating the issue

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'delivery/__openerp__.py'
2--- delivery/__openerp__.py 2012-01-31 13:36:57 +0000
3+++ delivery/__openerp__.py 2013-06-25 09:37:33 +0000
4@@ -46,6 +46,7 @@
5 'demo_xml': ['delivery_demo.xml'],
6 'test': [
7 'test/delivery_cost.yml',
8+ 'test/delivery_chained_pickings.yml',
9 ],
10 'installable': True,
11 'auto_install': False,
12
13=== modified file 'delivery/stock.py'
14--- delivery/stock.py 2011-12-21 18:11:49 +0000
15+++ delivery/stock.py 2013-06-25 09:37:33 +0000
16@@ -75,7 +75,7 @@
17 :param browse_record picking: the stock picking being invoiced
18 :param browse_record invoice: the stock picking's invoice
19 :return: dict containing the values to create the invoice line,
20- or None to create nothing
21+ or None to create nothing
22 """
23 carrier_obj = self.pool.get('delivery.carrier')
24 grid_obj = self.pool.get('delivery.grid')
25@@ -160,6 +160,17 @@
26 }
27 return res
28
29+ def _prepare_chained_picking(self, cr, uid, picking_name, picking, picking_type, moves_todo, context=None):
30+ values = super(stock_move, self)._prepare_chained_picking(cr, uid, picking_name, picking, picking_type, moves_todo, context=context)
31+ if picking.carrier_id:
32+ values['carrier_id'] = picking.carrier_id.id
33+ values['volume'] = picking.volume
34+ values['weight'] = picking.weight
35+ values['weight_net'] = picking.weight_net
36+ values['carrier_tracking_ref'] = picking.carrier_tracking_ref
37+ values['number_of_packages'] = picking.number_of_packages
38+ return values
39+
40 _columns = {
41 'weight': fields.function(_cal_move_weight, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_move_weight',
42 store={
43
44=== added file 'delivery/test/delivery_chained_pickings.yml'
45--- delivery/test/delivery_chained_pickings.yml 1970-01-01 00:00:00 +0000
46+++ delivery/test/delivery_chained_pickings.yml 2013-06-25 09:37:33 +0000
47@@ -0,0 +1,37 @@
48+-
49+ I create a picking to stock.location_convenience_shop, which is chained with stock.location_refrigerator
50+-
51+ !record {model: stock.picking, id: shipment_with_delivery}:
52+ type: internal
53+ carrier_id: delivery.delivery_carrier
54+ volume: 42
55+ carrier_tracking_ref: FDX123
56+ number_of_packages: 7
57+-
58+ I add a move in the picking
59+-
60+ !record {model: stock.move, id: icecream_move}:
61+ picking_id: shipment_with_delivery
62+ product_id: stock.product_icecream
63+ product_uom: product.product_uom_kgm
64+ product_qty: 130.0
65+ location_id: stock.stock_location_suppliers
66+ location_dest_id: stock.location_convenience_shop
67+-
68+ I confirm the picking
69+-
70+ !workflow {model: stock.picking, action: button_confirm, ref: shipment_with_delivery}
71+-
72+ I check that the delivery fields have been propagated to the chained picking
73+-
74+ !python {model: stock.move}: |
75+ original_move = self.browse(cr, uid, ref('icecream_move'), context=context)
76+ original_picking = original_move.picking_id
77+ chained_move = original_move.move_dest_id
78+ chained_picking = chained_move.picking_id
79+ assert chained_picking.carrier_tracking_ref == original_picking.carrier_tracking_ref, 'no propagation of carrier_tracking_ref'
80+ assert chained_picking.carrier_id == original_picking.carrier_id, 'no propagation of carrier_id'
81+ assert chained_picking.volume == original_picking.volume, 'no propagation of volume'
82+ assert chained_picking.weight == original_picking.weight, 'no propagation of weight'
83+ assert chained_picking.weight_net == original_picking.weight_net, 'no propagation of weight'
84+