Merge lp:~yann-papouin/ocb-addons/6.1-bug-947838-sale-recreate-packing-duplicates into lp:ocb-addons/6.1

Proposed by Yann Papouin
Status: Needs review
Proposed branch: lp:~yann-papouin/ocb-addons/6.1-bug-947838-sale-recreate-packing-duplicates
Merge into: lp:ocb-addons/6.1
Diff against target: 32 lines (+14/-1)
1 file modified
sale/ (+14/-1)
To merge this branch: bzr merge lp:~yann-papouin/ocb-addons/6.1-bug-947838-sale-recreate-packing-duplicates
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Review via email:

Description of the change

Change _create_pickings_and_procurements to avoid recreating procurement when they are still valid

To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

#11 pass context (even though this function screws up then, but this may change)
#15 same here

Why don't you simply call this functions via the browse records you have in hand anyway?

review: Needs Fixing
Revision history for this message
Yann Papouin (yann-papouin) wrote :

Yes you're right, I always miss this context value

Revision history for this message
Yann Papouin (yann-papouin) wrote :

Do I need to pass context even when directly calling function via the browse records or does it automatically reuse the context initially passed in browse?

Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

No, on browse records there's no need to pass the context. It's even harmful, does the code you submitted now run? I'd expect and exception about passing a duplicate keyword argument names 'context'

review: Needs Fixing (code review)
6817. By Yann Papouin

Do not pass context in proxy functions

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

Unmerged revisions

6817. By Yann Papouin

Do not pass context in proxy functions

6816. By Yann Papouin

Readding code checking 'confirmed' lines to avoid duplicates

6815. By Yann Papouin

Pass context and use existing browse records

6814. By Yann Papouin

Removing useless code checking 'confirmed' lines

6813. By Yann Papouin

FIX: "Recreate Packing" button create duplicates

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sale/'
2--- sale/ 2013-12-18 15:22:03 +0000
3+++ sale/ 2014-01-22 15:39:44 +0000
4@@ -825,6 +825,19 @@
5 date_planned = self._get_date_planned(cr, uid, order, line, order.date_confirm, context=context)
7 if line.product_id:
8+ if line.state == 'confirmed':
9+ # Ignore existing procurement and linked move if not canceled
10+ if line.procurement_id and line.procurement_id.state != 'cancel'\
11+ and line.procurement_id.move_id and line.procurement_id.move_id.state != 'cancel':
12+ continue
13+ elif line.state == 'exception':
14+ # Reset line state to confirmed state
15+ line.button_confirm()
16+ # Cancel existing move if the canceled procurement exists
17+ if line.procurement_id and line.procurement_id.state == 'cancel'\
18+ and line.procurement_id.move_id and line.procurement_id.move_id.state not in ('done', 'cancel'):
19+ line.procurement_id.move_id.action_cancel()
21 if line.product_id.product_tmpl_id.type in ('product', 'consu'):
22 if not picking_id:
23 picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context))
24@@ -1137,7 +1150,7 @@
25 def copy_data(self, cr, uid, id, default=None, context=None):
26 if not default:
27 default = {}
28- default.update({'state': 'draft', 'move_ids': [], 'invoiced': False, 'invoice_lines': []})
29+ default.update({'state': 'draft', 'move_ids': [], 'procurement_id': False, 'invoiced': False, 'invoice_lines': []})
30 return super(sale_order_line, self).copy_data(cr, uid, id, default, context=context)
32 def product_packaging_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False,


People subscribed via source and target branches