Merge lp:~akretion-team/openobject-addons/sale-modular-picking-better-context into lp:openobject-addons

Proposed by Raphaël Valyi - http://www.akretion.com
Status: Merged
Merged at revision: 6096
Proposed branch: lp:~akretion-team/openobject-addons/sale-modular-picking-better-context
Merge into: lp:openobject-addons
Diff against target: 104 lines (+12/-12)
2 files modified
purchase/purchase.py (+6/-6)
sale/sale.py (+6/-6)
To merge this branch: bzr merge lp:~akretion-team/openobject-addons/sale-modular-picking-better-context
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) offline ;-) Approve
Raphaël Valyi - http://www.akretion.com (community) Needs Resubmitting
Review via email: mp+82944@code.launchpad.net

Description of the change

better signature for methods introduced during recent refactoring to have more modular picking creation in sale and purchase modules.

To post a comment you must log in.
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

we will however double check those two commit internally at Akretion before requesting the merge

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

Hello,

According to the discussion we had about methods called by workflow ( https://code.launchpad.net/~openerp-community/openobject-server/context-in-workflows/+merge/85518 ), I just normalized the methods signatures of all methods touched and created by the sale/purchase picking modularization so they now have a standard context argument as their last argument.

We may probably not have perfect signatures everywhere in 6.1, but I think it's normal that at least new methods/refactored methods have the correct signature, at least that's a step in the right direction, so could you please merge it now?

review: Needs Resubmitting
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Looks good, but while merging I will also change the context passing to use the usual kwargs (making future API evolution easier), and also correct existing modules who already override the current API with *args (delivery, project_mrp, sale_journal). In most cases this is a good opportunity to replace the old override of action_ship_create with a simpler/cleaner _prepare* override.

Will complete the merge asap today.

Thanks for the clean and simple contribution!

PS: online diff is not up to date to due an ongoing LP bug that seems to affect addons branches randomly: bug 904683 / bug 808930 - hope it will be solved soon

review: Approve (offline ;-))
6027. By Raphaël Valyi - http://www.akretion.com

[MERGE] merged with trunk: added context arg in sale.order#get_date_planned (from 20/12 merge)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'purchase/purchase.py'
2--- purchase/purchase.py 2011-11-17 15:40:04 +0000
3+++ purchase/purchase.py 2011-11-21 22:44:24 +0000
4@@ -453,7 +453,7 @@
5 self.log(cr, uid, id, message)
6 return True
7
8- def _prepare_order_picking(self, cr, uid, order, *args):
9+ def _prepare_order_picking(self, cr, uid, order, context=None):
10 return {
11 'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.in'),
12 'origin': order.name + ((order.origin and (':' + order.origin)) or ''),
13@@ -466,7 +466,7 @@
14 'move_lines' : [],
15 }
16
17- def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, *args):
18+ def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, context=None):
19 return {
20 'name': order.name + ': ' + (order_line.name or ''),
21 'product_id': order_line.product_id.id,
22@@ -487,7 +487,7 @@
23 'price_unit': order_line.price_unit
24 }
25
26- def _create_pickings(self, cr, uid, order, order_lines, picking_id=False, *args):
27+ def _create_pickings(self, cr, uid, order, order_lines, picking_id=False, context=None):
28 """Creates pickings and appropriate stock moves for given order lines, then
29 confirms the moves, makes them available, and confirms the picking.
30
31@@ -507,7 +507,7 @@
32 :return: list of IDs of pickings used/created for the given order lines (usually just one)
33 """
34 if not picking_id:
35- picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, *args))
36+ picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, context))
37 todo_moves = []
38 stock_move = self.pool.get('stock.move')
39 wf_service = netsvc.LocalService("workflow")
40@@ -515,7 +515,7 @@
41 if not order_line.product_id:
42 continue
43 if order_line.product_id.type in ('product', 'consu'):
44- move = stock_move.create(cr, uid, self._prepare_order_line_move(cr, uid, order, order_line, picking_id, *args))
45+ move = stock_move.create(cr, uid, self._prepare_order_line_move(cr, uid, order, order_line, picking_id, context))
46 if order_line.move_dest_id:
47 order_line.move_dest_id.write({'location_id': order.location_id.id})
48 todo_moves.append(move)
49@@ -527,7 +527,7 @@
50 def action_picking_create(self,cr, uid, ids, *args):
51 picking_ids = []
52 for order in self.browse(cr, uid, ids):
53- picking_ids.extend(self._create_pickings(cr, uid, order, order.order_line, None, *args))
54+ picking_ids.extend(self._create_pickings(cr, uid, order, order.order_line, None, {}))#TODO propagate context the day we have it
55
56 # Must return one unique picking ID: the one to connect in the subflow of the purchase order.
57 # In case of multiple (split) pickings, we should return the ID of the critical one, i.e. the
58
59=== modified file 'sale/sale.py'
60--- sale/sale.py 2011-11-18 13:14:04 +0000
61+++ sale/sale.py 2011-11-21 22:44:24 +0000
62@@ -676,7 +676,7 @@
63 return False
64 return canceled
65
66- def _prepare_order_line_procurement(self, cr, uid, order, line, move_id, date_planned, *args):
67+ def _prepare_order_line_procurement(self, cr, uid, order, line, move_id, date_planned, context=None):
68 return {
69 'name': line.name,
70 'origin': order.name,
71@@ -695,7 +695,7 @@
72 'company_id': order.company_id.id,
73 }
74
75- def _prepare_order_line_move(self, cr, uid, order, line, picking_id, date_planned, *args):
76+ def _prepare_order_line_move(self, cr, uid, order, line, picking_id, date_planned, context=None):
77 location_id = order.shop_id.warehouse_id.lot_stock_id.id
78 output_id = order.shop_id.warehouse_id.lot_output_id.id
79 return {
80@@ -722,7 +722,7 @@
81 'price_unit': line.product_id.standard_price or 0.0
82 }
83
84- def _prepare_order_picking(self, cr, uid, order, *args):
85+ def _prepare_order_picking(self, cr, uid, order, context=None):
86 pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out')
87 return {
88 'name': pick_name,
89@@ -772,13 +772,13 @@
90 if line.product_id:
91 if line.product_id.product_tmpl_id.type in ('product', 'consu'):
92 if not picking_id:
93- picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, *args))
94- move_id = move_obj.create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, *args))
95+ picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, {})) #TODO pass context if present
96+ move_id = move_obj.create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, {}))
97 else:
98 # a service has no stock move
99 move_id = False
100
101- proc_id = procurement_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, *args))
102+ proc_id = procurement_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, {}))
103 proc_ids.append(proc_id)
104 line.write({'procurement_id': proc_id})
105

Subscribers

People subscribed via source and target branches

to all changes: