Merge lp:~openerp-dev/openobject-addons/trunk-workflow-context-odo into lp:openobject-addons
- trunk-workflow-context-odo
- Merge into trunk
Status: | Work in progress |
---|---|
Proposed branch: | lp:~openerp-dev/openobject-addons/trunk-workflow-context-odo |
Merge into: | lp:openobject-addons |
Diff against target: |
1045 lines (+147/-143) (has conflicts) 11 files modified
account/account_invoice.py (+18/-19) hr_expense/hr_expense.py (+5/-5) hr_payroll/hr_payroll.py (+2/-2) mrp/mrp.py (+18/-18) mrp/procurement.py (+2/-2) mrp_operations/mrp_operations.py (+17/-17) procurement/procurement.py (+10/-10) purchase/purchase.py (+21/-20) sale/sale.py (+29/-25) stock/stock.py (+21/-21) stock_location/procurement_pull.py (+4/-4) Text conflict in sale/sale.py |
To merge this branch: | bzr merge lp:~openerp-dev/openobject-addons/trunk-workflow-context-odo |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email: mp+85530@code.launchpad.net |
Commit message
Description of the change
Work in progress for passing context in business methods who are calling workflows directly or being called by workflows, and as much as possible, downstream.
Basically this boils downs to adding and passing context for all methods on workflow-enabled models, which is a lot of work and dangerous enough... Perhaps a first step instead would be to only care about supporting a context parameter in methods that are directly called by workflows. These are easy to identify, and there is a lot less work to do, _but_ the result will be quite disappointing, as anything beyond the first stack frame downstream of the workflow will likely never see the context anyway.
This branch is not complete yet, and this work is probably too sensitive at this point of releasing 6.1.
See also the prerequisite server branch lp:~openerp-dev/openobject-server/trunk-workflow-context-odo
Unmerged revisions
- 5838. By Olivier Dony (Odoo)
-
[IMP] workflows: accept and propagate context during workflow execution (wip)
Preview Diff
1 | === modified file 'account/account_invoice.py' |
2 | --- account/account_invoice.py 2011-12-06 10:13:54 +0000 |
3 | +++ account/account_invoice.py 2011-12-13 18:03:48 +0000 |
4 | @@ -466,7 +466,7 @@ |
5 | } |
6 | return result |
7 | |
8 | - def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice): |
9 | + def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice, context=None): |
10 | if not payment_term_id: |
11 | return {} |
12 | res = {} |
13 | @@ -578,12 +578,12 @@ |
14 | return {'value': val, 'domain': dom} |
15 | |
16 | # go from canceled state to draft state |
17 | - def action_cancel_draft(self, cr, uid, ids, *args): |
18 | + def action_cancel_draft(self, cr, uid, ids, context=None): |
19 | self.write(cr, uid, ids, {'state':'draft'}) |
20 | wf_service = netsvc.LocalService("workflow") |
21 | for inv_id in ids: |
22 | - wf_service.trg_delete(uid, 'account.invoice', inv_id, cr) |
23 | - wf_service.trg_create(uid, 'account.invoice', inv_id, cr) |
24 | + wf_service.trg_delete(uid, 'account.invoice', inv_id, cr, context=context) |
25 | + wf_service.trg_create(uid, 'account.invoice', inv_id, cr, context=context) |
26 | return True |
27 | |
28 | # Workflow stuff |
29 | @@ -591,12 +591,12 @@ |
30 | |
31 | # return the ids of the move lines which has the same account than the invoice |
32 | # whose id is in ids |
33 | - def move_line_id_payment_get(self, cr, uid, ids, *args): |
34 | + def move_line_id_payment_get(self, cr, uid, ids, context=None): |
35 | if not ids: return [] |
36 | - result = self.move_line_id_payment_gets(cr, uid, ids, *args) |
37 | + result = self.move_line_id_payment_gets(cr, uid, ids, context=context) |
38 | return result.get(ids[0], []) |
39 | |
40 | - def move_line_id_payment_gets(self, cr, uid, ids, *args): |
41 | + def move_line_id_payment_gets(self, cr, uid, ids, context=None): |
42 | res = {} |
43 | if not ids: return res |
44 | cr.execute('SELECT i.id, l.id '\ |
45 | @@ -630,8 +630,8 @@ |
46 | }) |
47 | return super(account_invoice, self).copy(cr, uid, id, default, context) |
48 | |
49 | - def test_paid(self, cr, uid, ids, *args): |
50 | - res = self.move_line_id_payment_get(cr, uid, ids) |
51 | + def test_paid(self, cr, uid, ids, context=None): |
52 | + res = self.move_line_id_payment_get(cr, uid, ids, context=context) |
53 | if not res: |
54 | return False |
55 | ok = True |
56 | @@ -701,14 +701,14 @@ |
57 | })] |
58 | return iml |
59 | |
60 | - def action_date_assign(self, cr, uid, ids, *args): |
61 | + def action_date_assign(self, cr, uid, ids, context=None): |
62 | for inv in self.browse(cr, uid, ids): |
63 | - res = self.onchange_payment_term_date_invoice(cr, uid, inv.id, inv.payment_term.id, inv.date_invoice) |
64 | + res = self.onchange_payment_term_date_invoice(cr, uid, inv.id, inv.payment_term.id, inv.date_invoice, context=context) |
65 | if res and res['value']: |
66 | self.write(cr, uid, [inv.id], res['value']) |
67 | return True |
68 | |
69 | - def finalize_invoice_move_lines(self, cr, uid, invoice_browse, move_lines): |
70 | + def finalize_invoice_move_lines(self, cr, uid, invoice_browse, move_lines, context=None): |
71 | """finalize_invoice_move_lines(cr, uid, invoice, move_lines) -> move_lines |
72 | Hook method to be overridden in additional modules to verify and possibly alter the |
73 | move lines to be created by an invoice, for special cases. |
74 | @@ -794,12 +794,13 @@ |
75 | line.append((0,0,val)) |
76 | return line |
77 | |
78 | - def action_move_create(self, cr, uid, ids, *args): |
79 | + def action_move_create(self, cr, uid, ids, context=None): |
80 | """Creates invoice related analytics and financial move lines""" |
81 | ait_obj = self.pool.get('account.invoice.tax') |
82 | cur_obj = self.pool.get('res.currency') |
83 | period_obj = self.pool.get('account.period') |
84 | - context = {} |
85 | + if context is None: |
86 | + context = {} |
87 | for inv in self.browse(cr, uid, ids): |
88 | if not inv.journal_id.sequence_id: |
89 | raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal')) |
90 | @@ -815,8 +816,7 @@ |
91 | # one move line per invoice line |
92 | iml = self._get_analytic_lines(cr, uid, inv.id) |
93 | # check if taxes are all computed |
94 | - ctx = context.copy() |
95 | - ctx.update({'lang': inv.partner_id.lang}) |
96 | + ctx = dict(context, lang=inv.partner_id.lang) |
97 | compute_taxes = ait_obj.compute(cr, uid, inv.id, context=ctx) |
98 | self.check_tax_lines(cr, uid, inv, compute_taxes, ait_obj) |
99 | |
100 | @@ -916,7 +916,7 @@ |
101 | raise osv.except_osv(_('UserError'), |
102 | _('You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu.')) |
103 | |
104 | - line = self.finalize_invoice_move_lines(cr, uid, inv, line) |
105 | + line = self.finalize_invoice_move_lines(cr, uid, inv, line, context=context) |
106 | |
107 | move = { |
108 | 'ref': inv.reference and inv.reference or inv.name, |
109 | @@ -1009,8 +1009,7 @@ |
110 | self.log(cr, uid, inv_id, message, context=ctx) |
111 | return True |
112 | |
113 | - def action_cancel(self, cr, uid, ids, *args): |
114 | - context = {} # TODO: Use context from arguments |
115 | + def action_cancel(self, cr, uid, ids, context=None): |
116 | account_move_obj = self.pool.get('account.move') |
117 | invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids']) |
118 | move_ids = [] # ones that we will need to remove |
119 | |
120 | === modified file 'hr_expense/hr_expense.py' |
121 | --- hr_expense/hr_expense.py 2011-11-28 08:06:57 +0000 |
122 | +++ hr_expense/hr_expense.py 2011-12-13 18:03:48 +0000 |
123 | @@ -105,14 +105,14 @@ |
124 | company_id = employee.company_id.id |
125 | return {'value': {'department_id': department_id, 'company_id': company_id}} |
126 | |
127 | - def expense_confirm(self, cr, uid, ids, *args): |
128 | + def expense_confirm(self, cr, uid, ids, context=None): |
129 | self.write(cr, uid, ids, { |
130 | 'state':'confirm', |
131 | 'date_confirm': time.strftime('%Y-%m-%d') |
132 | }) |
133 | return True |
134 | |
135 | - def expense_accept(self, cr, uid, ids, *args): |
136 | + def expense_accept(self, cr, uid, ids, context=None): |
137 | self.write(cr, uid, ids, { |
138 | 'state':'accepted', |
139 | 'date_valid':time.strftime('%Y-%m-%d'), |
140 | @@ -120,11 +120,11 @@ |
141 | }) |
142 | return True |
143 | |
144 | - def expense_canceled(self, cr, uid, ids, *args): |
145 | + def expense_canceled(self, cr, uid, ids, context=None): |
146 | self.write(cr, uid, ids, {'state':'cancelled'}) |
147 | return True |
148 | |
149 | - def expense_paid(self, cr, uid, ids, *args): |
150 | + def expense_paid(self, cr, uid, ids, context=None): |
151 | self.write(cr, uid, ids, {'state':'paid'}) |
152 | return True |
153 | |
154 | @@ -149,7 +149,7 @@ |
155 | 'res_id': inv_ids and inv_ids[0] or False, |
156 | } |
157 | |
158 | - def action_invoice_create(self, cr, uid, ids): |
159 | + def action_invoice_create(self, cr, uid, ids, context=None): |
160 | res = False |
161 | invoice_obj = self.pool.get('account.invoice') |
162 | property_obj = self.pool.get('ir.property') |
163 | |
164 | === modified file 'hr_payroll/hr_payroll.py' |
165 | --- hr_payroll/hr_payroll.py 2011-11-30 14:01:07 +0000 |
166 | +++ hr_payroll/hr_payroll.py 2011-12-13 18:03:48 +0000 |
167 | @@ -336,8 +336,8 @@ |
168 | for payslip in self.browse(cr, uid, ids, context=context): |
169 | id_copy = self.copy(cr, uid, payslip.id, {'credit_note': True, 'name': _('Refund: ')+payslip.name}, context=context) |
170 | self.compute_sheet(cr, uid, [id_copy], context=context) |
171 | - wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'hr_verify_sheet', cr) |
172 | - wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'process_sheet', cr) |
173 | + wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'hr_verify_sheet', cr, context=context) |
174 | + wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'process_sheet', cr, context=context) |
175 | |
176 | form_id = mod_obj.get_object_reference(cr, uid, 'hr_payroll', 'view_hr_payslip_form') |
177 | form_res = form_id and form_id[1] or False |
178 | |
179 | === modified file 'mrp/mrp.py' |
180 | --- mrp/mrp.py 2011-12-06 08:12:49 +0000 |
181 | +++ mrp/mrp.py 2011-12-13 18:03:48 +0000 |
182 | @@ -585,14 +585,14 @@ |
183 | } |
184 | return {'value': result} |
185 | |
186 | - def action_picking_except(self, cr, uid, ids): |
187 | + def action_picking_except(self, cr, uid, ids, context=None): |
188 | """ Changes the state to Exception. |
189 | @return: True |
190 | """ |
191 | self.write(cr, uid, ids, {'state': 'picking_except'}) |
192 | return True |
193 | |
194 | - def action_compute(self, cr, uid, ids, properties=[]): |
195 | + def action_compute(self, cr, uid, ids, properties=[], context=None): |
196 | """ Computes bills of material of a product. |
197 | @param properties: List containing dictionaries of properties. |
198 | @return: No. of products. |
199 | @@ -663,15 +663,15 @@ |
200 | self.log(cr, uid, production_id, message) |
201 | return True |
202 | |
203 | - def action_production_end(self, cr, uid, ids): |
204 | + def action_production_end(self, cr, uid, ids, context=None): |
205 | """ Changes production state to Finish and writes finished date. |
206 | @return: True |
207 | """ |
208 | - for production in self.browse(cr, uid, ids): |
209 | - self._costs_generate(cr, uid, production) |
210 | + for production in self.browse(cr, uid, ids, context=context): |
211 | + self._costs_generate(cr, uid, production, context=context) |
212 | return self.write(cr, uid, ids, {'state': 'done', 'date_finished': time.strftime('%Y-%m-%d %H:%M:%S')}) |
213 | |
214 | - def test_production_done(self, cr, uid, ids): |
215 | + def test_production_done(self, cr, uid, ids, context=None): |
216 | """ Tests whether production is done or not. |
217 | @return: True or False |
218 | """ |
219 | @@ -791,7 +791,7 @@ |
220 | wf_service.trg_validate(uid, 'mrp.production', production_id, 'button_produce_done', cr) |
221 | return True |
222 | |
223 | - def _costs_generate(self, cr, uid, production): |
224 | + def _costs_generate(self, cr, uid, production, context=None): |
225 | """ Calculates total costs at the end of the production. |
226 | @param production: Id of production order. |
227 | @return: Calculated amount. |
228 | @@ -834,14 +834,14 @@ |
229 | } ) |
230 | return amount |
231 | |
232 | - def action_in_production(self, cr, uid, ids): |
233 | + def action_in_production(self, cr, uid, ids, context=None): |
234 | """ Changes state to In Production and writes starting date. |
235 | @return: True |
236 | """ |
237 | self.write(cr, uid, ids, {'state': 'in_production', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S')}) |
238 | return True |
239 | |
240 | - def test_if_product(self, cr, uid, ids): |
241 | + def test_if_product(self, cr, uid, ids, context=None): |
242 | """ |
243 | @return: True or False |
244 | """ |
245 | @@ -852,10 +852,10 @@ |
246 | res = False |
247 | return res |
248 | |
249 | - def _get_auto_picking(self, cr, uid, production): |
250 | + def _get_auto_picking(self, cr, uid, production, context=None): |
251 | return True |
252 | |
253 | - def action_confirm(self, cr, uid, ids): |
254 | + def action_confirm(self, cr, uid, ids, context=None): |
255 | """ Confirms production order. |
256 | @return: Newly generated picking Id. |
257 | """ |
258 | @@ -866,10 +866,10 @@ |
259 | move_obj = self.pool.get('stock.move') |
260 | proc_obj = self.pool.get('procurement.order') |
261 | wf_service = netsvc.LocalService("workflow") |
262 | - for production in self.browse(cr, uid, ids): |
263 | + for production in self.browse(cr, uid, ids, context=context): |
264 | if not production.product_lines: |
265 | - self.action_compute(cr, uid, [production.id]) |
266 | - production = self.browse(cr, uid, [production.id])[0] |
267 | + self.action_compute(cr, uid, [production.id], context=context) |
268 | + production = self.browse(cr, uid, [production.id], context=context)[0] |
269 | routing_loc = None |
270 | pick_type = 'internal' |
271 | address_id = False |
272 | @@ -958,9 +958,9 @@ |
273 | 'move_id': move_id, |
274 | 'company_id': production.company_id.id, |
275 | }) |
276 | - wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) |
277 | + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr, context=context) |
278 | proc_ids.append(proc_id) |
279 | - wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) |
280 | + wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr, context=context) |
281 | self.write(cr, uid, [production.id], {'picking_id': picking_id, 'move_lines': [(6,0,moves)], 'state':'confirmed'}) |
282 | message = _("Manufacturing order '%s' is scheduled for the %s.") % ( |
283 | production.name, |
284 | @@ -969,13 +969,13 @@ |
285 | self.log(cr, uid, production.id, message) |
286 | return picking_id |
287 | |
288 | - def force_production(self, cr, uid, ids, *args): |
289 | + def force_production(self, cr, uid, ids, context=None): |
290 | """ Assigns products. |
291 | @param *args: Arguments |
292 | @return: True |
293 | """ |
294 | pick_obj = self.pool.get('stock.picking') |
295 | - pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)]) |
296 | + pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)], context=context) |
297 | return True |
298 | |
299 | mrp_production() |
300 | |
301 | === modified file 'mrp/procurement.py' |
302 | --- mrp/procurement.py 2011-09-17 16:41:25 +0000 |
303 | +++ mrp/procurement.py 2011-12-13 18:03:48 +0000 |
304 | @@ -33,7 +33,7 @@ |
305 | 'property_ids': fields.many2many('mrp.property', 'procurement_property_rel', 'procurement_id','property_id', 'Properties'), |
306 | } |
307 | |
308 | - def check_produce_product(self, cr, uid, procurement, context=[]): |
309 | + def check_produce_product(self, cr, uid, procurement, context=None): |
310 | """ Finds the bill of material for the product from procurement order. |
311 | @return: True or False |
312 | """ |
313 | @@ -99,7 +99,7 @@ |
314 | self.write(cr, uid, [procurement.id], {'state': 'running'}) |
315 | bom_result = production_obj.action_compute(cr, uid, |
316 | [produce_id], properties=[x.id for x in procurement.property_ids]) |
317 | - wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr) |
318 | + wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr, context=context) |
319 | if res_id: |
320 | move_obj.write(cr, uid, [res_id], |
321 | {'location_id': procurement.location_id.id}) |
322 | |
323 | === modified file 'mrp_operations/mrp_operations.py' |
324 | --- mrp_operations/mrp_operations.py 2011-12-08 09:49:28 +0000 |
325 | +++ mrp_operations/mrp_operations.py 2011-12-13 18:03:48 +0000 |
326 | @@ -156,14 +156,14 @@ |
327 | prod_obj.write(cr, uid, [prod.production_id.id], {'date_start':dstart}, context=context, mini=False) |
328 | return result |
329 | |
330 | - def action_draft(self, cr, uid, ids): |
331 | + def action_draft(self, cr, uid, ids, context=None): |
332 | """ Sets state to draft. |
333 | @return: True |
334 | """ |
335 | self.write(cr, uid, ids, {'state':'draft'}) |
336 | return True |
337 | |
338 | - def action_start_working(self, cr, uid, ids): |
339 | + def action_start_working(self, cr, uid, ids, context=None): |
340 | """ Sets state to start working and writes starting date. |
341 | @return: True |
342 | """ |
343 | @@ -171,7 +171,7 @@ |
344 | self.write(cr, uid, ids, {'state':'startworking', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S')}) |
345 | return True |
346 | |
347 | - def action_done(self, cr, uid, ids): |
348 | + def action_done(self, cr, uid, ids, context=None): |
349 | """ Sets state to done, writes finish date and calculates delay. |
350 | @return: True |
351 | """ |
352 | @@ -188,21 +188,21 @@ |
353 | self.modify_production_order_state(cr,uid,ids,'done') |
354 | return True |
355 | |
356 | - def action_cancel(self, cr, uid, ids): |
357 | + def action_cancel(self, cr, uid, ids, context=None): |
358 | """ Sets state to cancel. |
359 | @return: True |
360 | """ |
361 | self.write(cr, uid, ids, {'state':'cancel'}) |
362 | return True |
363 | |
364 | - def action_pause(self, cr, uid, ids): |
365 | + def action_pause(self, cr, uid, ids, context=None): |
366 | """ Sets state to pause. |
367 | @return: True |
368 | """ |
369 | self.write(cr, uid, ids, {'state':'pause'}) |
370 | return True |
371 | |
372 | - def action_resume(self, cr, uid, ids): |
373 | + def action_resume(self, cr, uid, ids, context=None): |
374 | """ Sets state to startworking. |
375 | @return: True |
376 | """ |
377 | @@ -228,7 +228,7 @@ |
378 | result[prod.id] = max(line.date_planned_end, result[prod.id]) |
379 | return result |
380 | |
381 | - def action_production_end(self, cr, uid, ids): |
382 | + def action_production_end(self, cr, uid, ids, context=None): |
383 | """ Finishes work order if production order is done. |
384 | @return: Super method |
385 | """ |
386 | @@ -236,11 +236,11 @@ |
387 | wf_service = netsvc.LocalService("workflow") |
388 | for workcenter_line in obj.workcenter_lines: |
389 | if workcenter_line.state == 'draft': |
390 | - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_start_working', cr) |
391 | - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_done', cr) |
392 | - return super(mrp_production,self).action_production_end(cr, uid, ids) |
393 | + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_start_working', cr, context=context) |
394 | + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_done', cr, context=context) |
395 | + return super(mrp_production,self).action_production_end(cr, uid, ids, context=context) |
396 | |
397 | - def action_in_production(self, cr, uid, ids): |
398 | + def action_in_production(self, cr, uid, ids, context=None): |
399 | """ Changes state to In Production and writes starting date. |
400 | @return: True |
401 | """ |
402 | @@ -249,8 +249,8 @@ |
403 | wf_service = netsvc.LocalService("workflow") |
404 | for prod in self.browse(cr, uid, ids): |
405 | if prod.workcenter_lines: |
406 | - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', prod.workcenter_lines[0].id, 'button_start_working', cr) |
407 | - return super(mrp_production,self).action_in_production(cr, uid, ids) |
408 | + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', prod.workcenter_lines[0].id, 'button_start_working', cr, context=context) |
409 | + return super(mrp_production,self).action_in_production(cr, uid, ids, context=context) |
410 | |
411 | def action_cancel(self, cr, uid, ids, context=None): |
412 | """ Cancels work order if production order is canceled. |
413 | @@ -259,7 +259,7 @@ |
414 | obj = self.browse(cr, uid, ids,context=context)[0] |
415 | wf_service = netsvc.LocalService("workflow") |
416 | for workcenter_line in obj.workcenter_lines: |
417 | - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_cancel', cr) |
418 | + wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_cancel', cr, context=context) |
419 | return super(mrp_production,self).action_cancel(cr,uid,ids,context=context) |
420 | |
421 | def _compute_planned_workcenter(self, cr, uid, ids, context=None, mini=False): |
422 | @@ -371,13 +371,13 @@ |
423 | pass |
424 | return result |
425 | |
426 | - def action_compute(self, cr, uid, ids, properties=[]): |
427 | + def action_compute(self, cr, uid, ids, properties=[], context=None): |
428 | """ Computes bills of material of a product and planned date of work order. |
429 | @param properties: List containing dictionaries of properties. |
430 | @return: No. of products. |
431 | """ |
432 | - result = super(mrp_production, self).action_compute(cr, uid, ids, properties=properties) |
433 | - self._compute_planned_workcenter(cr, uid, ids, context={}) |
434 | + result = super(mrp_production, self).action_compute(cr, uid, ids, properties=properties, context=context) |
435 | + self._compute_planned_workcenter(cr, uid, ids, context=context) |
436 | return result |
437 | |
438 | mrp_production() |
439 | |
440 | === modified file 'procurement/procurement.py' |
441 | --- procurement/procurement.py 2011-12-07 14:58:54 +0000 |
442 | +++ procurement/procurement.py 2011-12-13 18:03:48 +0000 |
443 | @@ -410,7 +410,7 @@ |
444 | """ |
445 | return 0 |
446 | |
447 | - def action_cancel(self, cr, uid, ids): |
448 | + def action_cancel(self, cr, uid, ids, context=None): |
449 | """ Cancels procurement and writes move state to Assigned. |
450 | @return: True |
451 | """ |
452 | @@ -431,13 +431,13 @@ |
453 | self.write(cr, uid, ids, {'state': 'cancel'}) |
454 | wf_service = netsvc.LocalService("workflow") |
455 | for id in ids: |
456 | - wf_service.trg_trigger(uid, 'procurement.order', id, cr) |
457 | + wf_service.trg_trigger(uid, 'procurement.order', id, cr, context=context) |
458 | return True |
459 | |
460 | - def action_check_finished(self, cr, uid, ids): |
461 | + def action_check_finished(self, cr, uid, ids, context=None): |
462 | return self.check_move_done(cr, uid, ids) |
463 | |
464 | - def action_check(self, cr, uid, ids): |
465 | + def action_check(self, cr, uid, ids, context=None): |
466 | """ Checks procurement move state whether assigned or done. |
467 | @return: True |
468 | """ |
469 | @@ -448,14 +448,14 @@ |
470 | ok = True |
471 | return ok |
472 | |
473 | - def action_ready(self, cr, uid, ids): |
474 | + def action_ready(self, cr, uid, ids, context=None): |
475 | """ Changes procurement state to Ready. |
476 | @return: True |
477 | """ |
478 | res = self.write(cr, uid, ids, {'state': 'ready'}) |
479 | return res |
480 | |
481 | - def action_done(self, cr, uid, ids): |
482 | + def action_done(self, cr, uid, ids, context=None): |
483 | """ Changes procurement state to Done and writes Closed date. |
484 | @return: True |
485 | """ |
486 | @@ -463,11 +463,11 @@ |
487 | for procurement in self.browse(cr, uid, ids): |
488 | if procurement.move_id: |
489 | if procurement.close_move and (procurement.move_id.state <> 'done'): |
490 | - move_obj.action_done(cr, uid, [procurement.move_id.id]) |
491 | + move_obj.action_done(cr, uid, [procurement.move_id.id], context=context) |
492 | res = self.write(cr, uid, ids, {'state': 'done', 'date_close': time.strftime('%Y-%m-%d')}) |
493 | wf_service = netsvc.LocalService("workflow") |
494 | for id in ids: |
495 | - wf_service.trg_trigger(uid, 'procurement.order', id, cr) |
496 | + wf_service.trg_trigger(uid, 'procurement.order', id, cr, context=context) |
497 | return res |
498 | |
499 | procurement_order() |
500 | @@ -475,7 +475,7 @@ |
501 | class StockPicking(osv.osv): |
502 | _inherit = 'stock.picking' |
503 | |
504 | - def test_finished(self, cursor, user, ids): |
505 | + def test_finished(self, cursor, user, ids, context=None): |
506 | wf_service = netsvc.LocalService("workflow") |
507 | res = super(StockPicking, self).test_finished(cursor, user, ids) |
508 | for picking in self.browse(cursor, user, ids): |
509 | @@ -483,7 +483,7 @@ |
510 | if move.state == 'done' and move.procurements: |
511 | for procurement in move.procurements: |
512 | wf_service.trg_validate(user, 'procurement.order', |
513 | - procurement.id, 'button_check', cursor) |
514 | + procurement.id, 'button_check', cursor, context=context) |
515 | return res |
516 | |
517 | StockPicking() |
518 | |
519 | === modified file 'purchase/purchase.py' |
520 | --- purchase/purchase.py 2011-12-01 21:32:12 +0000 |
521 | +++ purchase/purchase.py 2011-12-13 18:03:48 +0000 |
522 | @@ -339,15 +339,15 @@ |
523 | 'account_analytic_id': order_line.account_analytic_id.id or False, |
524 | } |
525 | |
526 | - def action_cancel_draft(self, cr, uid, ids, *args): |
527 | + def action_cancel_draft(self, cr, uid, ids, context=None): |
528 | if not len(ids): |
529 | return False |
530 | self.write(cr, uid, ids, {'state':'draft','shipped':0}) |
531 | wf_service = netsvc.LocalService("workflow") |
532 | for p_id in ids: |
533 | # Deleting the existing instance of workflow for PO |
534 | - wf_service.trg_delete(uid, 'purchase.order', p_id, cr) |
535 | - wf_service.trg_create(uid, 'purchase.order', p_id, cr) |
536 | + wf_service.trg_delete(uid, 'purchase.order', p_id, cr, context=context) |
537 | + wf_service.trg_create(uid, 'purchase.order', p_id, cr, context=context) |
538 | for (id,name) in self.name_get(cr, uid, ids): |
539 | message = _("Purchase order '%s' has been set in draft state.") % name |
540 | self.log(cr, uid, id, message) |
541 | @@ -421,7 +421,7 @@ |
542 | res = inv_id |
543 | return res |
544 | |
545 | - def has_stockable_product(self,cr, uid, ids, *args): |
546 | + def has_stockable_product(self,cr, uid, ids, context=None): |
547 | for order in self.browse(cr, uid, ids): |
548 | for order_line in order.order_line: |
549 | if order_line.product_id and order_line.product_id.product_tmpl_id.type in ('product', 'consu'): |
550 | @@ -437,14 +437,14 @@ |
551 | _('Unable to cancel this purchase order!'), |
552 | _('You must first cancel all receptions related to this purchase order.')) |
553 | for pick in purchase.picking_ids: |
554 | - wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_cancel', cr) |
555 | + wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_cancel', cr, context=context) |
556 | for inv in purchase.invoice_ids: |
557 | if inv and inv.state not in ('cancel','draft'): |
558 | raise osv.except_osv( |
559 | _('Unable to cancel this purchase order!'), |
560 | _('You must first cancel all invoices related to this purchase order.')) |
561 | if inv: |
562 | - wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr) |
563 | + wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr, context=context) |
564 | self.write(cr,uid,ids,{'state':'cancel'}) |
565 | |
566 | for (id, name) in self.name_get(cr, uid, ids): |
567 | @@ -453,7 +453,7 @@ |
568 | self.log(cr, uid, id, message) |
569 | return True |
570 | |
571 | - def _prepare_order_picking(self, cr, uid, order, *args): |
572 | + def _prepare_order_picking(self, cr, uid, order, context=None): |
573 | return { |
574 | 'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.in'), |
575 | 'origin': order.name + ((order.origin and (':' + order.origin)) or ''), |
576 | @@ -466,7 +466,7 @@ |
577 | 'move_lines' : [], |
578 | } |
579 | |
580 | - def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, *args): |
581 | + def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, context=None): |
582 | return { |
583 | 'name': order.name + ': ' + (order_line.name or ''), |
584 | 'product_id': order_line.product_id.id, |
585 | @@ -487,7 +487,7 @@ |
586 | 'price_unit': order_line.price_unit |
587 | } |
588 | |
589 | - def _create_pickings(self, cr, uid, order, order_lines, picking_id=False, *args): |
590 | + def _create_pickings(self, cr, uid, order, order_lines, picking_id=False, context=None): |
591 | """Creates pickings and appropriate stock moves for given order lines, then |
592 | confirms the moves, makes them available, and confirms the picking. |
593 | |
594 | @@ -507,7 +507,7 @@ |
595 | :return: list of IDs of pickings used/created for the given order lines (usually just one) |
596 | """ |
597 | if not picking_id: |
598 | - picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, *args)) |
599 | + picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context)) |
600 | todo_moves = [] |
601 | stock_move = self.pool.get('stock.move') |
602 | wf_service = netsvc.LocalService("workflow") |
603 | @@ -515,19 +515,19 @@ |
604 | if not order_line.product_id: |
605 | continue |
606 | if order_line.product_id.type in ('product', 'consu'): |
607 | - move = stock_move.create(cr, uid, self._prepare_order_line_move(cr, uid, order, order_line, picking_id, *args)) |
608 | + move = stock_move.create(cr, uid, self._prepare_order_line_move(cr, uid, order, order_line, picking_id, context=context)) |
609 | if order_line.move_dest_id: |
610 | order_line.move_dest_id.write({'location_id': order.location_id.id}) |
611 | todo_moves.append(move) |
612 | - stock_move.action_confirm(cr, uid, todo_moves) |
613 | - stock_move.force_assign(cr, uid, todo_moves) |
614 | - wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) |
615 | + stock_move.action_confirm(cr, uid, todo_moves, context=context) |
616 | + stock_move.force_assign(cr, uid, todo_moves, context=context) |
617 | + wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr, context=context) |
618 | return [picking_id] |
619 | |
620 | - def action_picking_create(self,cr, uid, ids, *args): |
621 | + def action_picking_create(self,cr, uid, ids, context=None): |
622 | picking_ids = [] |
623 | for order in self.browse(cr, uid, ids): |
624 | - picking_ids.extend(self._create_pickings(cr, uid, order, order.order_line, None, *args)) |
625 | + picking_ids.extend(self._create_pickings(cr, uid, order, order.order_line, None, context=None)) |
626 | |
627 | # Must return one unique picking ID: the one to connect in the subflow of the purchase order. |
628 | # In case of multiple (split) pickings, we should return the ID of the critical one, i.e. the |
629 | @@ -730,7 +730,7 @@ |
630 | # - split into small internal methods for clearity |
631 | def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom, |
632 | partner_id, date_order=False, fiscal_position=False, date_planned=False, |
633 | - name=False, price_unit=False, notes=False, context={}): |
634 | + name=False, price_unit=False, notes=False, context=None): |
635 | if not pricelist: |
636 | raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist or a supplier in the purchase form !\nPlease set one before choosing a product.')) |
637 | if not partner_id: |
638 | @@ -744,8 +744,9 @@ |
639 | lang=False |
640 | if partner_id: |
641 | lang=self.pool.get('res.partner').read(cr, uid, partner_id, ['lang'])['lang'] |
642 | - context={'lang':lang} |
643 | - context['partner_id'] = partner_id |
644 | + if context is None: |
645 | + context = {} |
646 | + context = dict(context, lang=lang, partner_id=partner_id) |
647 | |
648 | prod = self.pool.get('product.product').browse(cr, uid, product, context=context) |
649 | prod_uom_po = prod.uom_po_id.id |
650 | @@ -805,7 +806,7 @@ |
651 | # - merge into 'product_id_change' method |
652 | def product_uom_change(self, cr, uid, ids, pricelist, product, qty, uom, |
653 | partner_id, date_order=False, fiscal_position=False, date_planned=False, |
654 | - name=False, price_unit=False, notes=False, context={}): |
655 | + name=False, price_unit=False, notes=False, context=None): |
656 | res = self.product_id_change(cr, uid, ids, pricelist, product, qty, uom, |
657 | partner_id, date_order=date_order, fiscal_position=fiscal_position, date_planned=date_planned, |
658 | name=name, price_unit=price_unit, notes=notes, context=context) |
659 | |
660 | === modified file 'sale/sale.py' |
661 | --- sale/sale.py 2011-12-11 11:09:56 +0000 |
662 | +++ sale/sale.py 2011-12-13 18:03:48 +0000 |
663 | @@ -306,7 +306,7 @@ |
664 | v['pricelist_id'] = shop.pricelist_id.id |
665 | return {'value': v} |
666 | |
667 | - def action_cancel_draft(self, cr, uid, ids, *args): |
668 | + def action_cancel_draft(self, cr, uid, ids, context=None): |
669 | if not len(ids): |
670 | return False |
671 | cr.execute('select id from sale_order_line where order_id IN %s and state=%s', (tuple(ids), 'cancel')) |
672 | @@ -316,14 +316,14 @@ |
673 | wf_service = netsvc.LocalService("workflow") |
674 | for inv_id in ids: |
675 | # Deleting the existing instance of workflow for SO |
676 | - wf_service.trg_delete(uid, 'sale.order', inv_id, cr) |
677 | - wf_service.trg_create(uid, 'sale.order', inv_id, cr) |
678 | + wf_service.trg_delete(uid, 'sale.order', inv_id, cr, context=context) |
679 | + wf_service.trg_create(uid, 'sale.order', inv_id, cr, context=context) |
680 | for (id,name) in self.name_get(cr, uid, ids): |
681 | message = _("The sales order '%s' has been set in draft state.") %(name,) |
682 | self.log(cr, uid, id, message) |
683 | return True |
684 | |
685 | - def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context={}): |
686 | + def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context=None): |
687 | print order_lines |
688 | if (not pricelist_id) or (not order_lines): |
689 | return {} |
690 | @@ -333,6 +333,7 @@ |
691 | } |
692 | return {'warning': warning} |
693 | |
694 | +<<<<<<< TREE |
695 | def onchange_partner_order_id(self, cr, uid, ids, order_id, invoice_id=False, shipping_id=False, context={}): |
696 | if not order_id: |
697 | return {} |
698 | @@ -344,6 +345,9 @@ |
699 | return {'value': val} |
700 | |
701 | def onchange_partner_id(self, cr, uid, ids, part): |
702 | +======= |
703 | + def onchange_partner_id(self, cr, uid, ids, part, context=None): |
704 | +>>>>>>> MERGE-SOURCE |
705 | if not part: |
706 | return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False, 'partner_order_id': False, 'payment_term': False, 'fiscal_position': False}} |
707 | |
708 | @@ -608,7 +612,7 @@ |
709 | proc_ids = proc_obj.search(cr, uid, [('move_id', '=', mov.id)]) |
710 | if proc_ids: |
711 | for proc in proc_ids: |
712 | - wf_service.trg_validate(uid, 'procurement.order', proc, 'button_check', cr) |
713 | + wf_service.trg_validate(uid, 'procurement.order', proc, 'button_check', cr, context=context) |
714 | for r in self.read(cr, uid, ids, ['picking_ids']): |
715 | for pick in r['picking_ids']: |
716 | wf_service.trg_validate(uid, 'stock.picking', pick, 'button_cancel', cr) |
717 | @@ -619,7 +623,7 @@ |
718 | _('You must first cancel all invoices attached to this sales order.')) |
719 | for r in self.read(cr, uid, ids, ['invoice_ids']): |
720 | for inv in r['invoice_ids']: |
721 | - wf_service.trg_validate(uid, 'account.invoice', inv, 'invoice_cancel', cr) |
722 | + wf_service.trg_validate(uid, 'account.invoice', inv, 'invoice_cancel', cr, context=context) |
723 | sale_order_line_obj.write(cr, uid, [l.id for l in sale.order_line], |
724 | {'state': 'cancel'}) |
725 | message = _("The sales order '%s' has been cancelled.") % (sale.name,) |
726 | @@ -627,7 +631,7 @@ |
727 | self.write(cr, uid, ids, {'state': 'cancel'}) |
728 | return True |
729 | |
730 | - def action_wait(self, cr, uid, ids, *args): |
731 | + def action_wait(self, cr, uid, ids, context=None): |
732 | for o in self.browse(cr, uid, ids): |
733 | if not o.order_line: |
734 | raise osv.except_osv(_('Error !'),_('You cannot confirm a sale order which has no line.')) |
735 | @@ -635,12 +639,12 @@ |
736 | self.write(cr, uid, [o.id], {'state': 'manual', 'date_confirm': time.strftime(DEFAULT_SERVER_DATE_FORMAT)}) |
737 | else: |
738 | self.write(cr, uid, [o.id], {'state': 'progress', 'date_confirm': time.strftime(DEFAULT_SERVER_DATE_FORMAT)}) |
739 | - self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line]) |
740 | + self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line], context=context) |
741 | message = _("The quotation '%s' has been converted to a sales order.") % (o.name,) |
742 | self.log(cr, uid, o.id, message) |
743 | return True |
744 | |
745 | - def procurement_lines_get(self, cr, uid, ids, *args): |
746 | + def procurement_lines_get(self, cr, uid, ids, context=None): |
747 | res = [] |
748 | for order in self.browse(cr, uid, ids, context={}): |
749 | for line in order.order_line: |
750 | @@ -652,14 +656,14 @@ |
751 | # returns True if all lines are done, False otherwise |
752 | # if mode == 'canceled': |
753 | # returns True if there is at least one canceled line, False otherwise |
754 | - def test_state(self, cr, uid, ids, mode, *args): |
755 | + def test_state(self, cr, uid, ids, mode, context=None): |
756 | assert mode in ('finished', 'canceled'), _("invalid mode for test_state") |
757 | finished = True |
758 | canceled = False |
759 | notcanceled = False |
760 | write_done_ids = [] |
761 | write_cancel_ids = [] |
762 | - for order in self.browse(cr, uid, ids, context={}): |
763 | + for order in self.browse(cr, uid, ids, context=context): |
764 | for line in order.order_line: |
765 | if (not line.procurement_id) or (line.procurement_id.state=='done'): |
766 | if line.state != 'done': |
767 | @@ -686,7 +690,7 @@ |
768 | return False |
769 | return canceled |
770 | |
771 | - def _prepare_order_line_procurement(self, cr, uid, order, line, move_id, date_planned, *args): |
772 | + def _prepare_order_line_procurement(self, cr, uid, order, line, move_id, date_planned, context=None): |
773 | return { |
774 | 'name': line.name, |
775 | 'origin': order.name, |
776 | @@ -707,7 +711,7 @@ |
777 | 'company_id': order.company_id.id, |
778 | } |
779 | |
780 | - def _prepare_order_line_move(self, cr, uid, order, line, picking_id, date_planned, *args): |
781 | + def _prepare_order_line_move(self, cr, uid, order, line, picking_id, date_planned, context=None): |
782 | location_id = order.shop_id.warehouse_id.lot_stock_id.id |
783 | output_id = order.shop_id.warehouse_id.lot_output_id.id |
784 | return { |
785 | @@ -734,7 +738,7 @@ |
786 | 'price_unit': line.product_id.standard_price or 0.0 |
787 | } |
788 | |
789 | - def _prepare_order_picking(self, cr, uid, order, *args): |
790 | + def _prepare_order_picking(self, cr, uid, order, context=None): |
791 | pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out') |
792 | return { |
793 | 'name': pick_name, |
794 | @@ -750,7 +754,7 @@ |
795 | 'company_id': order.company_id.id, |
796 | } |
797 | |
798 | - def _create_pickings_and_procurements(self, cr, uid, order, order_lines, picking_id=False, *args): |
799 | + def _create_pickings_and_procurements(self, cr, uid, order, order_lines, picking_id=False, context=None): |
800 | """Create the required procurements to supply sale order lines, also connecting |
801 | the procurements to appropriate stock moves in order to bring the goods to the |
802 | sale order's requested location. |
803 | @@ -784,13 +788,13 @@ |
804 | if line.product_id: |
805 | if line.product_id.product_tmpl_id.type in ('product', 'consu'): |
806 | if not picking_id: |
807 | - picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, *args)) |
808 | - move_id = move_obj.create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, *args)) |
809 | + picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context)) |
810 | + move_id = move_obj.create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, context=context)) |
811 | else: |
812 | # a service has no stock move |
813 | move_id = False |
814 | |
815 | - proc_id = procurement_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, *args)) |
816 | + proc_id = procurement_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, context=context)) |
817 | proc_ids.append(proc_id) |
818 | line.write({'procurement_id': proc_id}) |
819 | |
820 | @@ -809,10 +813,10 @@ |
821 | |
822 | wf_service = netsvc.LocalService("workflow") |
823 | if picking_id: |
824 | - wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) |
825 | + wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr, context=context) |
826 | |
827 | for proc_id in proc_ids: |
828 | - wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) |
829 | + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr, context=context) |
830 | |
831 | val = {} |
832 | if order.state == 'shipping_except': |
833 | @@ -827,9 +831,9 @@ |
834 | order.write(val) |
835 | return True |
836 | |
837 | - def action_ship_create(self, cr, uid, ids, *args): |
838 | - for order in self.browse(cr, uid, ids, context={}): |
839 | - self._create_pickings_and_procurements(cr, uid, order, order.order_line, None, *args) |
840 | + def action_ship_create(self, cr, uid, ids, context=None): |
841 | + for order in self.browse(cr, uid, ids, context=context): |
842 | + self._create_pickings_and_procurements(cr, uid, order, order.order_line, None, context=context) |
843 | return True |
844 | |
845 | def action_ship_end(self, cr, uid, ids, context=None): |
846 | @@ -1041,7 +1045,7 @@ |
847 | # Trigger workflow events |
848 | wf_service = netsvc.LocalService("workflow") |
849 | for sid in sales.keys(): |
850 | - wf_service.trg_write(uid, 'sale.order', sid, cr) |
851 | + wf_service.trg_write(uid, 'sale.order', sid, cr, context=context) |
852 | return create_ids |
853 | |
854 | def button_cancel(self, cr, uid, ids, context=None): |
855 | @@ -1065,7 +1069,7 @@ |
856 | wf_service.trg_write(uid, 'sale.order', line.order_id.id, cr) |
857 | return res |
858 | |
859 | - def uos_change(self, cr, uid, ids, product_uos, product_uos_qty=0, product_id=None): |
860 | + def uos_change(self, cr, uid, ids, product_uos, product_uos_qty=0, product_id=None, context=None): |
861 | product_obj = self.pool.get('product.product') |
862 | if not product_id: |
863 | return {'value': {'product_uom': product_uos, |
864 | |
865 | === modified file 'stock/stock.py' |
866 | --- stock/stock.py 2011-12-01 21:32:12 +0000 |
867 | +++ stock/stock.py 2011-12-13 18:03:48 +0000 |
868 | @@ -739,7 +739,7 @@ |
869 | # TODO: Check locations to see if in the same location ? |
870 | return True |
871 | |
872 | - def action_assign(self, cr, uid, ids, *args): |
873 | + def action_assign(self, cr, uid, ids, context=None): |
874 | """ Changes state of picking to available if all moves are confirmed. |
875 | @return: True |
876 | """ |
877 | @@ -750,7 +750,7 @@ |
878 | self.pool.get('stock.move').action_assign(cr, uid, move_ids) |
879 | return True |
880 | |
881 | - def force_assign(self, cr, uid, ids, *args): |
882 | + def force_assign(self, cr, uid, ids, context=None): |
883 | """ Changes state of picking to available if moves are confirmed or waiting. |
884 | @return: True |
885 | """ |
886 | @@ -758,10 +758,10 @@ |
887 | for pick in self.browse(cr, uid, ids): |
888 | move_ids = [x.id for x in pick.move_lines if x.state in ['confirmed','waiting']] |
889 | self.pool.get('stock.move').force_assign(cr, uid, move_ids) |
890 | - wf_service.trg_write(uid, 'stock.picking', pick.id, cr) |
891 | + wf_service.trg_write(uid, 'stock.picking', pick.id, cr, context=context) |
892 | return True |
893 | |
894 | - def draft_force_assign(self, cr, uid, ids, *args): |
895 | + def draft_force_assign(self, cr, uid, ids, context=None): |
896 | """ Confirms picking directly from draft state. |
897 | @return: True |
898 | """ |
899 | @@ -770,7 +770,7 @@ |
900 | if not pick.move_lines: |
901 | raise osv.except_osv(_('Error !'),_('You can not process picking without stock moves')) |
902 | wf_service.trg_validate(uid, 'stock.picking', pick.id, |
903 | - 'button_confirm', cr) |
904 | + 'button_confirm', cr, context=context) |
905 | return True |
906 | |
907 | def draft_validate(self, cr, uid, ids, context=None): |
908 | @@ -782,10 +782,10 @@ |
909 | for pick in self.browse(cr, uid, ids, context=context): |
910 | move_ids = [x.id for x in pick.move_lines] |
911 | self.pool.get('stock.move').force_assign(cr, uid, move_ids) |
912 | - wf_service.trg_write(uid, 'stock.picking', pick.id, cr) |
913 | + wf_service.trg_write(uid, 'stock.picking', pick.id, cr, context=context) |
914 | return self.action_process( |
915 | cr, uid, ids, context=context) |
916 | - def cancel_assign(self, cr, uid, ids, *args): |
917 | + def cancel_assign(self, cr, uid, ids, context=None): |
918 | """ Cancels picking and moves. |
919 | @return: True |
920 | """ |
921 | @@ -793,7 +793,7 @@ |
922 | for pick in self.browse(cr, uid, ids): |
923 | move_ids = [x.id for x in pick.move_lines] |
924 | self.pool.get('stock.move').cancel_assign(cr, uid, move_ids) |
925 | - wf_service.trg_write(uid, 'stock.picking', pick.id, cr) |
926 | + wf_service.trg_write(uid, 'stock.picking', pick.id, cr, context=context) |
927 | return True |
928 | |
929 | def action_assign_wkf(self, cr, uid, ids, context=None): |
930 | @@ -804,7 +804,7 @@ |
931 | self.log_picking(cr, uid, ids, context=context) |
932 | return True |
933 | |
934 | - def test_finished(self, cr, uid, ids): |
935 | + def test_finished(self, cr, uid, ids, context=None): |
936 | """ Tests whether the move is in done or cancel state or not. |
937 | @return: True or False |
938 | """ |
939 | @@ -818,7 +818,7 @@ |
940 | move.write({'state': 'done'}) |
941 | return True |
942 | |
943 | - def test_assigned(self, cr, uid, ids): |
944 | + def test_assigned(self, cr, uid, ids, context=None): |
945 | """ Tests whether the move is in assigned state or not. |
946 | @return: True or False |
947 | """ |
948 | @@ -1284,16 +1284,16 @@ |
949 | |
950 | # At first we confirm the new picking (if necessary) |
951 | if new_picking: |
952 | - wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr) |
953 | + wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr, context=context) |
954 | # Then we finish the good picking |
955 | self.write(cr, uid, [pick.id], {'backorder_id': new_picking}) |
956 | - self.action_move(cr, uid, [new_picking]) |
957 | - wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_done', cr) |
958 | - wf_service.trg_write(uid, 'stock.picking', pick.id, cr) |
959 | + self.action_move(cr, uid, [new_picking], context=context) |
960 | + wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_done', cr, context=context) |
961 | + wf_service.trg_write(uid, 'stock.picking', pick.id, cr, context=context) |
962 | delivered_pack_id = new_picking |
963 | else: |
964 | self.action_move(cr, uid, [pick.id]) |
965 | - wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_done', cr) |
966 | + wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_done', cr, context=context) |
967 | delivered_pack_id = pick.id |
968 | |
969 | delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context) |
970 | @@ -1909,7 +1909,7 @@ |
971 | }) |
972 | new_moves.append(self.browse(cr, uid, [new_id])[0]) |
973 | if pickid: |
974 | - wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr) |
975 | + wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr, context=context) |
976 | if new_moves: |
977 | new_moves += self.create_chained_picking(cr, uid, new_moves, context) |
978 | return new_moves |
979 | @@ -1920,10 +1920,10 @@ |
980 | """ |
981 | moves = self.browse(cr, uid, ids, context=context) |
982 | self.write(cr, uid, ids, {'state': 'confirmed'}) |
983 | - self.create_chained_picking(cr, uid, moves, context) |
984 | + self.create_chained_picking(cr, uid, moves, context=context) |
985 | return [] |
986 | |
987 | - def action_assign(self, cr, uid, ids, *args): |
988 | + def action_assign(self, cr, uid, ids, context=None): |
989 | """ Changes state to confirmed or waiting. |
990 | @return: List of values |
991 | """ |
992 | @@ -1931,7 +1931,7 @@ |
993 | for move in self.browse(cr, uid, ids): |
994 | if move.state in ('confirmed', 'waiting'): |
995 | todo.append(move.id) |
996 | - res = self.check_assign(cr, uid, todo) |
997 | + res = self.check_assign(cr, uid, todo, context=context) |
998 | return res |
999 | |
1000 | def force_assign(self, cr, uid, ids, context=None): |
1001 | @@ -2203,10 +2203,10 @@ |
1002 | |
1003 | self.write(cr, uid, move_ids, {'state': 'done', 'date': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context) |
1004 | for id in move_ids: |
1005 | - wf_service.trg_trigger(uid, 'stock.move', id, cr) |
1006 | + wf_service.trg_trigger(uid, 'stock.move', id, cr, context=context) |
1007 | |
1008 | for pick_id in picking_ids: |
1009 | - wf_service.trg_write(uid, 'stock.picking', pick_id, cr) |
1010 | + wf_service.trg_write(uid, 'stock.picking', pick_id, cr, context=context) |
1011 | |
1012 | return True |
1013 | |
1014 | |
1015 | === modified file 'stock_location/procurement_pull.py' |
1016 | --- stock_location/procurement_pull.py 2011-11-24 15:50:58 +0000 |
1017 | +++ stock_location/procurement_pull.py 2011-12-13 18:03:48 +0000 |
1018 | @@ -45,7 +45,7 @@ |
1019 | return (line.type_proc=='move') and (line.location_src_id) |
1020 | return False |
1021 | |
1022 | - def action_move_create(self, cr, uid, ids,context=None): |
1023 | + def action_move_create(self, cr, uid, ids, context=None): |
1024 | proc_obj = self.pool.get('procurement.order') |
1025 | move_obj = self.pool.get('stock.move') |
1026 | picking_obj=self.pool.get('stock.picking') |
1027 | @@ -110,15 +110,15 @@ |
1028 | 'move_id': move_id, |
1029 | }) |
1030 | wf_service = netsvc.LocalService("workflow") |
1031 | - wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) |
1032 | - wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) |
1033 | + wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr, context=context) |
1034 | + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr, context=context) |
1035 | if proc.move_id: |
1036 | move_obj.write(cr, uid, [proc.move_id.id], |
1037 | {'location_id':proc.location_id.id}) |
1038 | self.write(cr, uid, [proc.id], {'state':'running', 'message':_('Pulled from another location via procurement %d')%proc_id}) |
1039 | |
1040 | # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) |
1041 | - wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) |
1042 | + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr, context=context) |
1043 | return False |
1044 | |
1045 | procurement_order() |