Merge lp:~camptocamp/stock-logistic-flows/7.0-add_stock_picking_priority-afe into lp:stock-logistic-flows
- 7.0-add_stock_picking_priority-afe
- Merge into 7.0
Status: | Merged |
---|---|
Merged at revision: | 40 |
Proposed branch: | lp:~camptocamp/stock-logistic-flows/7.0-add_stock_picking_priority-afe |
Merge into: | lp:stock-logistic-flows |
Diff against target: |
499 lines (+468/-0) 6 files modified
stock_picking_priority/__init__.py (+22/-0) stock_picking_priority/__openerp__.py (+44/-0) stock_picking_priority/picking_priority.py (+121/-0) stock_picking_priority/picking_priority_demo.yml (+81/-0) stock_picking_priority/picking_priority_view.xml (+64/-0) stock_picking_priority/tests/test_picking_priority.yml (+136/-0) |
To merge this branch: | bzr merge lp:~camptocamp/stock-logistic-flows/7.0-add_stock_picking_priority-afe |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Lionel Sausin - Initiatives/Numérigraphe (community) | quick code review and testing | Needs Fixing | |
Brendan Clune (Logic Supply) (community) | Approve | ||
Nicolas Bessi - Camptocamp (community) | no test, code review | Approve | |
Guewen Baconnier @ Camptocamp | code review | Approve | |
Sandy Carter (http://www.savoirfairelinux.com) | code review | Needs Fixing | |
Review via email: mp+197206@code.launchpad.net |
Commit message
Description of the change
[ADD] stock_pricking_
Add a priority attribute to pickings.
This priority can be changed after the picking is confirmed and a
wizard can be run to recompute the availability of pickings
depending on the new priorities.
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote : | # |
- 42. By Alexandre Fayolle - camptocamp
-
[FIX] code formatting issue
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
> __openerp__: pep8 issues
> * spaces before the colon on l.56,57,
Fixed, thanks.
> picking_
> * l.123 you're not checking if ids is an int or a list, this could lead to a
> problem with search and an error on l.137
I respectfully disagree. The name of the parameter implies that expected type is a list. Adding such tests only clutters the code imo. Calling the function with a single integer would be a bug in the calling function.
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
> > picking_
> > * l.123 you're not checking if ids is an int or a list, this could lead to
> a
> > problem with search and an error on l.137
>
> I respectfully disagree. The name of the parameter implies that expected type
> is a list. Adding such tests only clutters the code imo. Calling the function
> with a single integer would be a bug in the calling function.
I agree with Alexandre. Only some methods of the ORM (write, unlink, browse, name_get, perm_read) do accept both, which is a regretted choice today AFAIK, but can no longer be changed to keep the backward compatibility. But all the other methods do not have to support boths.
LGTM, thanks
- 43. By Nicolas Bessi - Camptocamp
-
[PEP8]
- 44. By Nicolas Bessi - Camptocamp
-
[RM] unused variable
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote : | # |
Hello,
I agree with Alexandre and Guewen.
I generally do such tests in opposite situation,
when a public function is waiting for one id list,in and where nested form can do the call to a button, on change, webclient is not always consistent...
I fixed an indentation and remove unused _columns
LGTM
Brendan Clune (Logic Supply) (brendan-clune) wrote : | # |
Code looks good and we have done basic testing on our development environment.
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote : | # |
Technically,
The selection values ("[('0', 'Normal'),('1', 'Urgent'),('2', 'Very Urgent')]") could be usefully factored into a constant.
That would allow others to create modules to add other priorities.
Also, would a priority of "-1" be correctly placed after all positive priorities?
Functionally, it would be useful push this priority up to the sale orders too (but maybe that would belong to another module?)
Other than that it seems to work fine and it rocks.
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) : | # |
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
On 01/24/2014 04:09 PM, Lionel Sausin - Numérigraphe wrote:
> Review: Approve quick code review and testing
>
> Technically,
> The selection values ("[('0', 'Normal'),('1', 'Urgent'),('2', 'Very Urgent')]") could be usefully factored into a constant.
> That would allow others to create modules to add other priorities.
> Also, would a priority of "-1" be correctly placed after all positive priorities?
>
> Functionally, it would be useful push this priority up to the sale orders too (but maybe that would belong to another module?)
>
> Other than that it seems to work fine and it rocks.
>
This MP has been merged already. The changes you propose could be done
in a new proposal. I agree for the sales, in a new module to not add a
dependency on 'sale' on this module.
--
Guewen Baconnier
Business Solutions Software Developer
Camptocamp SA
PSE A, CH-1015 Lausanne
Phone: +41 21 619 10 39
Office: +41 21 619 10 10
http://
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote : | # |
Oh, I really thought I found it in the list of non-merged branches, but it's the end of the week and probably I should get a rest.
Sorry about the noise!
Preview Diff
1 | === added directory 'stock_picking_priority' |
2 | === added file 'stock_picking_priority/__init__.py' |
3 | --- stock_picking_priority/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ stock_picking_priority/__init__.py 2013-12-11 07:58:44 +0000 |
5 | @@ -0,0 +1,22 @@ |
6 | +# -*- coding: utf-8 -*- |
7 | +############################################################################## |
8 | +# |
9 | +# Author: Alexandre Fayolle |
10 | +# Copyright 2013 Camptocamp SA |
11 | +# |
12 | +# This program is free software: you can redistribute it and/or modify |
13 | +# it under the terms of the GNU Affero General Public License as |
14 | +# published by the Free Software Foundation, either version 3 of the |
15 | +# License, or (at your option) any later version. |
16 | +# |
17 | +# This program is distributed in the hope that it will be useful, |
18 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | +# GNU Affero General Public License for more details. |
21 | +# |
22 | +# You should have received a copy of the GNU Affero General Public License |
23 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
24 | +# |
25 | +############################################################################## |
26 | + |
27 | +from . import picking_priority |
28 | |
29 | === added file 'stock_picking_priority/__openerp__.py' |
30 | --- stock_picking_priority/__openerp__.py 1970-01-01 00:00:00 +0000 |
31 | +++ stock_picking_priority/__openerp__.py 2013-12-11 07:58:44 +0000 |
32 | @@ -0,0 +1,44 @@ |
33 | +# -*- coding: utf-8 -*- |
34 | +############################################################################## |
35 | +# |
36 | +# Author: Alexandre Fayolle |
37 | +# Copyright 2013 Camptocamp SA |
38 | +# |
39 | +# This program is free software: you can redistribute it and/or modify |
40 | +# it under the terms of the GNU Affero General Public License as |
41 | +# published by the Free Software Foundation, either version 3 of the |
42 | +# License, or (at your option) any later version. |
43 | +# |
44 | +# This program is distributed in the hope that it will be useful, |
45 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
46 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
47 | +# GNU Affero General Public License for more details. |
48 | +# |
49 | +# You should have received a copy of the GNU Affero General Public License |
50 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
51 | +# |
52 | +############################################################################## |
53 | + |
54 | + |
55 | +{ |
56 | + "name": "Picking priority", |
57 | + "version": "0.1", |
58 | + "depends": ['stock'], |
59 | + "author": "Camptocamp", |
60 | + 'license': 'AGPL-3', |
61 | + "description": """Add a priority attribute to pickings. |
62 | + |
63 | + This priority can be changed after the picking is confirmed and a |
64 | + wizard can be run to recompute the availability of pickings |
65 | + depending on the new priorities.""", |
66 | + "website": "http://www.camptocamp.com", |
67 | + "category": "Warehouse management", |
68 | + "demo": [ |
69 | + 'picking_priority_demo.yml', |
70 | + ], |
71 | + "data": ['picking_priority_view.xml', |
72 | + ], |
73 | + "test": ['tests/test_picking_priority.yml', |
74 | + ], |
75 | + "installable": True, |
76 | +} |
77 | |
78 | === added file 'stock_picking_priority/picking_priority.py' |
79 | --- stock_picking_priority/picking_priority.py 1970-01-01 00:00:00 +0000 |
80 | +++ stock_picking_priority/picking_priority.py 2013-12-11 07:58:44 +0000 |
81 | @@ -0,0 +1,121 @@ |
82 | +# -*- coding: utf-8 -*- |
83 | +############################################################################## |
84 | +# |
85 | +# Author: Alexandre Fayolle |
86 | +# Copyright 2013 Camptocamp SA |
87 | +# |
88 | +# This program is free software: you can redistribute it and/or modify |
89 | +# it under the terms of the GNU Affero General Public License as |
90 | +# published by the Free Software Foundation, either version 3 of the |
91 | +# License, or (at your option) any later version. |
92 | +# |
93 | +# This program is distributed in the hope that it will be useful, |
94 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
95 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
96 | +# GNU Affero General Public License for more details. |
97 | +# |
98 | +# You should have received a copy of the GNU Affero General Public License |
99 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
100 | +# |
101 | +############################################################################# |
102 | +import logging |
103 | + |
104 | +from openerp.osv import orm, osv, fields |
105 | +from openerp.tools.translate import _ |
106 | +_logger = logging.getLogger(__name__) |
107 | + |
108 | + |
109 | +class StockPicking(orm.Model): |
110 | + _inherit = "stock.picking" |
111 | + _columns = { |
112 | + 'priority': fields.selection([('0', 'Normal'), |
113 | + ('1', 'Urgent'), |
114 | + ('2', 'Very Urgent')], |
115 | + 'Priority', |
116 | + required=True, |
117 | + help='The priority of the picking'), |
118 | + } |
119 | + _defaults = { |
120 | + 'priority': '0', |
121 | + } |
122 | + |
123 | + def retry_assign_all(self, cr, uid, ids, context=None): |
124 | + domain = [('type', '!=', 'in'), |
125 | + ('move_lines', '!=', []), |
126 | + ('state', 'in', ('confirmed', 'assigned'))] |
127 | + if ids: |
128 | + domain += [('ids', 'in', ids)] |
129 | + picking_ids = self.search(cr, uid, domain, |
130 | + order='priority desc, min_date', |
131 | + context=context) |
132 | + _logger.info('cancelling pickings') |
133 | + cancelled_ids = self.cancel_assign(cr, uid, picking_ids, context) |
134 | + assigned_ids = [] |
135 | + errors = [] |
136 | + _logger.info('reassigning pickings') |
137 | + for picking_id in picking_ids: |
138 | + try: |
139 | + assigned_id = self.action_assign(cr, uid, [picking_id], |
140 | + context) |
141 | + assigned_ids.append(assigned_id) |
142 | + except osv.except_osv, exc: |
143 | + name = self.read(cr, uid, picking_id, ['name'], |
144 | + context=context)['name'] |
145 | + errors.append(u'%s: %s' % (name, exc.args[-1])) |
146 | + _logger.info('error in action_assign for picking %s: %s' |
147 | + % (name, exc)) |
148 | + if errors: |
149 | + message = '\n'.join(errors) |
150 | + raise orm.except_orm(_(u'Warning'), |
151 | + _(u'No operations validated due ' |
152 | + 'to the following errors:\n%s') % message) |
153 | + return cancelled_ids, assigned_ids |
154 | + |
155 | + |
156 | +class StockPickingOut(orm.Model): |
157 | + _inherit = 'stock.picking.out' |
158 | + _columns = { |
159 | + 'priority': fields.selection([('0', 'Normal'), |
160 | + ('1', 'Urgent'), |
161 | + ('2', 'Very Urgent')], |
162 | + 'Priority', |
163 | + required=True, |
164 | + help='The priority of the picking'), |
165 | + } |
166 | + _defaults = { |
167 | + 'priority': '0', |
168 | + } |
169 | + |
170 | + def retry_assign_all(self, cr, uid, ids, context=None): |
171 | + return self.pool.get('stock.picking').retry_assign_all(cr, uid, ids, |
172 | + context=context) |
173 | + |
174 | + |
175 | +class StockPickingIn(orm.Model): |
176 | + _inherit = 'stock.picking.in' |
177 | + _columns = { |
178 | + 'priority': fields.selection([('0', 'Normal'), |
179 | + ('1', 'Urgent'), |
180 | + ('2', 'Very Urgent')], |
181 | + 'Priority', |
182 | + required=True, |
183 | + help='The priority of the picking'), |
184 | + } |
185 | + _defaults = { |
186 | + 'priority': '0', |
187 | + } |
188 | + |
189 | + def retry_assign_all(self, cr, uid, ids, context=None): |
190 | + return self.pool.get('stock.picking').retry_assign_all(cr, uid, ids, |
191 | + context=context) |
192 | + |
193 | + |
194 | +class StockPickingRetryAvailability(orm.TransientModel): |
195 | + _name = "stock.picking.retry.availability" |
196 | + |
197 | + def action_retry_assign(self, cr, uid, ids, context=None): |
198 | + pick_obj = self.pool['stock.picking'] |
199 | + |
200 | + pick_obj.retry_assign_all(cr, uid, [], context=context) |
201 | + |
202 | + return {'type': 'ir.actions.act_window_close'} |
203 | |
204 | === added file 'stock_picking_priority/picking_priority_demo.yml' |
205 | --- stock_picking_priority/picking_priority_demo.yml 1970-01-01 00:00:00 +0000 |
206 | +++ stock_picking_priority/picking_priority_demo.yml 2013-12-11 07:58:44 +0000 |
207 | @@ -0,0 +1,81 @@ |
208 | +- |
209 | + Create 3 pickings and procurements for 3 M-Opt on shelf 1 due Dec 10, 1st and 20 |
210 | + M-Opt (product.product_product_10) |
211 | + initial stock is 8 units in shelf 1 (stock.stock_location_components) |
212 | +- |
213 | + !record {model: stock.picking.out, id: ship_mopt_1}: |
214 | + name: mopt1_1 |
215 | + move_lines: |
216 | + - product_id: product.product_product_10 |
217 | + product_qty: 3 |
218 | + product_uom: product.product_uom_unit |
219 | + location_id: stock.stock_location_components |
220 | + location_dest_id: stock.stock_location_output |
221 | + date: 2013-12-10 |
222 | + date_expected: 2013-12-10 |
223 | + procurements: |
224 | + - name: mopt1_1 |
225 | + origin: test |
226 | + date_planned: 2013-12-10 |
227 | + product_id: product.product_product_10 |
228 | + product_qty: 3 |
229 | + product_uom: product.product_uom_unit |
230 | + location_id: stock.stock_location_components |
231 | + procure_method: make_to_stock |
232 | +- |
233 | + !record {model: stock.picking.out, id: ship_mopt_2}: |
234 | + name: mopt1_2 |
235 | + move_lines: |
236 | + - product_id: product.product_product_10 |
237 | + product_qty: 3 |
238 | + product_uom: product.product_uom_unit |
239 | + location_id: stock.stock_location_components |
240 | + location_dest_id: stock.stock_location_output |
241 | + date: 2013-12-01 |
242 | + date_expected: 2013-12-01 |
243 | + procurements: |
244 | + - name: mopt1_2 |
245 | + origin: test |
246 | + date_planned: 2013-12-01 |
247 | + product_id: product.product_product_10 |
248 | + product_qty: 3 |
249 | + product_uom: product.product_uom_unit |
250 | + location_id: stock.stock_location_components |
251 | + procure_method: make_to_stock |
252 | +- |
253 | + !record {model: stock.picking.out, id: ship_mopt_3}: |
254 | + name: mopt1_3 |
255 | + move_lines: |
256 | + - product_id: product.product_product_10 |
257 | + product_qty: 3 |
258 | + product_uom: product.product_uom_unit |
259 | + location_id: stock.stock_location_components |
260 | + location_dest_id: stock.stock_location_output |
261 | + date: 2013-12-20 |
262 | + date_expected: 2013-12-20 |
263 | + procurements: |
264 | + - name: mopt1_3 |
265 | + origin: test |
266 | + date_planned: 2013-12-20 |
267 | + product_id: product.product_product_10 |
268 | + product_qty: 3 |
269 | + product_uom: product.product_uom_unit |
270 | + location_id: stock.stock_location_components |
271 | + procure_method: make_to_stock |
272 | +- |
273 | + Confirm the 3 pickings |
274 | +- |
275 | + !workflow {model: stock.picking, action: button_confirm, ref: ship_mopt_1} |
276 | +- |
277 | + !workflow {model: stock.picking, action: button_confirm, ref: ship_mopt_2} |
278 | +- |
279 | + !workflow {model: stock.picking, action: button_confirm, ref: ship_mopt_3} |
280 | +- |
281 | + Confirm the procurements |
282 | +- |
283 | + !python {model: procurement.order}: | |
284 | + procurement_ids = self.search(cr, uid, [('name', 'in', ('mopt1_1', 'mopt1_2', 'mopt1_3'))], context=context) |
285 | + from openerp import netsvc |
286 | + wf_service = netsvc.LocalService("workflow") |
287 | + for id in procurement_ids: |
288 | + wf_service.trg_validate(uid, 'procurement.order', id, 'button_confirm', cr) |
289 | |
290 | === added file 'stock_picking_priority/picking_priority_view.xml' |
291 | --- stock_picking_priority/picking_priority_view.xml 1970-01-01 00:00:00 +0000 |
292 | +++ stock_picking_priority/picking_priority_view.xml 2013-12-11 07:58:44 +0000 |
293 | @@ -0,0 +1,64 @@ |
294 | +<?xml version="1.0" encoding="utf-8"?> |
295 | +<openerp> |
296 | + <data> |
297 | + <record model="ir.ui.view" id="stock_picking_form"> |
298 | + <field name="name">stock.picking.form priority</field> |
299 | + <field name="model">stock.picking</field> |
300 | + <field name="inherit_id" ref="stock.view_picking_form"/> |
301 | + <field name="arch" type="xml"> |
302 | + <field name="date_done" position="after"> |
303 | + <field name="priority"/> |
304 | + </field> |
305 | + </field> |
306 | + </record> |
307 | + <record model="ir.ui.view" id="stock_picking_out_form"> |
308 | + <field name="name">stock.picking.out.form priority</field> |
309 | + <field name="model">stock.picking.out</field> |
310 | + <field name="inherit_id" ref="stock.view_picking_form"/> |
311 | + <field name="arch" type="xml"> |
312 | + <field name="date_done" position="after"> |
313 | + <field name="priority"/> |
314 | + </field> |
315 | + </field> |
316 | + </record> |
317 | + |
318 | + <act_window id="action_retry_assign" |
319 | + name="Retry picking assignment" |
320 | + res_model="stock.picking.retry.availability" |
321 | + view_type="form" |
322 | + view_mode="form" |
323 | + target="new" |
324 | + /> |
325 | + |
326 | + <menuitem id="menu_retry_availability" |
327 | + name="Recompute picking availability" |
328 | + parent="procurement.menu_stock_sched" |
329 | + sequence="40" |
330 | + action="action_retry_assign" |
331 | + groups="stock.group_stock_user,stock.group_stock_manager" |
332 | + /> |
333 | + |
334 | + <record model="ir.ui.view" id="picking_retry_availability_form"> |
335 | + <field name="name">stock.picking.retry.availability form</field> |
336 | + <field name="model">stock.picking.retry.availability</field> |
337 | + <field name="arch" type="xml"> |
338 | + <form string="Recompute picking availability" version="7.0"> |
339 | + <sheet> |
340 | + <p class="oe_grey"> |
341 | + This action will recompute the picking availability based on their |
342 | + priority. Before running it, make sure that you have changed the |
343 | + priority of at least one picking. |
344 | + </p> |
345 | + </sheet> |
346 | + <footer> |
347 | + <button name="action_retry_assign" string="Recompute availability" type="object" |
348 | + class="oe_highlight"/> |
349 | + or |
350 | + <button string="Cancel" class="oe_link" special="cancel" /> |
351 | + </footer> |
352 | + </form> |
353 | + </field> |
354 | + </record> |
355 | + |
356 | + </data> |
357 | +</openerp> |
358 | |
359 | === added directory 'stock_picking_priority/tests' |
360 | === added file 'stock_picking_priority/tests/test_picking_priority.yml' |
361 | --- stock_picking_priority/tests/test_picking_priority.yml 1970-01-01 00:00:00 +0000 |
362 | +++ stock_picking_priority/tests/test_picking_priority.yml 2013-12-11 07:58:44 +0000 |
363 | @@ -0,0 +1,136 @@ |
364 | +- |
365 | + Create 3 pickings and procurements for 10 M-Las on shelf 1 due Dec 10, 1st and 20 |
366 | + M-Las (product.product_product_11) |
367 | + initial stock is 26 units in shelf 1 (stock.stock_location_components) |
368 | +- |
369 | + !record {model: stock.picking.out, id: ship_mlas_1}: |
370 | + name: mlas1_1 |
371 | + move_lines: |
372 | + - product_id: product.product_product_11 |
373 | + product_qty: 10 |
374 | + product_uom: product.product_uom_unit |
375 | + location_id: stock.stock_location_components |
376 | + location_dest_id: stock.stock_location_output |
377 | + date: 2013-12-20 |
378 | + date_expected: 2013-12-20 |
379 | + procurements: |
380 | + - name: mlas1_1 |
381 | + origin: test |
382 | + date_planned: 2013-12-20 |
383 | + product_id: product.product_product_11 |
384 | + product_qty: 10 |
385 | + product_uom: product.product_uom_unit |
386 | + location_id: stock.stock_location_components |
387 | + procure_method: make_to_stock |
388 | +- |
389 | + !record {model: stock.picking.out, id: ship_mlas_2}: |
390 | + name: mlas1_2 |
391 | + move_lines: |
392 | + - product_id: product.product_product_11 |
393 | + product_qty: 10 |
394 | + product_uom: product.product_uom_unit |
395 | + location_id: stock.stock_location_components |
396 | + location_dest_id: stock.stock_location_output |
397 | + date: 2013-12-01 |
398 | + date_expected: 2013-12-01 |
399 | + procurements: |
400 | + - name: mlas1_2 |
401 | + origin: test |
402 | + date_planned: 2013-12-01 |
403 | + product_id: product.product_product_11 |
404 | + product_qty: 10 |
405 | + product_uom: product.product_uom_unit |
406 | + location_id: stock.stock_location_components |
407 | + procure_method: make_to_stock |
408 | +- |
409 | + !record {model: stock.picking.out, id: ship_mlas_3}: |
410 | + name: mlas1_3 |
411 | + move_lines: |
412 | + - product_id: product.product_product_11 |
413 | + product_qty: 10 |
414 | + product_uom: product.product_uom_unit |
415 | + location_id: stock.stock_location_components |
416 | + location_dest_id: stock.stock_location_output |
417 | + date: 2013-12-10 |
418 | + date_expected: 2013-12-10 |
419 | + procurements: |
420 | + - name: mlas1_3 |
421 | + origin: test |
422 | + date_planned: 2013-12-10 |
423 | + product_id: product.product_product_11 |
424 | + product_qty: 10 |
425 | + product_uom: product.product_uom_unit |
426 | + location_id: stock.stock_location_components |
427 | + procure_method: make_to_stock |
428 | +- |
429 | + Confirm the 3 pickings |
430 | +- |
431 | + !workflow {model: stock.picking, action: button_confirm, ref: ship_mlas_1} |
432 | +- |
433 | + !workflow {model: stock.picking, action: button_confirm, ref: ship_mlas_2} |
434 | +- |
435 | + !workflow {model: stock.picking, action: button_confirm, ref: ship_mlas_3} |
436 | +- |
437 | + Confirm the procurements |
438 | +- |
439 | + !python {model: procurement.order}: | |
440 | + procurement_ids = self.search(cr, uid, [('name', 'in', ('mlas1_1', 'mlas1_2', 'mlas1_3'))], context=context) |
441 | + from openerp import netsvc |
442 | + wf_service = netsvc.LocalService("workflow") |
443 | + for id in procurement_ids: |
444 | + wf_service.trg_validate(uid, 'procurement.order', id, 'button_confirm', cr) |
445 | +- |
446 | + I run the scheduler. |
447 | +- |
448 | + !python {model: procurement.order}: | |
449 | + self.run_scheduler(cr, uid) |
450 | +- |
451 | + Check the procurement states |
452 | +- |
453 | + !python {model: procurement.order}: | |
454 | + procurement_ids = self.search(cr, uid, [('name', 'in', ('mlas1_1', 'mlas1_2', 'mlas1_3'))], context=context) |
455 | + states = {} |
456 | + for proc in self.browse(cr, uid, procurement_ids, context=context): |
457 | + states[proc.name] = proc.state |
458 | + expected = {'mlas1_1': 'exception', 'mlas1_2': 'ready', 'mlas1_3': 'ready'} |
459 | + assert states == expected, 'wrong procurement states: %s (expected %s)' % (states, expected) |
460 | +- |
461 | + Check the picking states |
462 | +- |
463 | + !python {model: stock.picking}: | |
464 | + picking_ids = [ref("ship_mlas_1"), ref("ship_mlas_2"), ref("ship_mlas_3")] |
465 | + states = {} |
466 | + for pick in self.browse(cr, uid, picking_ids, context=context): |
467 | + states[pick.id] = pick.state |
468 | + expected = {ref("ship_mlas_1"): 'confirmed', ref("ship_mlas_2"): 'assigned', ref("ship_mlas_3"): 'assigned'} |
469 | + assert states == expected, 'wrong picking states %s (expected: %s)' % (states, expected) |
470 | +- |
471 | + I set the priority of picking ship_mlas_1 to Urgent |
472 | +- |
473 | + !python {model: stock.picking.out}: | |
474 | + self.write(cr, uid, ref("ship_mlas_1"), {'priority': '1'}, context=context) |
475 | +- |
476 | + I retry the assignments |
477 | +- |
478 | + !python {model: stock.picking.out}: | |
479 | + self.retry_assign_all(cr, uid, [], context=context) |
480 | +- |
481 | + Check the procurement states |
482 | +- |
483 | + !python {model: procurement.order}: | |
484 | + procurement_ids = self.search(cr, uid, [('name', 'in', ('mlas1_1', 'mlas1_2', 'mlas1_3'))], context=context) |
485 | + states = {} |
486 | + for proc in self.browse(cr, uid, procurement_ids, context=context): |
487 | + states[proc.name] = proc.state |
488 | + expected = {'mlas1_1': 'exception', 'mlas1_2': 'ready', 'mlas1_3': 'ready'} |
489 | + assert states == expected, 'wrong procurement states: %s (expected %s)' % (states, expected) |
490 | +- |
491 | + Check the picking states |
492 | +- |
493 | + !python {model: stock.picking}: | |
494 | + picking_ids = [ref("ship_mlas_1"), ref("ship_mlas_2"), ref("ship_mlas_3")] |
495 | + states = {} |
496 | + for pick in self.browse(cr, uid, picking_ids, context=context): |
497 | + states[pick.id] = pick.state |
498 | + expected = {ref("ship_mlas_1"): 'assigned', ref("ship_mlas_2"): 'assigned', ref("ship_mlas_3"): 'confirmed'} |
499 | + assert states == expected, 'wrong picking states %s (expected: %s)' % (states, expected) |
__openerp__: pep8 issues 58,59,66, 67,68,71
* spaces before the colon on l.56,57,
picking_ priority. py:
* l.123 you're not checking if ids is an int or a list, this could lead to a problem with search and an error on l.137