Merge lp:~matjaz-6/openerpsl/openerpsl_02_17 into lp:openerpsl/7.0

Proposed by Matjaz Kalic
Status: Merged
Merged at revision: 341
Proposed branch: lp:~matjaz-6/openerpsl/openerpsl_02_17
Merge into: lp:openerpsl/7.0
Diff against target: 814 lines (+310/-223)
13 files modified
m_web_api/m_web.py (+9/-1)
m_web_api/static/src/js/core.js (+8/-13)
mrp_procurement_qty/__openerp__.py (+1/-0)
mrp_procurement_qty/bakery_production.py (+33/-3)
mrp_procurement_qty/bakery_production_view.xml (+4/-0)
mrp_procurement_qty/mrp_production.py (+5/-4)
mrp_procurement_qty/mrp_production_view.xml (+0/-1)
mrp_procurement_qty/wizard/__init__.py (+2/-1)
mrp_procurement_qty/wizard/procurement_order.py (+13/-198)
mrp_procurement_qty/wizard/procurement_order_from_op_view.xml (+1/-1)
mrp_procurement_qty/wizard/procurement_order_move_stock.py (+199/-0)
mrp_procurement_qty/wizard/procurement_order_move_stock_view.xml (+34/-0)
mrp_procurement_qty/wizard/procurement_order_view.xml (+1/-1)
To merge this branch: bzr merge lp:~matjaz-6/openerpsl/openerpsl_02_17
Reviewer Review Type Date Requested Status
Mentis Pending
Review via email: mp+208195@code.launchpad.net

Description of the change

[MOD] mrp_procurement_qty/wizard/procurement_order_move_stock.py (new wizard for moving stock), ....

To post a comment you must log in.
341. By Dušan Laznik (Mentis)

[MOD] mrp_procurement_qty/wizard/procurement_order_move_stock.py (new wizard for moving stock), ....

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'm_web_api/m_web.py'
2--- m_web_api/m_web.py 2014-02-22 14:28:38 +0000
3+++ m_web_api/m_web.py 2014-02-25 17:17:51 +0000
4@@ -75,7 +75,15 @@
5 self.get_qty_delivery_available(cr,uid,line_id,False,False)
6 return True
7
8- def set_hladilnica_produced(self, cr, uid, line_id,kol1, status):
9+ def set_hladilnica_produced(self, cr, uid, line_id, kol1, status):
10+ for mrp_line in self.pool.get('mrp.production').browse(cr, uid, [line_id]):
11+ if mrp_line.product_id.product_tmpl_id.categ_id.parent_id.id == 38: #izdelki
12+ mrp_bom_ids = self.pool.get('mrp.production').search(cr, uid, [('product_id','=',mrp_line.product_with_bom_id),
13+ ('state', 'in', ['ready', 'confirmed','in_production'])
14+ ])
15+ qty_P_ready = kol1 * mrp_line.product_with_bom_factor
16+ self.pool.get('mrp.production').write(cr, uid, mrp_bom_ids, {'product_on_bom_qty_P_ready':qty_P_ready})
17+
18 self.write(cr, uid, line_id, {'product_on_bom_qty_ready': kol1})
19 cr.commit()
20 self.get_qty_delivery_available(cr,uid,line_id,False,False)
21
22=== modified file 'm_web_api/static/src/js/core.js'
23--- m_web_api/static/src/js/core.js 2014-02-24 21:25:06 +0000
24+++ m_web_api/static/src/js/core.js 2014-02-25 17:17:51 +0000
25@@ -883,7 +883,7 @@
26
27 mrp.query(['id','product_id','product_qty','produced','scrap','produced_phantom','scrap_phantom','produced_stock',
28 'product_on_bom_qty_available','product_on_bom_qty_stock','product_with_bom_name','product_on_bom_qty_ready',
29- 'product_qty_onstock','created_from_op'])
30+ 'product_qty_onstock','created_from_op','product_on_bom_qty_P_ready'])
31 .filter([['product_cat','in',kategorije],[tStatus,'in',tStatusValue],['dressing','in',dressingT],['state','in',['ready','in_production','confirmed']]])
32 .order_by('product_id').all().then(function(results){
33 for(i=0;i<results.length;i++){
34@@ -895,12 +895,16 @@
35 results[i].product_name = product_name;
36 results[i].product_code = product_code;
37
38-
39+ //Odstejemo nalozeno kolicino
40+ results[i].product_qty_onstock = results[i].product_qty_onstock - results[i].product_on_bom_qty_ready
41
42 if (vrstaIzdelka=='Polizdelki_testo'){
43 results[i].produced=results[i].produced_phantom;
44 results[i].scrap=results[i].scrap_phantom;
45- results[i].product_delo=(results[i].product_qty - results[i].produced_phantom + results[i].scrap_phantom - results[i].product_on_bom_qty_ready);
46+ results[i].product_delo=(results[i].product_qty - results[i].produced_phantom + results[i].scrap_phantom
47+ - results[i].product_on_bom_qty_ready -results[i].product_on_bom_qty_P_ready);
48+ if (results[i].product_on_bom_qty_P_ready>0)
49+ results[i].product_on_bom_qty_ready = results[i].product_on_bom_qty_ready + '('+results[i].product_on_bom_qty_P_ready+')'
50 }
51 if (vrstaIzdelka=='Polizdelki'){
52 results[i].product_delo=(results[i].produced_phantom-results[i].scrap_phantom-results[i].produced);
53@@ -917,9 +921,6 @@
54 if (results[i].created_from_op == true)
55 results[i].product_qty = 0
56
57- //Odstejemo nalozeno kolicino
58- results[i].product_qty_onstock = results[i].product_qty_onstock - results[i].product_on_bom_qty_ready
59-
60 if (vrstaIzdelka=='Polizdelki_testo'){
61 iDelo = parseInt(results[i].product_delo);
62 if (iDelo < 0) //if (sGotovo && (iDelo < 0))
63@@ -1047,12 +1048,6 @@
64 .data('parent', 'fillPolIzdelek')
65 .dialog("open");
66 }
67- else if (from_OP == 'true' && kol1 == 0){
68- $("#label_value_warning").text("Izdelek je naročen na zalogo. Ali ga res ne želite premakniti v hladilnico?");
69- $("#dialog-value-warning")
70- .data('parent', 'fillPolIzdelek_OP')
71- .dialog("open");
72- }
73 else{
74 mrp.call('set_izdelek_produced',[id1,kol_skupaj,kol1,1]);
75 refreshRow(tip,'grid1',true,false,true,false,kol_skupaj,0,kol1,0);
76@@ -1299,7 +1294,7 @@
77 mrp.call('set_hladilnica_produced',[id1,kol_skupaj,1]);
78 refreshRow_new('open','grid1',false,false,false,false,false,true,true,0,0,0,0,0,kol_skupaj,(kol_vdelu-kol));
79 }
80- else if (arg == 'fillPolIzdelek' || arg == 'fillPolIzdelek_OP'){
81+ else if (arg == 'fillPolIzdelek'){
82 id1=$("#grid1").jqGrid('getCell',rId,0);
83 id1=parseInt(id1);
84
85
86=== modified file 'mrp_procurement_qty/__openerp__.py'
87--- mrp_procurement_qty/__openerp__.py 2014-02-22 14:28:38 +0000
88+++ mrp_procurement_qty/__openerp__.py 2014-02-25 17:17:51 +0000
89@@ -49,6 +49,7 @@
90 'security/ir.model.access.csv',
91 'mrp_production_view.xml',
92 'wizard/procurement_order_from_op_view.xml',
93+ 'wizard/procurement_order_move_stock_view.xml',
94 'bakery_production_view.xml',
95 'res_config_view.xml',
96 ],
97
98=== modified file 'mrp_procurement_qty/bakery_production.py'
99--- mrp_procurement_qty/bakery_production.py 2014-02-22 14:28:38 +0000
100+++ mrp_procurement_qty/bakery_production.py 2014-02-25 17:17:51 +0000
101@@ -32,12 +32,14 @@
102 'duration': fields.char('Duration', size=8, readonly=True),
103 'user_id': fields.many2one('res.users', 'User', readonly=True),
104 'running': fields.boolean('Running'),
105+ 'misc': fields.char('Misc.', size=128, readonly=True),
106 'process': fields.selection([
107 ('10','Confirm sale orders'),
108 ('20','Procurement'),
109 ('30','Procurement with OP'),
110 ('40','Deliver delivery orders'),
111- ('50','Produce manufacturing orders')], 'Process', readonly=True),
112+ ('50','Produce manufacturing orders'),
113+ ('60','Stock moved')], 'Process', readonly=True),
114 }
115 _defaults = {
116 'date_start': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
117@@ -54,6 +56,8 @@
118 def process_end(self, cr, uid, process, process_id, production_id, context=None):
119
120 date_start = self.browse(cr, uid, [process_id])[0]['date_start']
121+ stock_moved = self.pool.get('bakery.production').browse(cr, uid, [production_id])[0]['stock_moved']
122+
123 d_diff = datetime.now()-datetime.strptime(date_start, ('%Y-%m-%d %H:%M:%S'))
124 total_secs = d_diff.seconds
125 secs = total_secs % 60
126@@ -89,6 +93,9 @@
127 self.pool.get('bakery.production').write(cr, uid, [production_id], {'manufactury_done':True,
128 'running':False,
129 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')})
130+ elif process == '60':
131+ self.pool.get('bakery.production').write(cr, uid, [production_id], {'stock_moved':not stock_moved})
132+
133 return {}
134
135 def process_running(self, cr, uid, process, context=None):
136@@ -118,6 +125,7 @@
137 'procurement_done': fields.boolean('Procurement done'),
138 'op_procurement_done': fields.boolean('OP procurement done'),
139 'delivery_done': fields.boolean('Delivery done'),
140+ 'stock_moved': fields.boolean('Stock moved'),
141 'manufactury_done': fields.boolean('Manufactury done'),
142 }
143 _defaults = {
144@@ -136,11 +144,16 @@
145
146 running_id = self.search(cr, uid, [], order='id desc', limit=1, context=context)
147 for line in self.browse(cr, uid, running_id):
148- if line.running:
149+ if line.running and line.stock_moved and process != '60' and process != '20':
150+ res = _('Cannot run process. Stocks are moved!')
151+
152+ elif line.running:
153 if process == '10'and line.delivery_done:
154 res = _('Cannot confirm Sale orders, since Delivery orders are already delivered!')
155 elif process == '20'and line.delivery_done:
156- res = _('Cannot run Schedulers, since Delivery orders are already delivered!')
157+ res = _('Cannot run Scheduler, since Delivery orders are already delivered!')
158+ elif process == '20'and not line.stock_moved:
159+ res = _('Cannot run Schedulers. You must first move the stock and orderpoints!')
160 elif process == '30' and not line.procurement_done:
161 res = _('Cannot run Scheduler from Orderpoint, since normal Scheduler has not been run yet!')
162 elif process == '40':
163@@ -150,9 +163,26 @@
164 res = _('Cannot deliver Delivery orders since production start date (%s) is not older than today!') %(d_start)
165 elif process == '50'and not line.delivery_done:
166 res = _('Cannot finnish production, since Delivery orders have not been delivered yet!')
167+ elif process == '60':
168+ if not line.sale_done:
169+ res = _('Sale not confirmed!')
170+ elif line.delivery_done:
171+ res = _('Delivery orders are delivered!')
172+
173 else:
174 running_id = []
175
176 return running_id, res
177
178+ def is_stock_moved(self, cr, uid, process, context=None):
179+ res = False
180+ if context is None:
181+ context = {'active_test':False}
182+
183+ running_id = self.search(cr, uid, [], order='id desc', limit=1, context=context)
184+ for line in self.browse(cr, uid, running_id):
185+ if line.running and line.stock_moved:
186+ res = True
187+ return res
188+
189 bakery_production()
190
191=== modified file 'mrp_procurement_qty/bakery_production_view.xml'
192--- mrp_procurement_qty/bakery_production_view.xml 2014-02-22 14:28:38 +0000
193+++ mrp_procurement_qty/bakery_production_view.xml 2014-02-25 17:17:51 +0000
194@@ -15,6 +15,7 @@
195 <field name="op_procurement_done"/>
196 <field name="delivery_done"/>
197 <field name="manufactury_done"/>
198+ <field name="stock_moved"/>
199 <field name="running"/>
200 </tree>
201 </field>
202@@ -28,6 +29,7 @@
203 <form string="Bakery production">
204 <group string="Status">
205 <field name="running"/>
206+ <field name="stock_moved"/>
207 <field name="date_start"/>
208 <field name="date_end"/>
209 </group>
210@@ -66,6 +68,7 @@
211 <field name="date_start"/>
212 <field name="date_end"/>
213 <field name="duration"/>
214+ <field name="misc"/>
215 <field name="running"/>
216 </tree>
217 </field>
218@@ -83,6 +86,7 @@
219 <field name="date_start"/>
220 <field name="date_end"/>
221 <field name="duration"/>
222+ <field name="misc"/>
223 <field name="running"/>
224 </group>
225 </form>
226
227=== modified file 'mrp_procurement_qty/mrp_production.py'
228--- mrp_procurement_qty/mrp_production.py 2014-02-24 13:52:07 +0000
229+++ mrp_procurement_qty/mrp_production.py 2014-02-25 17:17:51 +0000
230@@ -52,7 +52,7 @@
231 context['product_id'] = vals['product_id']
232 stock_values = self.pool.get('stock.location')._product_value(cr, user, [loc_id], ['stock_real'], arg=None, context=context)
233
234- vals['product_qty_onstock'] = stock_values[loc_id]['stock_real']
235+ vals['product_qty_onstock'] = int(stock_values[loc_id]['stock_real'])
236 res = super(mrp_production, self).create(cr, user, vals, context=context)
237 return res
238
239@@ -151,7 +151,7 @@
240 if order_bom.produced != 0 and order_bom.product_with_bom_factor:
241 qty_reserved += (order_bom.produced*order_bom.product_with_bom_factor)
242 #qty_from_stock += (order_bom.product_on_bom_qty_ready/order_bom.product_with_bom_factor) #kar je dano iz hladilnice
243- qty_from_stock += (order_bom.product_on_bom_qty_ready) #kar je dano iz hladilnice
244+ #qty_from_stock += (order_bom.product_on_bom_qty_ready) #ZADNJE
245
246
247 #Preveriti moram še ali je bilo kaj dano v košare
248@@ -186,10 +186,11 @@
249 _columns = {
250 'created_from_op': fields.boolean('Created from orderpoint'),
251 'product_qty_onstock': fields.float('Product qty on stock', digits=(6,2)),
252- 'product_qty_available': fields.function(_get_prod_qty_available, string='Product quantity available'),
253+ #'product_qty_available': fields.function(_get_prod_qty_available, string='Product quantity available'),
254 'product_on_bom_qty_available': fields.function(_get_prod_on_bom_qty_available, string='Product on BOM quantity available', multi='prepare0'),
255 'product_on_bom_qty_stock': fields.function(_get_prod_on_bom_qty_available, string='Product on BOM stock available', multi='prepare0'),
256- 'product_on_bom_qty_ready': fields.float('Quantity from stock - make available', digits=(6,2)),
257+ 'product_on_bom_qty_ready': fields.float('Load O from stock', digits=(6,2)),
258+ 'product_on_bom_qty_P_ready': fields.float('Load P from stock', digits=(6,2)),
259 'product_with_bom_factor': fields.function(_prepare_product_id, digits=(12,4), method=True, store=True, string='BOM factor', multi='prepare1'),
260 'product_with_bom_id': fields.function(_prepare_product_id, type='integer', method=True, store=True, string='Product with BOM id', multi='prepare1'),
261 'product_with_bom_relation': fields.function(_prepare_product_id, type='many2one', obj='product.product', method=True, store=True, string='Product with BOM name', multi='prepare1'),
262
263=== modified file 'mrp_procurement_qty/mrp_production_view.xml'
264--- mrp_procurement_qty/mrp_production_view.xml 2014-02-05 10:02:52 +0000
265+++ mrp_procurement_qty/mrp_production_view.xml 2014-02-25 17:17:51 +0000
266@@ -20,7 +20,6 @@
267 <field name="status_testo" />
268 </group>
269 <group name="stock_st" string="Stock">
270- <field name="product_qty_available" />
271 <field name="product_on_bom_qty_available" />
272 <field name="product_with_bom_factor" />
273 <field name="product_with_bom_id" />
274
275=== modified file 'mrp_procurement_qty/wizard/__init__.py'
276--- mrp_procurement_qty/wizard/__init__.py 2014-02-17 15:12:21 +0000
277+++ mrp_procurement_qty/wizard/__init__.py 2014-02-25 17:17:51 +0000
278@@ -26,4 +26,5 @@
279 import sale_order_journal
280 import delivery_order_return
281 import delivery_order_confirm
282-import procurement_order_from_op
283\ No newline at end of file
284+import procurement_order_from_op
285+import procurement_order_move_stock
286\ No newline at end of file
287
288=== modified file 'mrp_procurement_qty/wizard/procurement_order.py'
289--- mrp_procurement_qty/wizard/procurement_order.py 2014-02-24 16:52:18 +0000
290+++ mrp_procurement_qty/wizard/procurement_order.py 2014-02-25 17:17:51 +0000
291@@ -115,18 +115,6 @@
292 sale_override = self.browse(cr,uid,ids)[0].override
293 proc_obj = self.pool.get('procurement.order')
294
295- #proc_jour_obj = self.pool.get('procurement.order.journal')
296- #Check if there is procurement already running for this day
297-# proc_jour_ids = proc_jour_obj.search(cr, uid, [('state', '=' , True)])
298-# if proc_jour_ids: #ce obstaja lansirana proizvodnja, preverimo ali je istega datuma
299-# for proc_jour_line in proc_jour_obj.browse(cr, uid, proc_jour_ids):
300-# if (proc_jour_line.date_start != time.strftime('%Y-%m-%d')):
301-# raise osv.except_osv('Opozorilo!', u'Proizvodnja je že bila lansirana dne: %s.' % (proc_jour_line.date_start,))
302-# else:
303-# proc_jour_obj.create(cr, uid, {'date_start':time.strftime('%Y-%m-%d'),
304-# 'state':True
305-# })
306-
307 #Preverimo ali obstaja aktiven zapis in nezakljucene dobavnice----------------------------------------
308 production_id, production_status = self.pool.get('bakery.production').production_running(cr, uid, '20')
309 if production_status: #dobavnice so ze potrjene
310@@ -136,7 +124,7 @@
311 else:
312 production_id = production_id[0]
313
314- #Preverimo je lansiranje ze zagnano
315+ #Preverimo ce je lansiranje ze zagnano
316 process_status = self.pool.get('bakery.process').process_running(cr, uid, '20')
317 if not sale_override and process_status:
318 raise osv.except_osv(_('Warning!'),process_status)
319@@ -145,6 +133,10 @@
320 #------------------------------------------------------------------------------------------------------
321
322
323+ ir_config_parameter = self.pool.get('ir.config_parameter')
324+ ir_config_parameter.set_param(cr, uid, 'stock.empty_location_active', '1')
325+ empty_location_id = safe_eval(ir_config_parameter.get_param(cr, uid, 'stock.empty_location', 'False'))
326+
327 #Ce je stevilo ponovitev != 0 potem tolikokrat, drugace 4x
328 repeat_number = self.browse(cr,uid,ids)[0].repeat_number
329 if repeat_number == 0:
330@@ -152,96 +144,25 @@
331 elif repeat_number == -1:
332 repeat_number = 0
333
334-
335+ cr.commit()
336+ new_cr = pooler.get_db(cr.dbname).cursor()
337+ use_new_cursor = new_cr.dbname
338 print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' - Start')
339-
340- #Najdelo Tocke narocanja in jih umaknemo za navadno lansiranje
341- context['created_from_op'] = False
342- orderpoint_ids = self.pool.get('stock.warehouse.orderpoint').search(cr, uid, [('product_id.product_tmpl_id.categ_id.id','!=', 4),
343- ('product_id.product_tmpl_id.categ_id.parent_id.id','!=', 4),
344- ('product_min_qty','>',0)
345- ])
346- for orderpoint in self.pool.get('stock.warehouse.orderpoint').browse(cr, uid, orderpoint_ids):
347- self.pool.get('stock.warehouse.orderpoint').write(cr, uid, [orderpoint.id],
348- {'temp_min_qty':orderpoint.product_min_qty,
349- 'temp_max_qty':orderpoint.product_max_qty,
350- 'product_min_qty':0,
351- 'product_max_qty':0,
352- })
353- ir_config_parameter = self.pool.get('ir.config_parameter')
354- ir_config_parameter.set_param(cr, uid, 'stock.empty_location_active', '1')
355- empty_location_id = safe_eval(ir_config_parameter.get_param(cr, uid, 'stock.empty_location', 'False'))
356-
357- _sql_string0 = """UPDATE stock_move sm
358- SET
359- location_id =
360- case
361- when location_id = 12 then """ + str(empty_location_id) + """
362- else location_id
363- end,
364- location_dest_id =
365- case
366- when location_dest_id = 12 then """ + str(empty_location_id) + """
367- else location_dest_id
368- end
369- where
370- (
371- sm.location_id = 12 or location_dest_id = 12
372- )
373- and
374- (
375- select 1 from product_template pt
376- inner join product_category pc on
377- pc.id = pt.categ_id and
378- pc.parent_id in(34, 38)
379- where pt.id = sm.product_id
380- ) = 1 and sm.basket_status <> 3"""
381- cr.execute(_sql_string0)
382- cr.commit() #Ker se ustvari nov kurzor moramo vse spremembe commitnit ---------------------------------------------------
383- _sql_string01 = """UPDATE stock_move
384- SET
385- location_id =
386- case
387- when location_id = """ + str(empty_location_id) + """ then 12
388- else location_id
389- end,
390- location_dest_id =
391- case
392- when location_dest_id = """ + str(empty_location_id) + """ then 12
393- else location_dest_id
394- end
395- where
396- (
397- location_id = """ + str(empty_location_id) + """ or location_dest_id = """ + str(empty_location_id) + """
398- )"""
399-
400-
401- use_new_cursor = cr.dbname
402- new_cr = pooler.get_db(cr.dbname).cursor()
403 for x in range(0, repeat_number):
404 try:
405- #proc_obj.run_scheduler(new_cr, uid, automatic=False, use_new_cursor=new_cr.dbname, context=context)
406 produrement_ids = proc_obj.search(new_cr, uid, [('state', '=', 'confirmed'),
407 ('procure_method', '=', 'make_to_stock')])
408 proc_obj._procure_confirm(new_cr, uid, ids=produrement_ids, use_new_cursor=use_new_cursor, context=context)
409 proc_obj._procure_orderpoint_confirm(new_cr, uid, automatic=False, use_new_cursor=use_new_cursor, context=context)
410+
411+ self.pool.get('bakery.process').write(new_cr, uid, [process_id], {'misc':str(x+1)})
412+
413 new_cr.commit()
414 except Exception, e:
415 new_cr.rollback()
416 new_cr.close()
417- #Tocko narocanja vrnemo nazaj
418- orderpoint_ids = self.pool.get('stock.warehouse.orderpoint').search(cr, uid, [('product_id.product_tmpl_id.categ_id.id','!=', 4),
419- ('product_id.product_tmpl_id.categ_id.parent_id.id','!=', 4),
420- ('temp_min_qty','>',0)
421- ])
422- for orderpoint in self.pool.get('stock.warehouse.orderpoint').browse(cr, uid, orderpoint_ids):
423- self.pool.get('stock.warehouse.orderpoint').write(cr, uid, [orderpoint.id],
424- {'product_min_qty':orderpoint.temp_min_qty,
425- 'product_max_qty':orderpoint.temp_max_qty,
426- })
427- cr.execute(_sql_string01) #zalogo postavimo nazaj na 12
428- cr.commit()
429- raise osv.except_osv('Opozorilo!', u'Napaka lansiranja v %s. krogu. Err: %s' % (str(x), str(e)))
430+
431+ raise osv.except_osv('Opozorilo!', u'Napaka lansiranja v %s. krogu. Err: %s' % (str(x+1), str(e)))
432 return{}
433 print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' - Close: ' + str(x+1))
434 #------------------------------------------------------------------------------------------------------------------------
435@@ -254,112 +175,6 @@
436 raise osv.except_osv('Opozorilo!', 'Napaka pri zdruzevanju d.n.:' + str(e))
437 return{}
438 #-------------------------------------------------------------------------------------------
439- try:
440- orderpoint_ids = self.pool.get('stock.warehouse.orderpoint').search(new_cr, uid, [('product_id.product_tmpl_id.categ_id.id','!=', 4),
441- ('product_id.product_tmpl_id.categ_id.parent_id.id','!=', 4),
442- ('temp_min_qty','>',0)
443- ])
444- for orderpoint in self.pool.get('stock.warehouse.orderpoint').browse(new_cr, uid, orderpoint_ids):
445- self.pool.get('stock.warehouse.orderpoint').write(new_cr, uid, [orderpoint.id],
446- {'product_min_qty':orderpoint.temp_min_qty,
447- 'product_max_qty':orderpoint.temp_max_qty,
448- 'temp_min_qty':0,
449- 'temp_max_qty':0,
450- })
451- new_cr.commit()
452- except Exception, e:
453- new_cr.rollback()
454- new_cr.close()
455- raise osv.except_osv('Opozorilo!', 'Napaka pri premiku orderpoint-a nazaj; ' + str(e))
456- return{}
457- #-------------------------------------------------------------------------------------------
458- #String napisal ze prej
459- try:
460- new_cr.execute(_sql_string01)
461- new_cr.commit() #Da si nalozimo sprememb
462- except Exception, e:
463- new_cr.rollback()
464- new_cr.close()
465- raise osv.except_osv('Opozorilo!', 'Napaka pri premiku lokacije nazaj; ' +str(e))
466- return{}
467-
468- #-------------------------------------------------------------------------------------------
469- _sql_string1 = """update mrp_production
470- SET status_testo = 0, status_izdelki = 0
471- WHERE status_testo = 3 or status_izdelki = 3;"""
472- try:
473- new_cr.execute(_sql_string1)
474- new_cr.commit()
475- except Exception, e:
476- new_cr.rollback()
477- new_cr.close()
478- raise osv.except_osv('Opozorilo!', 'Napaka pri zagonu query-ja: status_testo; ' +str(e))
479- return{}
480- #-------------------------------------------------------------------------------------------
481-
482- _sql_string2 = """update stock_move
483- SET basket_status = 2
484- WHERE basket_status = 3 AND state = 'done';"""
485-
486- try:
487- new_cr.execute(_sql_string2)
488- new_cr.commit()
489- except Exception, e:
490- new_cr.rollback()
491- new_cr.close()
492- raise osv.except_osv('Opozorilo!', 'Napaka pri zagonu query-ja: basket_status_2_done; ' +str(e))
493- return{}
494- #--------------------------------------------------------------------------------------------
495-
496- _sql_string2a = """update stock_move
497- SET basket_status = 0
498- WHERE basket_status = 3;"""
499-
500- try:
501- new_cr.execute(_sql_string2a)
502- new_cr.commit()
503- except Exception, e:
504- new_cr.rollback()
505- new_cr.close()
506- raise osv.except_osv('Opozorilo!', 'Napaka pri zagonu query-ja: basket_status_0; ' +str(e))
507- return{}
508- #--------------------------------------------------------------------------------------------
509-
510- _sql_string3 = """update stock_move upd
511- set basket_status = 2
512- where
513- not upd.id in
514- (
515-
516- select id from stock_move mov
517- where mov.basket_status <> 2 and mov.location_id = 12
518- and exists(
519- select * from stock_picking pic
520- where
521- pic.id = mov.picking_id and
522- pic.type = 'out'
523- )
524-
525- ) and basket_status != 2;"""
526- try:
527- new_cr.execute(_sql_string3)
528- new_cr.commit()
529- except Exception, e:
530- new_cr.rollback()
531- new_cr.close()
532- raise osv.except_osv('Opozorilo!', 'Napaka pri zagonu query-ja: basket_status2; ' +str(e))
533- return{}
534- #--------------------------------------------------------------------------------------------
535- try:
536- self.pool.get('stock.move').get_qty_delivery_available(new_cr, uid)
537- new_cr.commit()
538- except Exception, e:
539- new_cr.rollback()
540- new_cr.close()
541- raise osv.except_osv('Opozorilo!', 'Napaka pri zagonu query-ja delivery_available' + str(e))
542- finally:
543- new_cr.close()
544-
545
546 print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' - KONEC Lansiranja')
547 self.pool.get('bakery.process').process_end(cr, uid, '20', process_id, production_id)
548
549=== modified file 'mrp_procurement_qty/wizard/procurement_order_from_op_view.xml'
550--- mrp_procurement_qty/wizard/procurement_order_from_op_view.xml 2014-02-17 15:12:21 +0000
551+++ mrp_procurement_qty/wizard/procurement_order_from_op_view.xml 2014-02-25 17:17:51 +0000
552@@ -30,6 +30,6 @@
553 key2="client_action_multi"
554 id="action_run_scheduler_orderpoint_multiple_times"/>
555
556- <menuitem action="action_run_scheduler_orderpoint_multiple_times" id="menu_run_scheduler_orderpoint_multiple_times" parent="procurement.menu_stock_sched" sequence="20"/>
557+ <menuitem action="action_run_scheduler_orderpoint_multiple_times" id="menu_run_scheduler_orderpoint_multiple_times" parent="procurement.menu_stock_sched" sequence="23"/>
558 </data>
559 </openerp>
560
561=== added file 'mrp_procurement_qty/wizard/procurement_order_move_stock.py'
562--- mrp_procurement_qty/wizard/procurement_order_move_stock.py 1970-01-01 00:00:00 +0000
563+++ mrp_procurement_qty/wizard/procurement_order_move_stock.py 2014-02-25 17:17:51 +0000
564@@ -0,0 +1,199 @@
565+# -*- coding: utf-8 -*-
566+##############################################################################
567+#
568+# OpenERP, Open Source Management Solution
569+# Copyright (C) 2013 Mentis d.o.o.
570+#
571+# This program is free software: you can redistribute it and/or modify
572+# it under the terms of the GNU Affero General Public License as
573+# published by the Free Software Foundation, either version 3 of the
574+# License, or (at your option) any later version.
575+#
576+# This program is distributed in the hope that it will be useful,
577+# but WITHOUT ANY WARRANTY; without even the implied warranty of
578+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
579+# GNU Affero General Public License for more details.
580+#
581+# You should have received a copy of the GNU Affero General Public License
582+# along with this program. If not, see <http://www.gnu.org/licenses/>.
583+#
584+##############################################################################
585+
586+from osv import fields, osv
587+#from openerp import pooler
588+#from datetime import datetime
589+#import time
590+from tools.translate import _
591+from openerp.tools.safe_eval import safe_eval
592+
593+class procurement_order_move_stock_wizard(osv.osv_memory):
594+ _name = "procurement.order.move.stock.wizard"
595+ _description = "Move stock and order points"
596+
597+ def _get_status_move(self, cr, uid, context):
598+ return self.pool.get('bakery.production').is_stock_moved(cr, uid, '60', context=None)
599+
600+ def _get_status(self, cr, uid, context):
601+ return self.pool.get('bakery.process').process_running(cr, uid, '60', context=None)
602+
603+ _columns = {
604+ 'status_move': fields.boolean('Stock moved', readonly=True),
605+ 'status': fields.char('Running status', size=128, readonly=True),
606+ 'override': fields.boolean('Override running process', help='Run the process, even if there is another one running'),
607+ }
608+ _defaults = {
609+ 'status_move': _get_status_move,
610+ 'status': _get_status,
611+ }
612+
613+
614+ def execute(self, cr, uid, ids, context=None):
615+ if context is None:
616+ context = {}
617+
618+ sale_override = self.browse(cr,uid,ids)[0].override
619+
620+ #Preverimo ali obstaja aktiven zapis ------------------------------------------------------------------
621+ production_id, production_status = self.pool.get('bakery.production').production_running(cr, uid, '60')
622+ if production_status: #dobavnice so ze potrjene
623+ raise osv.except_osv(_('Warning!'),production_status)
624+ if production_id == []: #se ne obstaja aktiven zapis
625+ raise osv.except_osv(_('Warning!'),_('Sale orders have today not been confirmed yet!'))
626+ else:
627+ production_id = production_id[0]
628+
629+ #Preverimo je lansiranje ze zagnano
630+ process_status = self.pool.get('bakery.process').process_running(cr, uid, '60')
631+ if not sale_override and process_status:
632+ raise osv.except_osv(_('Warning!'),process_status)
633+ else:
634+ process_id = self.pool.get('bakery.process').process_start(cr, uid, '60')
635+ cr.commit()
636+ #------------------------------------------------------------------------------------------------------
637+
638+ ir_config_parameter = self.pool.get('ir.config_parameter')
639+ empty_location_id = safe_eval(ir_config_parameter.get_param(cr, uid, 'stock.empty_location', 'False'))
640+
641+ stock_moved = self.pool.get('bakery.production').is_stock_moved(cr, uid, '60', context=None)
642+ if not stock_moved:
643+ #1. Najdemo tocke narocanja in jih umaknemo za navadno lansiranje
644+ orderpoint_ids = self.pool.get('stock.warehouse.orderpoint').search(cr, uid, [('product_id.product_tmpl_id.categ_id.id','!=', 4),
645+ ('product_id.product_tmpl_id.categ_id.parent_id.id','!=', 4),
646+ ('product_min_qty','>',0)
647+ ])
648+ for orderpoint in self.pool.get('stock.warehouse.orderpoint').browse(cr, uid, orderpoint_ids):
649+ self.pool.get('stock.warehouse.orderpoint').write(cr, uid, [orderpoint.id],
650+ {'temp_min_qty':orderpoint.product_min_qty,
651+ 'temp_max_qty':orderpoint.product_max_qty,
652+ 'product_min_qty':0,
653+ 'product_max_qty':0,
654+ })
655+
656+ #2. Premaknemo zalogo na zacasno lokacijo
657+
658+
659+ _sql_string0 = """UPDATE stock_move sm
660+ SET
661+ location_id =
662+ case
663+ when location_id = 12 then """ + str(empty_location_id) + """
664+ else location_id
665+ end,
666+ location_dest_id =
667+ case
668+ when location_dest_id = 12 then """ + str(empty_location_id) + """
669+ else location_dest_id
670+ end
671+ where
672+ (
673+ sm.location_id = 12 or location_dest_id = 12
674+ )
675+ and
676+ (
677+ select 1 from product_template pt
678+ inner join product_category pc on
679+ pc.id = pt.categ_id and
680+ pc.parent_id in(34, 38)
681+ where pt.id = sm.product_id
682+ ) = 1 and sm.basket_status = 2"""
683+ cr.execute(_sql_string0)
684+
685+ else:
686+ orderpoint_ids = self.pool.get('stock.warehouse.orderpoint').search(cr, uid, [('product_id.product_tmpl_id.categ_id.id','!=', 4),
687+ ('product_id.product_tmpl_id.categ_id.parent_id.id','!=', 4),
688+ ('temp_min_qty','>',0)
689+ ])
690+ for orderpoint in self.pool.get('stock.warehouse.orderpoint').browse(cr, uid, orderpoint_ids):
691+ self.pool.get('stock.warehouse.orderpoint').write(cr, uid, [orderpoint.id],
692+ {'product_min_qty':orderpoint.temp_min_qty,
693+ 'product_max_qty':orderpoint.temp_max_qty,
694+ 'temp_min_qty':0,
695+ 'temp_max_qty':0,
696+ })
697+
698+ _sql_string01 = """UPDATE stock_move
699+ SET
700+ location_id =
701+ case
702+ when location_id = """ + str(empty_location_id) + """ then 12
703+ else location_id
704+ end,
705+ location_dest_id =
706+ case
707+ when location_dest_id = """ + str(empty_location_id) + """ then 12
708+ else location_dest_id
709+ end
710+ where
711+ (
712+ location_id = """ + str(empty_location_id) + """ or location_dest_id = """ + str(empty_location_id) + """
713+ )"""
714+
715+
716+ cr.execute(_sql_string01)
717+ #-------------------------------------------------------------------------------------------
718+
719+ _sql_string1 = """update mrp_production
720+ SET status_testo = 0, status_izdelki = 0
721+ WHERE status_testo = 3 or status_izdelki = 3;"""
722+ cr.execute(_sql_string1)
723+ #-------------------------------------------------------------------------------------------
724+
725+ _sql_string2 = """update stock_move
726+ SET basket_status = 2
727+ WHERE basket_status = 3 AND state = 'done';"""
728+
729+ cr.execute(_sql_string2)
730+ #--------------------------------------------------------------------------------------------
731+
732+ _sql_string2a = """update stock_move
733+ SET basket_status = 0
734+ WHERE basket_status = 3;"""
735+ cr.execute(_sql_string2a)
736+ #--------------------------------------------------------------------------------------------
737+
738+ _sql_string3 = """update stock_move upd
739+ set basket_status = 2
740+ where
741+ not upd.id in
742+ (
743+
744+ select id from stock_move mov
745+ where mov.basket_status <> 2 and mov.location_id = 12
746+ and exists(
747+ select * from stock_picking pic
748+ where
749+ pic.id = mov.picking_id and
750+ pic.type = 'out'
751+ )
752+
753+ ) and basket_status != 2;"""
754+ cr.execute(_sql_string3)
755+ #--------------------------------------------------------------------------------------------
756+ self.pool.get('stock.move').get_qty_delivery_available(cr, uid)
757+
758+
759+ self.pool.get('bakery.process').process_end(cr, uid, '60', process_id, production_id)
760+ return{}
761+
762+procurement_order_move_stock_wizard()
763+
764
765=== added file 'mrp_procurement_qty/wizard/procurement_order_move_stock_view.xml'
766--- mrp_procurement_qty/wizard/procurement_order_move_stock_view.xml 1970-01-01 00:00:00 +0000
767+++ mrp_procurement_qty/wizard/procurement_order_move_stock_view.xml 2014-02-25 17:17:51 +0000
768@@ -0,0 +1,34 @@
769+<?xml version="1.0" encoding="utf-8"?>
770+<openerp>
771+ <data>
772+ <record id="multiple_move_stock_wizard_view" model="ir.ui.view">
773+ <field name="name">Move stock and order points</field>
774+ <field name="model">procurement.order.move.stock.wizard</field>
775+ <field name="arch" type="xml">
776+ <form string="Move stock and order points - view" version="7.0">
777+ <group>
778+ <separator string="Status" colspan="4" />
779+ <field name="status_move" />
780+ <field name="status" />
781+ <field name="override" />
782+ </group>
783+ <footer>
784+ <button name="execute" string="Move stock" type="object" class="oe_highlight"/>
785+ or
786+ <button special="cancel" string="Cancel" class="oe_link"/>
787+ </footer>
788+ </form>
789+ </field>
790+ </record>
791+
792+ <act_window name="Move stock and order points"
793+ res_model="procurement.order.move.stock.wizard"
794+ src_model="procurement.order"
795+ view_mode="form"
796+ target="new"
797+ key2="client_action_multi"
798+ id="action_move_stock_order_points"/>
799+
800+ <menuitem action="action_move_stock_order_points" id="menu_move_stock_order_points" parent="procurement.menu_stock_sched" sequence="21"/>
801+ </data>
802+</openerp>
803
804=== modified file 'mrp_procurement_qty/wizard/procurement_order_view.xml'
805--- mrp_procurement_qty/wizard/procurement_order_view.xml 2014-02-17 15:12:21 +0000
806+++ mrp_procurement_qty/wizard/procurement_order_view.xml 2014-02-25 17:17:51 +0000
807@@ -30,6 +30,6 @@
808 key2="client_action_multi"
809 id="action_run_scheduler_multiple_times"/>
810
811- <menuitem action="action_run_scheduler_multiple_times" id="menu_run_scheduler_multiple_times" parent="procurement.menu_stock_sched" sequence="20"/>
812+ <menuitem action="action_run_scheduler_multiple_times" id="menu_run_scheduler_multiple_times" parent="procurement.menu_stock_sched" sequence="22"/>
813 </data>
814 </openerp>

Subscribers

People subscribed via source and target branches