Merge lp:~camptocamp/ocb-addons/ocb-7.0-fix_1264950-afe into lp:ocb-addons

Proposed by Alexandre Fayolle - camptocamp
Status: Merged
Merged at revision: 9865
Proposed branch: lp:~camptocamp/ocb-addons/ocb-7.0-fix_1264950-afe
Merge into: lp:ocb-addons
Diff against target: 31 lines (+12/-2)
1 file modified
stock/stock.py (+12/-2)
To merge this branch: bzr merge lp:~camptocamp/ocb-addons/ocb-7.0-fix_1264950-afe
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Raphaël Valyi - http://www.akretion.com Approve
Review via email: mp+201028@code.launchpad.net

Description of the change

[FIX] avoid writing picking state if it has not changed (fix lp:1264950)

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

this is running in production for my customer

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

LGTM no tests

review: Approve
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/stock.py'
2--- stock/stock.py 2013-11-28 14:50:59 +0000
3+++ stock/stock.py 2014-01-09 15:25:28 +0000
4@@ -754,7 +754,12 @@
5 @return: True
6 """
7 pickings = self.browse(cr, uid, ids, context=context)
8- self.write(cr, uid, ids, {'state': 'confirmed'})
9+ to_update = []
10+ for pick in pickings:
11+ if pick.state != 'confirmed':
12+ to_update.append(pick.id)
13+ if to_update:
14+ self.write(cr, uid, to_update, {'state': 'confirmed'})
15 todo = []
16 for picking in pickings:
17 for r in picking.move_lines:
18@@ -833,7 +838,12 @@
19 """ Changes picking state to assigned.
20 @return: True
21 """
22- self.write(cr, uid, ids, {'state': 'assigned'})
23+ to_update = []
24+ for pick in self.browse(cr, uid, ids, context=context):
25+ if pick.state != 'assigned':
26+ to_update.append(pick.id)
27+ if to_update:
28+ self.write(cr, uid, to_update, {'state': 'assigned'})
29 return True
30
31 def test_finished(self, cr, uid, ids):