Merge lp:~unifield-team/unifield-server/us-574 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 3646
Proposed branch: lp:~unifield-team/unifield-server/us-574
Merge into: lp:unifield-server
Diff against target: 812 lines (+340/-95)
15 files modified
bin/addons/sale_override/sale.py (+1/-1)
bin/addons/sourcing/__init__.py (+1/-0)
bin/addons/sourcing/po_automation_config.py (+97/-0)
bin/addons/sourcing/sale_order_line.py (+29/-6)
bin/addons/sourcing/sourcing_view.xml (+30/-1)
bin/addons/sourcing/wizard/multiple_sourcing.py (+165/-70)
bin/addons/sourcing/wizard/multiple_sourcing_view.xml (+8/-8)
bin/addons/unifield_tests/tests/resourcing.py (+1/-1)
bin/addons/unifield_tests/tests/test_pick_convert_to_standard.py (+1/-1)
bin/addons/unifield_tests/tests/test_sync_cancel_in.py (+1/-1)
bin/addons/unifield_tests/tests/test_uf_2490_one_rfq.py (+1/-1)
bin/addons/unifield_tests/tests/test_uftp_324.py (+1/-1)
bin/addons/unifield_tests/tests/test_uftp_326.py (+1/-1)
bin/addons/unifield_tests/tests/test_us_311.py (+2/-2)
bin/addons/unifield_tests/tests/test_utp_1007.py (+1/-1)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us-574
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+289338@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/sale_override/sale.py'
2--- bin/addons/sale_override/sale.py 2016-02-19 10:57:13 +0000
3+++ bin/addons/sale_override/sale.py 2016-03-17 10:23:08 +0000
4@@ -2354,7 +2354,7 @@
5 res = super(sale_order_line, self).unlink(cr, uid, ids, context=context)
6
7 if lines_to_check:
8- self.check_confirm_order(cr, uid, lines_to_check, context=context)
9+ self.check_confirm_order(cr, uid, lines_to_check, run_scheduler=False, ontext=context)
10
11 return res
12
13
14=== modified file 'bin/addons/sourcing/__init__.py'
15--- bin/addons/sourcing/__init__.py 2014-03-10 09:56:10 +0000
16+++ bin/addons/sourcing/__init__.py 2016-03-17 10:23:08 +0000
17@@ -28,5 +28,6 @@
18 import purchase_order
19 import res_partner
20 import sale_order
21+import po_automation_config
22
23 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
24
25=== added file 'bin/addons/sourcing/po_automation_config.py'
26--- bin/addons/sourcing/po_automation_config.py 1970-01-01 00:00:00 +0000
27+++ bin/addons/sourcing/po_automation_config.py 2016-03-17 10:23:08 +0000
28@@ -0,0 +1,97 @@
29+# -*- coding: utf-8 -*-
30+##############################################################################
31+#
32+# OpenERP, Open Source Management Solution
33+# Copyright (C) 2014 TeMPO Consulting, MSF
34+#
35+# This program is free software: you can redistribute it and/or modify
36+# it under the terms of the GNU Affero General Public License as
37+# published by the Free Software Foundation, either version 3 of the
38+# License, or (at your option) any later version.
39+#
40+# This program is distributed in the hope that it will be useful,
41+# but WITHOUT ANY WARRANTY; without even the implied warranty of
42+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43+# GNU Affero General Public License for more details.
44+#
45+# You should have received a copy of the GNU Affero General Public License
46+# along with this program. If not, see <http://www.gnu.org/licenses/>.
47+#
48+##############################################################################
49+
50+from osv import fields
51+from osv import osv
52+
53+from tools.translate import _
54+
55+
56+class po_automation_config(osv.osv):
57+ _name = 'po.automation.config'
58+
59+ _columns = {
60+ 'name': fields.selection(
61+ selection=[
62+ ('yes', 'Yes'),
63+ ('no', 'No'),
64+ ],
65+ string='Run scheduler automatically ?',
66+ required=True,
67+ ),
68+ }
69+
70+ _defaults = {
71+ 'name': 'yes',
72+ }
73+
74+ def create(self, cr, uid, vals, context=None):
75+ """
76+ Check that there is only one PO Automation configuration record
77+ :param cr: Cursor to the database
78+ :param uid: ID of the res.users that calls this method
79+ :param vals: Values for the new created record
80+ :param context: Context of the call
81+ :return: ID of the new po.automation.config record
82+ """
83+ if context is None:
84+ context = {}
85+
86+ if self.search(cr, uid, [], limit=1, context=context):
87+ raise osv.except_osv(
88+ _('Error'),
89+ _('It is forbidden to have more than one PO Automation configuration record'),
90+ )
91+
92+ return super(po_automation_config, self).create(cr, uid, vals, context=context)
93+
94+ def save(self, cr, uid, ids, context=None):
95+ """
96+ Just save the value on the PO Automation configuration record
97+ :param cr: Cursor to the database
98+ :param uid: ID of the res.users that calls the method
99+ :param ids: List of ID of po.automation.config to save
100+ :param context: Context of the call
101+ :return: True
102+ """
103+ return True
104+
105+ def get_po_automation(self, cr, uid, context=None):
106+ """
107+ Return True if the configuration of the PO Automation is 'Yes', else, return False
108+ :param cr: Cursor to the database
109+ :param uid: ID of the res.users that calls this method
110+ :param context: Context of the call
111+ :return: True or False
112+ """
113+ if context is None:
114+ context = {}
115+
116+ conf_ids = self.search(cr, uid, [], limit=1, context=context)
117+ for conf in self.browse(cr, uid, conf_ids, context=context):
118+ if conf.name == 'no':
119+ return False
120+
121+ return True
122+
123+po_automation_config()
124+
125+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
126
127=== modified file 'bin/addons/sourcing/sale_order_line.py'
128--- bin/addons/sourcing/sale_order_line.py 2016-01-08 14:11:50 +0000
129+++ bin/addons/sourcing/sale_order_line.py 2016-03-17 10:23:08 +0000
130@@ -1014,7 +1014,7 @@
131
132 return result
133
134- def confirmLine(self, cr, uid, ids, context=None):
135+ def confirmLine(self, cr, uid, ids, run_scheduler=False, context=None):
136 """
137 Set the line as confirmed and check if all lines
138 of the FO/IR are confirmed. If yes, launch the
139@@ -1023,6 +1023,8 @@
140 :param cr: Cursor to the database
141 :param uid: ID of the user that runs the method
142 :param ids: List of IDs of sale.order.line to check
143+ :param run_scheduler: If set to True, after all FO/IR are confirmed,
144+ run the Auto POs creation scheduler
145 :param context: Context of the call
146
147 :return Raise an error or True
148@@ -1030,6 +1032,7 @@
149 """
150 # Objects
151 order_obj = self.pool.get('sale.order')
152+ po_auto_obj = self.pool.get('po.automation.config')
153
154 if context is None:
155 context = {}
156@@ -1121,13 +1124,22 @@
157 _('You cannot confirm the sourcing of a line to an internal customer with an internal supplier.'),
158 )
159
160- self.check_confirm_order(cr, uid, ids, context=context)
161+ if not run_scheduler:
162+ run_scheduler = po_auto_obj.get_po_automation(cr, uid, context=context)
163+
164+ self.check_confirm_order(cr, uid, ids, run_scheduler=run_scheduler, context=context)
165
166 return True
167
168- def check_confirm_order(self, cr, uid, ids, context=None):
169+ def check_confirm_order(self, cr, uid, ids, run_scheduler=False, context=None):
170 """
171 Run the confirmation of the FO/IR if all lines are confirmed
172+ :param cr: Cursor to the database
173+ :param uid: ID of the res.users that calls the method
174+ :param ids: List of ID of sale.order.line to check
175+ :param run_scheduler: If set to True, after all FO/IR are confirmed,
176+ run the Auto POs creation scheduler
177+ :praam context: Context of the call
178 """
179 # Objects
180 order_obj = self.pool.get('sale.order')
181@@ -1198,12 +1210,16 @@
182
183 for order_id in order_ids:
184 self.infolog(cr, uid, "All lines of the FO/IR id:%s have been sourced" % order_id)
185- thread = threading.Thread(target=self.confirmOrder, args=(cr, uid, order_ids, state_to_use, context))
186+ thread = threading.Thread(
187+ target=self.confirmOrder,
188+ args=(cr, uid, order_ids, state_to_use, run_scheduler, context)
189+ )
190 thread.start()
191
192 return True
193
194- def confirmOrder(self, cr, uid, order_ids, state_to_use, context=None, new_cursor=True):
195+ def confirmOrder(self, cr, uid, order_ids, state_to_use, run_scheduler=False,
196+ context=None, new_cursor=True):
197 """
198 Confirm the order specified in the parameter.
199
200@@ -1211,6 +1227,8 @@
201 :param uid: ID of the user that runs the method
202 :param order_id: List of ID of the orders to confirm
203 :param state_to_use: Determine if the order is an IR or a FO
204+ :param run_scheduler: If set to True, after all FO/IR are confirmed,
205+ run the Auto POs creation scheduler
206 :param context: Context of the call
207 :param new_cursor: Use a new DB cursor or not
208
209@@ -1219,7 +1237,7 @@
210 """
211 if not context:
212 context = {}
213-
214+ wiz_obj = self.pool.get('procurement.purchase.compute.all')
215 wf_service = netsvc.LocalService("workflow")
216
217 if new_cursor:
218@@ -1263,6 +1281,11 @@
219 'error': misc.ustr(e),
220 }, context=context)
221
222+ if run_scheduler:
223+ # Run Auto POs creation scheduler
224+ wiz_id = wiz_obj.create(cr, uid, {}, context=context)
225+ wiz_obj.procure_calculation_purchase(cr, uid, wiz_id, context=context)
226+
227 if new_cursor:
228 cr.commit()
229 cr.close(True)
230
231=== modified file 'bin/addons/sourcing/sourcing_view.xml'
232--- bin/addons/sourcing/sourcing_view.xml 2014-09-29 12:38:06 +0000
233+++ bin/addons/sourcing/sourcing_view.xml 2016-03-17 10:23:08 +0000
234@@ -191,7 +191,36 @@
235 target="new"
236 key2="client_action_multi"
237 empty_ids="1"
238- id="action_compute_schedulers_sourcing"/>
239+ id="action_compute_schedulers_sourcing"/>
240+
241+ <!-- PO Automation -->
242+ <record id="po_automation_config_data" model="po.automation.config">
243+ <field name="name">yes</field>
244+ </record>
245+
246+ <record id="po_automation_config_tree_view" model="ir.ui.view">
247+ <field name="name">po.automation.config.tree.view</field>
248+ <field name="model">po.automation.config</field>
249+ <field name="type">tree</field>
250+ <field name="arch" type="xml">
251+ <tree string="PO Automation configuration" hide_delete_button="True" hide_new_button="True" editable="top">
252+ <field name="name" />
253+ </tree>
254+ </field>
255+ </record>
256+
257+ <record id="action_po_automation_config" model="ir.actions.act_window">
258+ <field name="name">PO Automation</field>
259+ <field name="res_model">po.automation.config</field>
260+ <field name="view_type">form</field>
261+ <field name="view_mode">tree,form</field>
262+ </record>
263+
264+ <menuitem
265+ id="menu_action_po_automation_config"
266+ action="action_po_automation_config"
267+ parent="base.menu_sale_config_sales"
268+ name="PO Automation" />
269
270 </data>
271 </openerp>
272
273=== modified file 'bin/addons/sourcing/wizard/multiple_sourcing.py'
274--- bin/addons/sourcing/wizard/multiple_sourcing.py 2015-03-02 20:31:25 +0000
275+++ bin/addons/sourcing/wizard/multiple_sourcing.py 2016-03-17 10:23:08 +0000
276@@ -23,12 +23,13 @@
277 from osv import osv
278 from tools.translate import _
279
280-from sourcing.sale_order_line import _SELECTION_PO_CFT
281+from ..sale_order_line import _SELECTION_PO_CFT
282
283 _SELECTION_TYPE = [
284 ('make_to_stock', 'from stock'),
285 ('make_to_order', 'on order'), ]
286
287+
288 class multiple_sourcing_wizard(osv.osv_memory):
289 _name = 'multiple.sourcing.wizard'
290
291@@ -40,6 +41,10 @@
292 'wizard_id',
293 string='Sourcing lines',
294 ),
295+ 'run_scheduler': fields.boolean(
296+ string='Run scheduler ?',
297+ readonly="True",
298+ ),
299 'type': fields.selection(
300 _SELECTION_TYPE,
301 string='Procurement Method',
302@@ -71,8 +76,17 @@
303 def default_get(self, cr, uid, fields_list, context=None):
304 """
305 Set lines with the selected lines to source
306+ :param cr: Cursor to the database
307+ :param uid: ID of the res.users that calls the method
308+ :param fields_list: List of field names to fill with default value
309+ :param context: Context of the call
310+ :return: A dictionary that contains the field name as key and the default value for this field as value.
311 """
312- if not context:
313+ sol_obj = self.pool.get('sale.order.line')
314+ user_obj = self.pool.get('res.users')
315+ po_auto_cfg_obj = self.pool.get('po.automation.config')
316+
317+ if context is None:
318 context = {}
319
320 active_ids = context.get('active_ids')
321@@ -81,18 +95,20 @@
322
323 res = super(multiple_sourcing_wizard, self).default_get(cr, uid, fields_list, context=context)
324
325- res['line_ids'] = []
326- res['error_on_lines'] = False
327+ res.update({
328+ 'line_ids': [],
329+ 'error_on_lines': False,
330+ 'run_scheduler': po_auto_cfg_obj.get_po_automation(cr, uid, context=context),
331+ 'type': 'make_to_stock',
332+ 'po_cft': False,
333+ })
334
335 # Check if all lines are with the same type, then set that type, otherwise set make_to_order
336-
337- # Ignore all lines which have already been sourced, if there are some alredy sourced lines, a message
338+ # Ignore all lines which have already been sourced, if there are some already sourced lines, a message
339 # will be displayed at the top of the wizard
340- res['type'] = 'make_to_stock'
341- res['po_cft'] = False
342- loc = -1 # first location flag
343- supplier = -1 # first location flag
344- for line in self.pool.get('sale.order.line').browse(cr, uid, active_ids, context=context):
345+ loc = -1 # first location flag
346+ supplier = -1 # first location flag
347+ for line in sol_obj.browse(cr, uid, active_ids, context=context):
348 if line.state == 'draft' and line.sale_order_state == 'validated':
349 res['line_ids'].append(line.id)
350 else:
351@@ -102,52 +118,70 @@
352 res['type'] = 'make_to_order'
353 res['po_cft'] = 'po'
354
355- loc = False # always set False for location if source on order
356+ loc = False # always set False for location if source on order
357 if not line.supplier:
358 supplier = False
359 else:
360 temp = line.supplier.id
361- if supplier == -1: # first location
362+ if supplier == -1: # first location
363 supplier = temp
364 elif supplier != temp:
365 supplier = False
366 else:
367- # UTP-1021: Calculate the location to set into the wizard view if all lines are sourced from the same location
368- supplier = False # if source from stock, always set False to partner
369+ # UTP-1021: Calculate the location to set into the wizard view if all lines
370+ # are sourced from the same location
371+ supplier = False # if source from stock, always set False to partner
372 temploc = line.location_id.id
373- if loc == -1: # first location
374+ if loc == -1: # first location
375 loc = temploc
376 elif temploc != loc:
377 loc = False
378
379- # UTP-1021: Set default values on openning the wizard
380+ # UTP-1021: Set default values on opening the wizard
381 if loc != -1:
382 res['location_id'] = loc
383 if supplier != -1:
384 res['supplier_id'] = supplier
385
386 if not res['line_ids']:
387- raise osv.except_osv(_('Error'), _('No non-sourced lines are selected. Please select non-sourced lines'))
388+ raise osv.except_osv(
389+ _('Error'),
390+ _('No non-sourced lines are selected. Please select non-sourced lines'),
391+ )
392
393- res['company_id'] = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
394+ res['company_id'] = user_obj.browse(cr, uid, uid, context=context).company_id.id
395
396 return res
397
398 def save_lines(self, cr, uid, ids, context=None):
399- '''
400- Set values to sourcing lines
401- '''
402- if not context:
403+ """
404+ Set values defined on the wizard to the lines of the wizard.
405+ :param cr: Cursor to the database
406+ :param uid: ID of the res.users that calls the method
407+ :param ids: List of ID of multiple.sourcing.wizard to save
408+ :param context: Context of the call
409+ :return: Close the wizard window
410+ """
411+ line_obj = self.pool.get('sale.order.line')
412+
413+ if context is None:
414 context = {}
415
416- line_obj = self.pool.get('sale.order.line')
417+ if isinstance(ids, (int, long)):
418+ ids = [ids]
419
420 for wiz in self.browse(cr, uid, ids, context=context):
421 if wiz.type == 'make_to_order':
422 if not wiz.po_cft:
423- raise osv.except_osv(_('Error'), _('The Procurement method should be filled !'))
424+ raise osv.except_osv(
425+ _('Error'),
426+ _('The Procurement method should be filled !'),
427+ )
428 elif wiz.po_cft != 'cft' and not wiz.supplier_id:
429- raise osv.except_osv(_('Error'), _('You should select a supplier !'))
430+ raise osv.except_osv(
431+ _('Error'),
432+ _('You should select a supplier !'),
433+ )
434
435 errors = {}
436 for line in wiz.line_ids:
437@@ -157,11 +191,12 @@
438 errors[err_msg].append((line.id, '%s of %s' % (line.line_number, line.order_id.name)))
439 else:
440 try:
441- line_obj.write(cr, uid, [line.id], {'type': wiz.type,
442- 'po_cft': wiz.po_cft,
443- 'supplier': wiz.supplier_id and wiz.supplier_id.id or False,
444- 'location_id': wiz.location_id.id and wiz.location_id.id or False},
445- context=context)
446+ line_obj.write(cr, uid, [line.id], {
447+ 'type': wiz.type,
448+ 'po_cft': wiz.po_cft,
449+ 'supplier': wiz.supplier_id and wiz.supplier_id.id or False,
450+ 'location_id': wiz.location_id.id and wiz.location_id.id or False,
451+ }, context=context)
452 except osv.except_osv, e:
453 errors.setdefault(e.value, [])
454 errors[e.value].append((line.id, '%s of %s' % (line.line_number, line.order_id.name)))
455@@ -184,35 +219,52 @@
456 return {'type': 'ir.actions.act_window_close'}
457
458 def source_lines(self, cr, uid, ids, context=None):
459- '''
460- Confirm all lines
461- '''
462+ """
463+ Confirm the sourcing of all the sale.order.line contained in the wizards.
464+ :param cr: Cursor to the database
465+ :param uid: ID of the res.users that calls the method
466+ :param ids: List of ID of multiple.sourcing.wizard that contain lines to confirm
467+ :param context: Context of the call
468+ :return: Close the wizard window
469+ """
470 # Objects
471 line_obj = self.pool.get('sale.order.line')
472+ po_auto_cfg_obj = self.pool.get('po.automation.config')
473
474- if not context:
475+ if context is None:
476 context = {}
477
478 if isinstance(ids, (int, long)):
479 ids = [ids]
480
481 lines_to_confirm = []
482+ run_scheduler = True
483
484 for wiz in self.browse(cr, uid, ids, context=context):
485+ if wiz.run_scheduler:
486+ run_scheduler = wiz.run_scheduler
487+ else:
488+ run_scheduler = po_auto_cfg_obj.get_po_automation(cr, uid, context=context)
489 for line in wiz.line_ids:
490 if line.order_id.procurement_request and wiz.po_cft == 'dpo':
491- raise osv.except_osv(_('Error'), _('You cannot choose Direct Purchase Order as method to source Internal Request lines.'))
492+ raise osv.except_osv(_('Error'), _(
493+ 'You cannot choose Direct Purchase Order as method to source Internal Request lines.'))
494 lines_to_confirm.append(line.id)
495
496- line_obj.confirmLine(cr, uid, lines_to_confirm, context=context)
497+ line_obj.confirmLine(cr, uid, lines_to_confirm, run_scheduler=run_scheduler, context=context)
498
499 return {'type': 'ir.actions.act_window_close'}
500
501 def save_source_lines(self, cr, uid, ids, context=None):
502- '''
503- Set values to sourcing lines and confirm them
504- '''
505- if not context:
506+ """
507+ Set values on sale.order.lines of the wizard and confirm them
508+ :param cr: Cursor to the database
509+ :param uid: ID of the res.users that calls the method
510+ :param ids: List of ID of multiple.sourcing.wizard that contain the lines to save and confirmed
511+ :param context: Context of the call
512+ :return: Close the wizard window
513+ """
514+ if context is None:
515 context = {}
516
517 self.save_lines(cr, uid, ids, context=context)
518@@ -221,9 +273,22 @@
519 return {'type': 'ir.actions.act_window_close'}
520
521 def change_type(self, cr, uid, ids, l_type, context=None):
522- '''
523+ """
524 Unset the other fields if the type is 'from stock'
525- '''
526+ :param cr: Cursor to the database
527+ :param uid: ID of the res.users that calls the method
528+ :param ids: List of ID of multiple.sourcing.wizard on which field values has to be changed
529+ :param l_type: Value of the field 'type'
530+ :param context: Context of the call
531+ :return: A dictionary that contains the field names to change as keys and the value for these fields as values.
532+ """
533+ global stock_loc
534+ wh_obj = self.pool.get('stock.warehouse')
535+ sol_obj = self.pool.get('sale.order.line')
536+
537+ if context is None:
538+ context = {}
539+
540 if l_type == 'make_to_order':
541 return {'value': {'location_id': False}}
542
543@@ -237,37 +302,53 @@
544 if not active_ids:
545 return res
546
547- wh_obj = self.pool.get('stock.warehouse')
548+ # Get the default stock location of the default warehouse
549 wh_ids = wh_obj.search(cr, uid, [], context=context)
550+ stock_loc = False
551 if wh_ids:
552 stock_loc = wh_obj.browse(cr, uid, wh_ids[0], context=context).lot_stock_id.id
553
554 all_line_empty = True
555- for line in self.pool.get('sale.order.line').browse(cr, uid, active_ids, context=context):
556+ for line in sol_obj.browse(cr, uid, active_ids, context=context):
557 if line.location_id and line.location_id.id != stock_loc:
558 all_line_empty = False
559
560- if all_line_empty: # by default, and if all lines has no location, then set by default Stock
561+ if all_line_empty: # by default, and if all lines has no location, then set by default Stock
562 return {'value': {'po_cft': False, 'supplier_id': False, 'location_id': stock_loc}}
563+
564 return {'value': {'po_cft': False, 'supplier_id': False}}
565
566 def change_po_cft(self, cr, uid, ids, po_cft, context=None):
567- '''
568- Unset the supplier if tender is choosen
569- '''
570+ """
571+ Unset the supplier if tender is choose
572+ :param cr: Cursor to the database
573+ :param uid: ID of the res.users that calls the method
574+ :param ids: List of ID of multiple.sourcing.wizard on which field values has to be changed
575+ :param po_cft: Value of the field 'po_cft'
576+ :param context: Context of the call
577+ :return: A dictionary that contains the field names to change as keys and the value for these fields as values.
578+ """
579 if po_cft == 'cft':
580 return {'value': {'supplier_id': False}}
581
582 return {}
583
584 def change_supplier(self, cr, uid, ids, supplier, context=None):
585- '''
586+ """
587 Check if the partner has an address.
588- '''
589+ :param cr: Cursor to the database
590+ :param uid: ID of the res.users that calls the method
591+ :param ids: List of ID of multiple.sourcing.wizard on which field values has to be changed
592+ :param supplier: Value of the field 'supplier_id'
593+ :param context: Context of the call
594+ :return: A dictionary that contains the field names to change as keys and the value for these fields as values.
595+ """
596 partner_obj = self.pool.get('res.partner')
597
598+ if context is None:
599+ context = {}
600+
601 result = {}
602-
603 if supplier:
604 partner = partner_obj.browse(cr, uid, supplier, context)
605 # Check if the partner has addresses
606@@ -279,28 +360,42 @@
607 return result
608
609 def change_location(self, cr, uid, ids, location_id, line_ids, context=None):
610- res = {'value': {}}
611- if not location_id:
612- return res
613-
614- if not line_ids or not line_ids[0] or not line_ids[0][2]:
615- return res
616-
617+ """
618+ Update the stock value of lines according to given location.
619+ :param cr: Cursor to the database
620+ :param uid: ID of the user that calls this method
621+ :param ids: List of ID of multiple.sourcing.wizard that contain lines to change
622+ :param location_id: ID of stock.location selected in the wizard
623+ :param line_ids: List of ID of sale.order.line contained in the multiple.sourcing.wizard
624+ :param context: Context of the call
625+ :return: A dictionary that contains the field names to change as keys and the value for these fields as values.
626+ """
627 line_obj = self.pool.get('sale.order.line')
628+
629+ res = {}
630+ if not location_id or not line_ids or not line_ids[0] or not line_ids[0][2]:
631+ return res
632+
633 active_ids = line_ids[0][2]
634
635- context = {}
636- context.update({'from_multiple_line_sourcing': False})
637- for line in self.pool.get('sale.order.line').browse(cr, uid, active_ids, context=context):
638- line_obj.write(cr, uid, [line.id], {'type': 'make_to_stock',
639- 'po_cft': False,
640- 'supplier': False,
641- 'location_id': location_id}, # UTP-1021: Update loc and ask the view to refresh
642- context=context)
643- res = {'value':
644- {'line_ids': active_ids, 'error_on_lines': False, 'po_cft':False,}}
645- return res
646+ context = {
647+ 'from_multiple_line_sourcing': False
648+ }
649+ for line in line_obj.browse(cr, uid, active_ids, context=context):
650+ line_obj.write(cr, uid, [line.id], {
651+ 'type': 'make_to_stock',
652+ 'po_cft': False,
653+ 'supplier': False,
654+ 'location_id': location_id,
655+ }, context=context) # UTP-1021: Update loc and ask the view to refresh
656
657+ return {
658+ 'value': {
659+ 'line_ids': active_ids,
660+ 'error_on_lines': False,
661+ 'po_cft': False,
662+ },
663+ }
664
665 multiple_sourcing_wizard()
666
667
668=== modified file 'bin/addons/sourcing/wizard/multiple_sourcing_view.xml'
669--- bin/addons/sourcing/wizard/multiple_sourcing_view.xml 2015-03-02 20:31:25 +0000
670+++ bin/addons/sourcing/wizard/multiple_sourcing_view.xml 2016-03-17 10:23:08 +0000
671@@ -21,20 +21,20 @@
672 on_change="change_type(type)"/>
673 <field name="po_cft" attrs="{'readonly': [('type', '=', 'make_to_stock')]}"
674 on_change="change_po_cft(po_cft)"/>
675+ <field name="run_scheduler" />
676 <separator colspan="4" string="Supplier selection" />
677 <field name="supplier_id"
678 domain="[('id', '!=', company_id), ('available_for_dpo', '=', po_cft), ('line_contains_fo', '=', line_ids)]"
679 attrs="{'readonly': ['|', ('po_cft', '=', 'cft'), ('type', '=', 'make_to_stock')]}"
680 on_change="change_supplier(supplier_id)"
681 />
682-
683-
684- <field name="location_id" domain="[('usage', '=', 'internal'), ('quarantine_location', '=', False),
685- ('scrap_location', '=', False), ('destruction_location', '=', False),
686- ('output_ok', '=', False), ('input_ok', '=', False)]"
687- attrs="{'readonly': [('type', '!=', 'make_to_stock')]}"
688- on_change="change_location(location_id, line_ids)" />
689-
690+ <field name="location_id"
691+ domain="[('usage', '=', 'internal'), ('quarantine_location', '=', False),
692+ ('scrap_location', '=', False), ('destruction_location', '=', False),
693+ ('output_ok', '=', False), ('input_ok', '=', False)]"
694+ attrs="{'readonly': [('type', '!=', 'make_to_stock')]}"
695+ on_change="change_location(location_id, line_ids)"
696+ />
697 </group>
698 <separator colspan="4" string="Actions" />
699 <button special="cancel" string="Cancel" icon="gtk-cancel" help="Close the wizard" />
700
701=== modified file 'bin/addons/unifield_tests/tests/resourcing.py'
702--- bin/addons/unifield_tests/tests/resourcing.py 2015-08-07 03:28:33 +0000
703+++ bin/addons/unifield_tests/tests/resourcing.py 2016-03-17 10:23:08 +0000
704@@ -255,7 +255,7 @@
705 'po_cft': 'po',
706 'supplier': self.get_record(db, 'ext_supplier_1'),
707 })
708- self.order_line_obj.confirmLine(line_ids)
709+ self.order_line_obj.confirmLine(line_ids, run_scheduler=False)
710
711 # Run the scheduler
712 new_order_id = self.run_auto_pos_creation(db, order_to_check=order_id)
713
714=== modified file 'bin/addons/unifield_tests/tests/test_pick_convert_to_standard.py'
715--- bin/addons/unifield_tests/tests/test_pick_convert_to_standard.py 2015-09-04 15:17:57 +0000
716+++ bin/addons/unifield_tests/tests/test_pick_convert_to_standard.py 2016-03-17 10:23:08 +0000
717@@ -95,7 +95,7 @@
718 'po_cft': 'po',
719 'supplier': self.get_record(self.c1, 'ext_supplier_1'),
720 })
721- self.c_sol_obj.confirmLine(line_ids)
722+ self.c_sol_obj.confirmLine(line_ids, run_scheduler=False)
723
724 # Run the scheduler
725 self.c_so_id = self.run_auto_pos_creation(self.c1, order_to_check=self.c_so_id)
726
727=== modified file 'bin/addons/unifield_tests/tests/test_sync_cancel_in.py'
728--- bin/addons/unifield_tests/tests/test_sync_cancel_in.py 2015-11-16 08:28:07 +0000
729+++ bin/addons/unifield_tests/tests/test_sync_cancel_in.py 2016-03-17 10:23:08 +0000
730@@ -113,7 +113,7 @@
731 'po_cft': 'po',
732 'supplier': self.get_record(self.c1, 'ext_supplier_1'),
733 })
734- self.c_sol_obj.confirmLine(line_ids)
735+ self.c_sol_obj.confirmLine(line_ids, run_scheduler=False)
736
737 # Run the scheduler
738 self.c_so_id = self.run_auto_pos_creation(self.c1, order_to_check=self.c_so_id)
739
740=== modified file 'bin/addons/unifield_tests/tests/test_uf_2490_one_rfq.py'
741--- bin/addons/unifield_tests/tests/test_uf_2490_one_rfq.py 2015-03-03 09:45:59 +0000
742+++ bin/addons/unifield_tests/tests/test_uf_2490_one_rfq.py 2016-03-17 10:23:08 +0000
743@@ -50,7 +50,7 @@
744 'po_cft': 'rfq',
745 'supplier': self.get_record(db, 'ext_supplier_1'),
746 })
747- self.order_line_obj.confirmLine(line_ids)
748+ self.order_line_obj.confirmLine(line_ids, run_scheduler=False)
749
750 # Run the scheduler
751 new_order_id = self.run_auto_pos_creation(db, order_to_check=order_id)
752
753=== modified file 'bin/addons/unifield_tests/tests/test_uftp_324.py'
754--- bin/addons/unifield_tests/tests/test_uftp_324.py 2015-03-12 12:51:33 +0000
755+++ bin/addons/unifield_tests/tests/test_uftp_324.py 2016-03-17 10:23:08 +0000
756@@ -130,7 +130,7 @@
757 'po_cft': 'po',
758 'supplier': self.get_record(self.c1, 'ext_supplier_1'),
759 })
760- self.c_sol_obj.confirmLine(line_ids)
761+ self.c_sol_obj.confirmLine(line_ids, run_scheduler=False)
762
763 # Run the scheduler
764 self.c_so_id = self.run_auto_pos_creation(self.c1, order_to_check=self.c_so_id)
765
766=== modified file 'bin/addons/unifield_tests/tests/test_uftp_326.py'
767--- bin/addons/unifield_tests/tests/test_uftp_326.py 2015-10-08 15:57:20 +0000
768+++ bin/addons/unifield_tests/tests/test_uftp_326.py 2016-03-17 10:23:08 +0000
769@@ -99,7 +99,7 @@
770 'po_cft': 'po',
771 'supplier': self.get_record(self.c1, 'ext_supplier_1'),
772 })
773- self.c_sol_obj.confirmLine(line_ids)
774+ self.c_sol_obj.confirmLine(line_ids, run_scheduler=False)
775
776 # Run the scheduler
777 self.c_so_id = self.run_auto_pos_creation(self.c1, order_to_check=self.c_so_id)
778
779=== modified file 'bin/addons/unifield_tests/tests/test_us_311.py'
780--- bin/addons/unifield_tests/tests/test_us_311.py 2015-07-22 13:02:02 +0000
781+++ bin/addons/unifield_tests/tests/test_us_311.py 2016-03-17 10:23:08 +0000
782@@ -108,7 +108,7 @@
783 'po_cft': 'po',
784 'supplier': self.p_crd_id,
785 })
786- self.p_sol_obj.confirmLine([self.p_irl1_id, self.p_irl2_id])
787+ self.p_sol_obj.confirmLine([self.p_irl1_id, self.p_irl2_id], run_scheduler=False)
788
789 # Run the scheduler
790 self.p_ir_id = self.run_auto_pos_creation(self.p1, order_to_check=self.p_ir_id)
791@@ -170,7 +170,7 @@
792 'po_cft': 'po',
793 'supplier': self.get_record(self.c1, 'ext_supplier_1'),
794 })
795- self.c_sol_obj.confirmLine(line_ids)
796+ self.c_sol_obj.confirmLine(line_ids, run_scheduler=False)
797
798 # Get the generated PO
799 self.c_fo_id = self.run_auto_pos_creation(self.c1, order_to_check=self.c_fo_id)
800
801=== modified file 'bin/addons/unifield_tests/tests/test_utp_1007.py'
802--- bin/addons/unifield_tests/tests/test_utp_1007.py 2015-02-10 08:55:45 +0000
803+++ bin/addons/unifield_tests/tests/test_utp_1007.py 2016-03-17 10:23:08 +0000
804@@ -69,7 +69,7 @@
805 'po_cft': 'po',
806 'supplier': self.get_record(self.c1, 'ext_supplier_1'),
807 })
808- self.c_sol_obj.confirmLine(line_ids)
809+ self.c_sol_obj.confirmLine(line_ids, run_scheduler=False)
810
811 # Run the scheduler
812 self.c_so_id = self.run_auto_pos_creation(self.c1, order_to_check=self.c_so_id)

Subscribers

People subscribed via source and target branches

to all changes: