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

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

Description of the change

Propagate delivery specific fields on chained pickings

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

Unmerged revisions

9268. By Alexandre Fayolle - camptocamp on 2013-06-25

[FIX] delivery: propagate additional fields in chained pickings

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-11-29 22:26:45 +0000
3+++ delivery/__openerp__.py 2013-06-25 10:08:55 +0000
4@@ -41,7 +41,9 @@
5 'delivery_data.xml'
6 ],
7 'demo': ['delivery_demo.xml'],
8- 'test': ['test/delivery_cost.yml'],
9+ 'test': ['test/delivery_cost.yml',
10+ 'test/delivery_chained_pickings.yml',
11+ ],
12 'installable': True,
13 'auto_install': False,
14 'images': ['images/1_delivery_method.jpeg','images/2_delivery_pricelist.jpeg'],
15
16=== modified file 'delivery/stock.py'
17--- delivery/stock.py 2012-12-18 08:59:14 +0000
18+++ delivery/stock.py 2013-06-25 10:08:55 +0000
19@@ -167,6 +167,17 @@
20 }
21 return res
22
23+ def _prepare_chained_picking(self, cr, uid, picking_name, picking, picking_type, moves_todo, context=None):
24+ values = super(stock_move, self)._prepare_chained_picking(cr, uid, picking_name, picking, picking_type, moves_todo, context=context)
25+ if picking.carrier_id:
26+ values['carrier_id'] = picking.carrier_id.id
27+ values['volume'] = picking.volume
28+ values['weight'] = picking.weight
29+ values['weight_net'] = picking.weight_net
30+ values['carrier_tracking_ref'] = picking.carrier_tracking_ref
31+ values['number_of_packages'] = picking.number_of_packages
32+ return values
33+
34 _columns = {
35 'weight': fields.function(_cal_move_weight, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_move_weight',
36 store={
37
38=== added file 'delivery/test/delivery_chained_pickings.yml'
39--- delivery/test/delivery_chained_pickings.yml 1970-01-01 00:00:00 +0000
40+++ delivery/test/delivery_chained_pickings.yml 2013-06-25 10:08:55 +0000
41@@ -0,0 +1,50 @@
42+-
43+ I setup product and locations
44+-
45+ !record {model: stock.location, id: dest_chained_location}:
46+ name: DestChainedLocation
47+ usage: internal
48+-
49+ !record {model: stock.location, id: source_chained_location}:
50+ name: Source Chained Location
51+ chained_auto_packing: auto
52+ chained_location_type: fixed
53+ usage: internal
54+ chained_location_id: dest_chained_location
55+-
56+ I create a picking to location_convenience_shop, which is chained with location_refrigerator
57+-
58+ !record {model: stock.picking, id: shipment_with_delivery}:
59+ type: internal
60+ carrier_id: delivery.delivery_carrier
61+ volume: 42
62+ carrier_tracking_ref: FDX123
63+ number_of_packages: 7
64+-
65+ I add a move in the picking
66+-
67+ !record {model: stock.move, id: icecream_move}:
68+ picking_id: shipment_with_delivery
69+ product_id: product_product_delivery
70+ product_uom: product.product_uom_kgm
71+ product_qty: 130.0
72+ location_id: stock.stock_location_suppliers
73+ location_dest_id: source_chained_location
74+-
75+ I confirm the picking
76+-
77+ !workflow {model: stock.picking, action: button_confirm, ref: shipment_with_delivery}
78+-
79+ I check that the delivery fields have been propagated to the chained picking
80+-
81+ !python {model: stock.move}: |
82+ original_move = self.browse(cr, uid, ref('icecream_move'), context=context)
83+ original_picking = original_move.picking_id
84+ chained_move = original_move.move_dest_id
85+ chained_picking = chained_move.picking_id
86+ assert chained_picking.carrier_tracking_ref == original_picking.carrier_tracking_ref, 'no propagation of carrier_tracking_ref'
87+ assert chained_picking.carrier_id == original_picking.carrier_id, 'no propagation of carrier_id'
88+ assert chained_picking.volume == original_picking.volume, 'no propagation of volume'
89+ assert chained_picking.weight == original_picking.weight, 'no propagation of weight'
90+ assert chained_picking.weight_net == original_picking.weight_net, 'no propagation of weight'
91+