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
=== modified file 'm_web_api/m_web.py'
--- m_web_api/m_web.py 2014-02-22 14:28:38 +0000
+++ m_web_api/m_web.py 2014-02-25 17:17:51 +0000
@@ -75,7 +75,15 @@
75 self.get_qty_delivery_available(cr,uid,line_id,False,False) 75 self.get_qty_delivery_available(cr,uid,line_id,False,False)
76 return True76 return True
77 77
78 def set_hladilnica_produced(self, cr, uid, line_id,kol1, status):78 def set_hladilnica_produced(self, cr, uid, line_id, kol1, status):
79 for mrp_line in self.pool.get('mrp.production').browse(cr, uid, [line_id]):
80 if mrp_line.product_id.product_tmpl_id.categ_id.parent_id.id == 38: #izdelki
81 mrp_bom_ids = self.pool.get('mrp.production').search(cr, uid, [('product_id','=',mrp_line.product_with_bom_id),
82 ('state', 'in', ['ready', 'confirmed','in_production'])
83 ])
84 qty_P_ready = kol1 * mrp_line.product_with_bom_factor
85 self.pool.get('mrp.production').write(cr, uid, mrp_bom_ids, {'product_on_bom_qty_P_ready':qty_P_ready})
86
79 self.write(cr, uid, line_id, {'product_on_bom_qty_ready': kol1})87 self.write(cr, uid, line_id, {'product_on_bom_qty_ready': kol1})
80 cr.commit()88 cr.commit()
81 self.get_qty_delivery_available(cr,uid,line_id,False,False) 89 self.get_qty_delivery_available(cr,uid,line_id,False,False)
8290
=== modified file 'm_web_api/static/src/js/core.js'
--- m_web_api/static/src/js/core.js 2014-02-24 21:25:06 +0000
+++ m_web_api/static/src/js/core.js 2014-02-25 17:17:51 +0000
@@ -883,7 +883,7 @@
883 883
884 mrp.query(['id','product_id','product_qty','produced','scrap','produced_phantom','scrap_phantom','produced_stock',884 mrp.query(['id','product_id','product_qty','produced','scrap','produced_phantom','scrap_phantom','produced_stock',
885 'product_on_bom_qty_available','product_on_bom_qty_stock','product_with_bom_name','product_on_bom_qty_ready',885 'product_on_bom_qty_available','product_on_bom_qty_stock','product_with_bom_name','product_on_bom_qty_ready',
886 'product_qty_onstock','created_from_op'])886 'product_qty_onstock','created_from_op','product_on_bom_qty_P_ready'])
887 .filter([['product_cat','in',kategorije],[tStatus,'in',tStatusValue],['dressing','in',dressingT],['state','in',['ready','in_production','confirmed']]])887 .filter([['product_cat','in',kategorije],[tStatus,'in',tStatusValue],['dressing','in',dressingT],['state','in',['ready','in_production','confirmed']]])
888 .order_by('product_id').all().then(function(results){ 888 .order_by('product_id').all().then(function(results){
889 for(i=0;i<results.length;i++){889 for(i=0;i<results.length;i++){
@@ -895,12 +895,16 @@
895 results[i].product_name = product_name;895 results[i].product_name = product_name;
896 results[i].product_code = product_code;896 results[i].product_code = product_code;
897 897
898 898 //Odstejemo nalozeno kolicino
899 results[i].product_qty_onstock = results[i].product_qty_onstock - results[i].product_on_bom_qty_ready
899 900
900 if (vrstaIzdelka=='Polizdelki_testo'){901 if (vrstaIzdelka=='Polizdelki_testo'){
901 results[i].produced=results[i].produced_phantom;902 results[i].produced=results[i].produced_phantom;
902 results[i].scrap=results[i].scrap_phantom;903 results[i].scrap=results[i].scrap_phantom;
903 results[i].product_delo=(results[i].product_qty - results[i].produced_phantom + results[i].scrap_phantom - results[i].product_on_bom_qty_ready);904 results[i].product_delo=(results[i].product_qty - results[i].produced_phantom + results[i].scrap_phantom
905 - results[i].product_on_bom_qty_ready -results[i].product_on_bom_qty_P_ready);
906 if (results[i].product_on_bom_qty_P_ready>0)
907 results[i].product_on_bom_qty_ready = results[i].product_on_bom_qty_ready + '('+results[i].product_on_bom_qty_P_ready+')'
904 }908 }
905 if (vrstaIzdelka=='Polizdelki'){909 if (vrstaIzdelka=='Polizdelki'){
906 results[i].product_delo=(results[i].produced_phantom-results[i].scrap_phantom-results[i].produced);910 results[i].product_delo=(results[i].produced_phantom-results[i].scrap_phantom-results[i].produced);
@@ -917,9 +921,6 @@
917 if (results[i].created_from_op == true)921 if (results[i].created_from_op == true)
918 results[i].product_qty = 0922 results[i].product_qty = 0
919 923
920 //Odstejemo nalozeno kolicino
921 results[i].product_qty_onstock = results[i].product_qty_onstock - results[i].product_on_bom_qty_ready
922
923 if (vrstaIzdelka=='Polizdelki_testo'){924 if (vrstaIzdelka=='Polizdelki_testo'){
924 iDelo = parseInt(results[i].product_delo);925 iDelo = parseInt(results[i].product_delo);
925 if (iDelo < 0) //if (sGotovo && (iDelo < 0))926 if (iDelo < 0) //if (sGotovo && (iDelo < 0))
@@ -1047,12 +1048,6 @@
1047 .data('parent', 'fillPolIzdelek')1048 .data('parent', 'fillPolIzdelek')
1048 .dialog("open");1049 .dialog("open");
1049 }1050 }
1050 else if (from_OP == 'true' && kol1 == 0){
1051 $("#label_value_warning").text("Izdelek je naročen na zalogo. Ali ga res ne želite premakniti v hladilnico?");
1052 $("#dialog-value-warning")
1053 .data('parent', 'fillPolIzdelek_OP')
1054 .dialog("open");
1055 }
1056 else{1051 else{
1057 mrp.call('set_izdelek_produced',[id1,kol_skupaj,kol1,1]);1052 mrp.call('set_izdelek_produced',[id1,kol_skupaj,kol1,1]);
1058 refreshRow(tip,'grid1',true,false,true,false,kol_skupaj,0,kol1,0);1053 refreshRow(tip,'grid1',true,false,true,false,kol_skupaj,0,kol1,0);
@@ -1299,7 +1294,7 @@
1299 mrp.call('set_hladilnica_produced',[id1,kol_skupaj,1]);1294 mrp.call('set_hladilnica_produced',[id1,kol_skupaj,1]);
1300 refreshRow_new('open','grid1',false,false,false,false,false,true,true,0,0,0,0,0,kol_skupaj,(kol_vdelu-kol));1295 refreshRow_new('open','grid1',false,false,false,false,false,true,true,0,0,0,0,0,kol_skupaj,(kol_vdelu-kol));
1301 }1296 }
1302 else if (arg == 'fillPolIzdelek' || arg == 'fillPolIzdelek_OP'){1297 else if (arg == 'fillPolIzdelek'){
1303 id1=$("#grid1").jqGrid('getCell',rId,0);1298 id1=$("#grid1").jqGrid('getCell',rId,0);
1304 id1=parseInt(id1);1299 id1=parseInt(id1);
1305 1300
13061301
=== modified file 'mrp_procurement_qty/__openerp__.py'
--- mrp_procurement_qty/__openerp__.py 2014-02-22 14:28:38 +0000
+++ mrp_procurement_qty/__openerp__.py 2014-02-25 17:17:51 +0000
@@ -49,6 +49,7 @@
49 'security/ir.model.access.csv',49 'security/ir.model.access.csv',
50 'mrp_production_view.xml',50 'mrp_production_view.xml',
51 'wizard/procurement_order_from_op_view.xml',51 'wizard/procurement_order_from_op_view.xml',
52 'wizard/procurement_order_move_stock_view.xml',
52 'bakery_production_view.xml',53 'bakery_production_view.xml',
53 'res_config_view.xml',54 'res_config_view.xml',
54 ],55 ],
5556
=== modified file 'mrp_procurement_qty/bakery_production.py'
--- mrp_procurement_qty/bakery_production.py 2014-02-22 14:28:38 +0000
+++ mrp_procurement_qty/bakery_production.py 2014-02-25 17:17:51 +0000
@@ -32,12 +32,14 @@
32 'duration': fields.char('Duration', size=8, readonly=True),32 'duration': fields.char('Duration', size=8, readonly=True),
33 'user_id': fields.many2one('res.users', 'User', readonly=True),33 'user_id': fields.many2one('res.users', 'User', readonly=True),
34 'running': fields.boolean('Running'),34 'running': fields.boolean('Running'),
35 'misc': fields.char('Misc.', size=128, readonly=True),
35 'process': fields.selection([36 'process': fields.selection([
36 ('10','Confirm sale orders'),37 ('10','Confirm sale orders'),
37 ('20','Procurement'),38 ('20','Procurement'),
38 ('30','Procurement with OP'),39 ('30','Procurement with OP'),
39 ('40','Deliver delivery orders'),40 ('40','Deliver delivery orders'),
40 ('50','Produce manufacturing orders')], 'Process', readonly=True),41 ('50','Produce manufacturing orders'),
42 ('60','Stock moved')], 'Process', readonly=True),
41 }43 }
42 _defaults = {44 _defaults = {
43 'date_start': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),45 'date_start': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
@@ -54,6 +56,8 @@
54 def process_end(self, cr, uid, process, process_id, production_id, context=None):56 def process_end(self, cr, uid, process, process_id, production_id, context=None):
55 57
56 date_start = self.browse(cr, uid, [process_id])[0]['date_start']58 date_start = self.browse(cr, uid, [process_id])[0]['date_start']
59 stock_moved = self.pool.get('bakery.production').browse(cr, uid, [production_id])[0]['stock_moved']
60
57 d_diff = datetime.now()-datetime.strptime(date_start, ('%Y-%m-%d %H:%M:%S'))61 d_diff = datetime.now()-datetime.strptime(date_start, ('%Y-%m-%d %H:%M:%S'))
58 total_secs = d_diff.seconds62 total_secs = d_diff.seconds
59 secs = total_secs % 6063 secs = total_secs % 60
@@ -89,6 +93,9 @@
89 self.pool.get('bakery.production').write(cr, uid, [production_id], {'manufactury_done':True,93 self.pool.get('bakery.production').write(cr, uid, [production_id], {'manufactury_done':True,
90 'running':False,94 'running':False,
91 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')})95 'date_end':time.strftime('%Y-%m-%d %H:%M:%S')})
96 elif process == '60':
97 self.pool.get('bakery.production').write(cr, uid, [production_id], {'stock_moved':not stock_moved})
98
92 return {}99 return {}
93 100
94 def process_running(self, cr, uid, process, context=None):101 def process_running(self, cr, uid, process, context=None):
@@ -118,6 +125,7 @@
118 'procurement_done': fields.boolean('Procurement done'),125 'procurement_done': fields.boolean('Procurement done'),
119 'op_procurement_done': fields.boolean('OP procurement done'),126 'op_procurement_done': fields.boolean('OP procurement done'),
120 'delivery_done': fields.boolean('Delivery done'),127 'delivery_done': fields.boolean('Delivery done'),
128 'stock_moved': fields.boolean('Stock moved'),
121 'manufactury_done': fields.boolean('Manufactury done'),129 'manufactury_done': fields.boolean('Manufactury done'),
122 }130 }
123 _defaults = {131 _defaults = {
@@ -136,11 +144,16 @@
136 144
137 running_id = self.search(cr, uid, [], order='id desc', limit=1, context=context)145 running_id = self.search(cr, uid, [], order='id desc', limit=1, context=context)
138 for line in self.browse(cr, uid, running_id):146 for line in self.browse(cr, uid, running_id):
139 if line.running:147 if line.running and line.stock_moved and process != '60' and process != '20':
148 res = _('Cannot run process. Stocks are moved!')
149
150 elif line.running:
140 if process == '10'and line.delivery_done:151 if process == '10'and line.delivery_done:
141 res = _('Cannot confirm Sale orders, since Delivery orders are already delivered!')152 res = _('Cannot confirm Sale orders, since Delivery orders are already delivered!')
142 elif process == '20'and line.delivery_done:153 elif process == '20'and line.delivery_done:
143 res = _('Cannot run Schedulers, since Delivery orders are already delivered!')154 res = _('Cannot run Scheduler, since Delivery orders are already delivered!')
155 elif process == '20'and not line.stock_moved:
156 res = _('Cannot run Schedulers. You must first move the stock and orderpoints!')
144 elif process == '30' and not line.procurement_done:157 elif process == '30' and not line.procurement_done:
145 res = _('Cannot run Scheduler from Orderpoint, since normal Scheduler has not been run yet!')158 res = _('Cannot run Scheduler from Orderpoint, since normal Scheduler has not been run yet!')
146 elif process == '40':159 elif process == '40':
@@ -150,9 +163,26 @@
150 res = _('Cannot deliver Delivery orders since production start date (%s) is not older than today!') %(d_start)163 res = _('Cannot deliver Delivery orders since production start date (%s) is not older than today!') %(d_start)
151 elif process == '50'and not line.delivery_done:164 elif process == '50'and not line.delivery_done:
152 res = _('Cannot finnish production, since Delivery orders have not been delivered yet!')165 res = _('Cannot finnish production, since Delivery orders have not been delivered yet!')
166 elif process == '60':
167 if not line.sale_done:
168 res = _('Sale not confirmed!')
169 elif line.delivery_done:
170 res = _('Delivery orders are delivered!')
171
153 else:172 else:
154 running_id = []173 running_id = []
155 174
156 return running_id, res175 return running_id, res
157 176
177 def is_stock_moved(self, cr, uid, process, context=None):
178 res = False
179 if context is None:
180 context = {'active_test':False}
181
182 running_id = self.search(cr, uid, [], order='id desc', limit=1, context=context)
183 for line in self.browse(cr, uid, running_id):
184 if line.running and line.stock_moved:
185 res = True
186 return res
187
158bakery_production()188bakery_production()
159189
=== modified file 'mrp_procurement_qty/bakery_production_view.xml'
--- mrp_procurement_qty/bakery_production_view.xml 2014-02-22 14:28:38 +0000
+++ mrp_procurement_qty/bakery_production_view.xml 2014-02-25 17:17:51 +0000
@@ -15,6 +15,7 @@
15 <field name="op_procurement_done"/>15 <field name="op_procurement_done"/>
16 <field name="delivery_done"/>16 <field name="delivery_done"/>
17 <field name="manufactury_done"/>17 <field name="manufactury_done"/>
18 <field name="stock_moved"/>
18 <field name="running"/>19 <field name="running"/>
19 </tree>20 </tree>
20 </field>21 </field>
@@ -28,6 +29,7 @@
28 <form string="Bakery production">29 <form string="Bakery production">
29 <group string="Status">30 <group string="Status">
30 <field name="running"/>31 <field name="running"/>
32 <field name="stock_moved"/>
31 <field name="date_start"/>33 <field name="date_start"/>
32 <field name="date_end"/>34 <field name="date_end"/>
33 </group>35 </group>
@@ -66,6 +68,7 @@
66 <field name="date_start"/>68 <field name="date_start"/>
67 <field name="date_end"/>69 <field name="date_end"/>
68 <field name="duration"/>70 <field name="duration"/>
71 <field name="misc"/>
69 <field name="running"/>72 <field name="running"/>
70 </tree>73 </tree>
71 </field>74 </field>
@@ -83,6 +86,7 @@
83 <field name="date_start"/>86 <field name="date_start"/>
84 <field name="date_end"/>87 <field name="date_end"/>
85 <field name="duration"/>88 <field name="duration"/>
89 <field name="misc"/>
86 <field name="running"/>90 <field name="running"/>
87 </group>91 </group>
88 </form>92 </form>
8993
=== modified file 'mrp_procurement_qty/mrp_production.py'
--- mrp_procurement_qty/mrp_production.py 2014-02-24 13:52:07 +0000
+++ mrp_procurement_qty/mrp_production.py 2014-02-25 17:17:51 +0000
@@ -52,7 +52,7 @@
52 context['product_id'] = vals['product_id']52 context['product_id'] = vals['product_id']
53 stock_values = self.pool.get('stock.location')._product_value(cr, user, [loc_id], ['stock_real'], arg=None, context=context)53 stock_values = self.pool.get('stock.location')._product_value(cr, user, [loc_id], ['stock_real'], arg=None, context=context)
54 54
55 vals['product_qty_onstock'] = stock_values[loc_id]['stock_real']55 vals['product_qty_onstock'] = int(stock_values[loc_id]['stock_real'])
56 res = super(mrp_production, self).create(cr, user, vals, context=context)56 res = super(mrp_production, self).create(cr, user, vals, context=context)
57 return res57 return res
58 58
@@ -151,7 +151,7 @@
151 if order_bom.produced != 0 and order_bom.product_with_bom_factor:151 if order_bom.produced != 0 and order_bom.product_with_bom_factor:
152 qty_reserved += (order_bom.produced*order_bom.product_with_bom_factor)152 qty_reserved += (order_bom.produced*order_bom.product_with_bom_factor)
153 #qty_from_stock += (order_bom.product_on_bom_qty_ready/order_bom.product_with_bom_factor) #kar je dano iz hladilnice153 #qty_from_stock += (order_bom.product_on_bom_qty_ready/order_bom.product_with_bom_factor) #kar je dano iz hladilnice
154 qty_from_stock += (order_bom.product_on_bom_qty_ready) #kar je dano iz hladilnice154 #qty_from_stock += (order_bom.product_on_bom_qty_ready) #ZADNJE
155 155
156 156
157 #Preveriti moram še ali je bilo kaj dano v košare157 #Preveriti moram še ali je bilo kaj dano v košare
@@ -186,10 +186,11 @@
186 _columns = {186 _columns = {
187 'created_from_op': fields.boolean('Created from orderpoint'),187 'created_from_op': fields.boolean('Created from orderpoint'),
188 'product_qty_onstock': fields.float('Product qty on stock', digits=(6,2)),188 'product_qty_onstock': fields.float('Product qty on stock', digits=(6,2)),
189 'product_qty_available': fields.function(_get_prod_qty_available, string='Product quantity available'),189 #'product_qty_available': fields.function(_get_prod_qty_available, string='Product quantity available'),
190 'product_on_bom_qty_available': fields.function(_get_prod_on_bom_qty_available, string='Product on BOM quantity available', multi='prepare0'),190 'product_on_bom_qty_available': fields.function(_get_prod_on_bom_qty_available, string='Product on BOM quantity available', multi='prepare0'),
191 'product_on_bom_qty_stock': fields.function(_get_prod_on_bom_qty_available, string='Product on BOM stock available', multi='prepare0'),191 'product_on_bom_qty_stock': fields.function(_get_prod_on_bom_qty_available, string='Product on BOM stock available', multi='prepare0'),
192 'product_on_bom_qty_ready': fields.float('Quantity from stock - make available', digits=(6,2)),192 'product_on_bom_qty_ready': fields.float('Load O from stock', digits=(6,2)),
193 'product_on_bom_qty_P_ready': fields.float('Load P from stock', digits=(6,2)),
193 'product_with_bom_factor': fields.function(_prepare_product_id, digits=(12,4), method=True, store=True, string='BOM factor', multi='prepare1'),194 'product_with_bom_factor': fields.function(_prepare_product_id, digits=(12,4), method=True, store=True, string='BOM factor', multi='prepare1'),
194 'product_with_bom_id': fields.function(_prepare_product_id, type='integer', method=True, store=True, string='Product with BOM id', multi='prepare1'),195 'product_with_bom_id': fields.function(_prepare_product_id, type='integer', method=True, store=True, string='Product with BOM id', multi='prepare1'),
195 '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'),196 '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'),
196197
=== modified file 'mrp_procurement_qty/mrp_production_view.xml'
--- mrp_procurement_qty/mrp_production_view.xml 2014-02-05 10:02:52 +0000
+++ mrp_procurement_qty/mrp_production_view.xml 2014-02-25 17:17:51 +0000
@@ -20,7 +20,6 @@
20 <field name="status_testo" />20 <field name="status_testo" />
21 </group>21 </group>
22 <group name="stock_st" string="Stock">22 <group name="stock_st" string="Stock">
23 <field name="product_qty_available" />
24 <field name="product_on_bom_qty_available" />23 <field name="product_on_bom_qty_available" />
25 <field name="product_with_bom_factor" />24 <field name="product_with_bom_factor" />
26 <field name="product_with_bom_id" />25 <field name="product_with_bom_id" />
2726
=== modified file 'mrp_procurement_qty/wizard/__init__.py'
--- mrp_procurement_qty/wizard/__init__.py 2014-02-17 15:12:21 +0000
+++ mrp_procurement_qty/wizard/__init__.py 2014-02-25 17:17:51 +0000
@@ -26,4 +26,5 @@
26import sale_order_journal26import sale_order_journal
27import delivery_order_return27import delivery_order_return
28import delivery_order_confirm28import delivery_order_confirm
29import procurement_order_from_op
30\ No newline at end of file29\ No newline at end of file
30import procurement_order_from_op
31import procurement_order_move_stock
31\ No newline at end of file32\ No newline at end of file
3233
=== modified file 'mrp_procurement_qty/wizard/procurement_order.py'
--- mrp_procurement_qty/wizard/procurement_order.py 2014-02-24 16:52:18 +0000
+++ mrp_procurement_qty/wizard/procurement_order.py 2014-02-25 17:17:51 +0000
@@ -115,18 +115,6 @@
115 sale_override = self.browse(cr,uid,ids)[0].override115 sale_override = self.browse(cr,uid,ids)[0].override
116 proc_obj = self.pool.get('procurement.order')116 proc_obj = self.pool.get('procurement.order')
117 117
118 #proc_jour_obj = self.pool.get('procurement.order.journal')
119 #Check if there is procurement already running for this day
120# proc_jour_ids = proc_jour_obj.search(cr, uid, [('state', '=' , True)])
121# if proc_jour_ids: #ce obstaja lansirana proizvodnja, preverimo ali je istega datuma
122# for proc_jour_line in proc_jour_obj.browse(cr, uid, proc_jour_ids):
123# if (proc_jour_line.date_start != time.strftime('%Y-%m-%d')):
124# raise osv.except_osv('Opozorilo!', u'Proizvodnja je že bila lansirana dne: %s.' % (proc_jour_line.date_start,))
125# else:
126# proc_jour_obj.create(cr, uid, {'date_start':time.strftime('%Y-%m-%d'),
127# 'state':True
128# })
129
130 #Preverimo ali obstaja aktiven zapis in nezakljucene dobavnice----------------------------------------118 #Preverimo ali obstaja aktiven zapis in nezakljucene dobavnice----------------------------------------
131 production_id, production_status = self.pool.get('bakery.production').production_running(cr, uid, '20')119 production_id, production_status = self.pool.get('bakery.production').production_running(cr, uid, '20')
132 if production_status: #dobavnice so ze potrjene120 if production_status: #dobavnice so ze potrjene
@@ -136,7 +124,7 @@
136 else:124 else:
137 production_id = production_id[0]125 production_id = production_id[0]
138 126
139 #Preverimo je lansiranje ze zagnano127 #Preverimo ce je lansiranje ze zagnano
140 process_status = self.pool.get('bakery.process').process_running(cr, uid, '20')128 process_status = self.pool.get('bakery.process').process_running(cr, uid, '20')
141 if not sale_override and process_status:129 if not sale_override and process_status:
142 raise osv.except_osv(_('Warning!'),process_status)130 raise osv.except_osv(_('Warning!'),process_status)
@@ -145,6 +133,10 @@
145 #------------------------------------------------------------------------------------------------------133 #------------------------------------------------------------------------------------------------------
146 134
147 135
136 ir_config_parameter = self.pool.get('ir.config_parameter')
137 ir_config_parameter.set_param(cr, uid, 'stock.empty_location_active', '1')
138 empty_location_id = safe_eval(ir_config_parameter.get_param(cr, uid, 'stock.empty_location', 'False'))
139
148 #Ce je stevilo ponovitev != 0 potem tolikokrat, drugace 4x140 #Ce je stevilo ponovitev != 0 potem tolikokrat, drugace 4x
149 repeat_number = self.browse(cr,uid,ids)[0].repeat_number141 repeat_number = self.browse(cr,uid,ids)[0].repeat_number
150 if repeat_number == 0:142 if repeat_number == 0:
@@ -152,96 +144,25 @@
152 elif repeat_number == -1:144 elif repeat_number == -1:
153 repeat_number = 0145 repeat_number = 0
154 146
155 147 cr.commit()
148 new_cr = pooler.get_db(cr.dbname).cursor()
149 use_new_cursor = new_cr.dbname
156 print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' - Start')150 print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' - Start')
157
158 #Najdelo Tocke narocanja in jih umaknemo za navadno lansiranje
159 context['created_from_op'] = False
160 orderpoint_ids = self.pool.get('stock.warehouse.orderpoint').search(cr, uid, [('product_id.product_tmpl_id.categ_id.id','!=', 4),
161 ('product_id.product_tmpl_id.categ_id.parent_id.id','!=', 4),
162 ('product_min_qty','>',0)
163 ])
164 for orderpoint in self.pool.get('stock.warehouse.orderpoint').browse(cr, uid, orderpoint_ids):
165 self.pool.get('stock.warehouse.orderpoint').write(cr, uid, [orderpoint.id],
166 {'temp_min_qty':orderpoint.product_min_qty,
167 'temp_max_qty':orderpoint.product_max_qty,
168 'product_min_qty':0,
169 'product_max_qty':0,
170 })
171 ir_config_parameter = self.pool.get('ir.config_parameter')
172 ir_config_parameter.set_param(cr, uid, 'stock.empty_location_active', '1')
173 empty_location_id = safe_eval(ir_config_parameter.get_param(cr, uid, 'stock.empty_location', 'False'))
174
175 _sql_string0 = """UPDATE stock_move sm
176 SET
177 location_id =
178 case
179 when location_id = 12 then """ + str(empty_location_id) + """
180 else location_id
181 end,
182 location_dest_id =
183 case
184 when location_dest_id = 12 then """ + str(empty_location_id) + """
185 else location_dest_id
186 end
187 where
188 (
189 sm.location_id = 12 or location_dest_id = 12
190 )
191 and
192 (
193 select 1 from product_template pt
194 inner join product_category pc on
195 pc.id = pt.categ_id and
196 pc.parent_id in(34, 38)
197 where pt.id = sm.product_id
198 ) = 1 and sm.basket_status <> 3"""
199 cr.execute(_sql_string0)
200 cr.commit() #Ker se ustvari nov kurzor moramo vse spremembe commitnit ---------------------------------------------------
201 _sql_string01 = """UPDATE stock_move
202 SET
203 location_id =
204 case
205 when location_id = """ + str(empty_location_id) + """ then 12
206 else location_id
207 end,
208 location_dest_id =
209 case
210 when location_dest_id = """ + str(empty_location_id) + """ then 12
211 else location_dest_id
212 end
213 where
214 (
215 location_id = """ + str(empty_location_id) + """ or location_dest_id = """ + str(empty_location_id) + """
216 )"""
217
218
219 use_new_cursor = cr.dbname
220 new_cr = pooler.get_db(cr.dbname).cursor()
221 for x in range(0, repeat_number):151 for x in range(0, repeat_number):
222 try:152 try:
223 #proc_obj.run_scheduler(new_cr, uid, automatic=False, use_new_cursor=new_cr.dbname, context=context)
224 produrement_ids = proc_obj.search(new_cr, uid, [('state', '=', 'confirmed'),153 produrement_ids = proc_obj.search(new_cr, uid, [('state', '=', 'confirmed'),
225 ('procure_method', '=', 'make_to_stock')])154 ('procure_method', '=', 'make_to_stock')])
226 proc_obj._procure_confirm(new_cr, uid, ids=produrement_ids, use_new_cursor=use_new_cursor, context=context)155 proc_obj._procure_confirm(new_cr, uid, ids=produrement_ids, use_new_cursor=use_new_cursor, context=context)
227 proc_obj._procure_orderpoint_confirm(new_cr, uid, automatic=False, use_new_cursor=use_new_cursor, context=context)156 proc_obj._procure_orderpoint_confirm(new_cr, uid, automatic=False, use_new_cursor=use_new_cursor, context=context)
157
158 self.pool.get('bakery.process').write(new_cr, uid, [process_id], {'misc':str(x+1)})
159
228 new_cr.commit() 160 new_cr.commit()
229 except Exception, e:161 except Exception, e:
230 new_cr.rollback()162 new_cr.rollback()
231 new_cr.close()163 new_cr.close()
232 #Tocko narocanja vrnemo nazaj164
233 orderpoint_ids = self.pool.get('stock.warehouse.orderpoint').search(cr, uid, [('product_id.product_tmpl_id.categ_id.id','!=', 4),165 raise osv.except_osv('Opozorilo!', u'Napaka lansiranja v %s. krogu. Err: %s' % (str(x+1), str(e)))
234 ('product_id.product_tmpl_id.categ_id.parent_id.id','!=', 4),
235 ('temp_min_qty','>',0)
236 ])
237 for orderpoint in self.pool.get('stock.warehouse.orderpoint').browse(cr, uid, orderpoint_ids):
238 self.pool.get('stock.warehouse.orderpoint').write(cr, uid, [orderpoint.id],
239 {'product_min_qty':orderpoint.temp_min_qty,
240 'product_max_qty':orderpoint.temp_max_qty,
241 })
242 cr.execute(_sql_string01) #zalogo postavimo nazaj na 12
243 cr.commit()
244 raise osv.except_osv('Opozorilo!', u'Napaka lansiranja v %s. krogu. Err: %s' % (str(x), str(e)))
245 return{}166 return{}
246 print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' - Close: ' + str(x+1))167 print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' - Close: ' + str(x+1))
247 #------------------------------------------------------------------------------------------------------------------------168 #------------------------------------------------------------------------------------------------------------------------
@@ -254,112 +175,6 @@
254 raise osv.except_osv('Opozorilo!', 'Napaka pri zdruzevanju d.n.:' + str(e))175 raise osv.except_osv('Opozorilo!', 'Napaka pri zdruzevanju d.n.:' + str(e))
255 return{}176 return{}
256 #-------------------------------------------------------------------------------------------177 #-------------------------------------------------------------------------------------------
257 try:
258 orderpoint_ids = self.pool.get('stock.warehouse.orderpoint').search(new_cr, uid, [('product_id.product_tmpl_id.categ_id.id','!=', 4),
259 ('product_id.product_tmpl_id.categ_id.parent_id.id','!=', 4),
260 ('temp_min_qty','>',0)
261 ])
262 for orderpoint in self.pool.get('stock.warehouse.orderpoint').browse(new_cr, uid, orderpoint_ids):
263 self.pool.get('stock.warehouse.orderpoint').write(new_cr, uid, [orderpoint.id],
264 {'product_min_qty':orderpoint.temp_min_qty,
265 'product_max_qty':orderpoint.temp_max_qty,
266 'temp_min_qty':0,
267 'temp_max_qty':0,
268 })
269 new_cr.commit()
270 except Exception, e:
271 new_cr.rollback()
272 new_cr.close()
273 raise osv.except_osv('Opozorilo!', 'Napaka pri premiku orderpoint-a nazaj; ' + str(e))
274 return{}
275 #-------------------------------------------------------------------------------------------
276 #String napisal ze prej
277 try:
278 new_cr.execute(_sql_string01)
279 new_cr.commit() #Da si nalozimo sprememb
280 except Exception, e:
281 new_cr.rollback()
282 new_cr.close()
283 raise osv.except_osv('Opozorilo!', 'Napaka pri premiku lokacije nazaj; ' +str(e))
284 return{}
285
286 #-------------------------------------------------------------------------------------------
287 _sql_string1 = """update mrp_production
288 SET status_testo = 0, status_izdelki = 0
289 WHERE status_testo = 3 or status_izdelki = 3;"""
290 try:
291 new_cr.execute(_sql_string1)
292 new_cr.commit()
293 except Exception, e:
294 new_cr.rollback()
295 new_cr.close()
296 raise osv.except_osv('Opozorilo!', 'Napaka pri zagonu query-ja: status_testo; ' +str(e))
297 return{}
298 #-------------------------------------------------------------------------------------------
299
300 _sql_string2 = """update stock_move
301 SET basket_status = 2
302 WHERE basket_status = 3 AND state = 'done';"""
303
304 try:
305 new_cr.execute(_sql_string2)
306 new_cr.commit()
307 except Exception, e:
308 new_cr.rollback()
309 new_cr.close()
310 raise osv.except_osv('Opozorilo!', 'Napaka pri zagonu query-ja: basket_status_2_done; ' +str(e))
311 return{}
312 #--------------------------------------------------------------------------------------------
313
314 _sql_string2a = """update stock_move
315 SET basket_status = 0
316 WHERE basket_status = 3;"""
317
318 try:
319 new_cr.execute(_sql_string2a)
320 new_cr.commit()
321 except Exception, e:
322 new_cr.rollback()
323 new_cr.close()
324 raise osv.except_osv('Opozorilo!', 'Napaka pri zagonu query-ja: basket_status_0; ' +str(e))
325 return{}
326 #--------------------------------------------------------------------------------------------
327
328 _sql_string3 = """update stock_move upd
329 set basket_status = 2
330 where
331 not upd.id in
332 (
333
334 select id from stock_move mov
335 where mov.basket_status <> 2 and mov.location_id = 12
336 and exists(
337 select * from stock_picking pic
338 where
339 pic.id = mov.picking_id and
340 pic.type = 'out'
341 )
342
343 ) and basket_status != 2;"""
344 try:
345 new_cr.execute(_sql_string3)
346 new_cr.commit()
347 except Exception, e:
348 new_cr.rollback()
349 new_cr.close()
350 raise osv.except_osv('Opozorilo!', 'Napaka pri zagonu query-ja: basket_status2; ' +str(e))
351 return{}
352 #--------------------------------------------------------------------------------------------
353 try:
354 self.pool.get('stock.move').get_qty_delivery_available(new_cr, uid)
355 new_cr.commit()
356 except Exception, e:
357 new_cr.rollback()
358 new_cr.close()
359 raise osv.except_osv('Opozorilo!', 'Napaka pri zagonu query-ja delivery_available' + str(e))
360 finally:
361 new_cr.close()
362
363 178
364 print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' - KONEC Lansiranja')179 print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' - KONEC Lansiranja')
365 self.pool.get('bakery.process').process_end(cr, uid, '20', process_id, production_id)180 self.pool.get('bakery.process').process_end(cr, uid, '20', process_id, production_id)
366181
=== modified file 'mrp_procurement_qty/wizard/procurement_order_from_op_view.xml'
--- mrp_procurement_qty/wizard/procurement_order_from_op_view.xml 2014-02-17 15:12:21 +0000
+++ mrp_procurement_qty/wizard/procurement_order_from_op_view.xml 2014-02-25 17:17:51 +0000
@@ -30,6 +30,6 @@
30 key2="client_action_multi"30 key2="client_action_multi"
31 id="action_run_scheduler_orderpoint_multiple_times"/> 31 id="action_run_scheduler_orderpoint_multiple_times"/>
3232
33 <menuitem action="action_run_scheduler_orderpoint_multiple_times" id="menu_run_scheduler_orderpoint_multiple_times" parent="procurement.menu_stock_sched" sequence="20"/>33 <menuitem action="action_run_scheduler_orderpoint_multiple_times" id="menu_run_scheduler_orderpoint_multiple_times" parent="procurement.menu_stock_sched" sequence="23"/>
34 </data>34 </data>
35</openerp>35</openerp>
3636
=== added file 'mrp_procurement_qty/wizard/procurement_order_move_stock.py'
--- mrp_procurement_qty/wizard/procurement_order_move_stock.py 1970-01-01 00:00:00 +0000
+++ mrp_procurement_qty/wizard/procurement_order_move_stock.py 2014-02-25 17:17:51 +0000
@@ -0,0 +1,199 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2013 Mentis d.o.o.
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from osv import fields, osv
23#from openerp import pooler
24#from datetime import datetime
25#import time
26from tools.translate import _
27from openerp.tools.safe_eval import safe_eval
28
29class procurement_order_move_stock_wizard(osv.osv_memory):
30 _name = "procurement.order.move.stock.wizard"
31 _description = "Move stock and order points"
32
33 def _get_status_move(self, cr, uid, context):
34 return self.pool.get('bakery.production').is_stock_moved(cr, uid, '60', context=None)
35
36 def _get_status(self, cr, uid, context):
37 return self.pool.get('bakery.process').process_running(cr, uid, '60', context=None)
38
39 _columns = {
40 'status_move': fields.boolean('Stock moved', readonly=True),
41 'status': fields.char('Running status', size=128, readonly=True),
42 'override': fields.boolean('Override running process', help='Run the process, even if there is another one running'),
43 }
44 _defaults = {
45 'status_move': _get_status_move,
46 'status': _get_status,
47 }
48
49
50 def execute(self, cr, uid, ids, context=None):
51 if context is None:
52 context = {}
53
54 sale_override = self.browse(cr,uid,ids)[0].override
55
56 #Preverimo ali obstaja aktiven zapis ------------------------------------------------------------------
57 production_id, production_status = self.pool.get('bakery.production').production_running(cr, uid, '60')
58 if production_status: #dobavnice so ze potrjene
59 raise osv.except_osv(_('Warning!'),production_status)
60 if production_id == []: #se ne obstaja aktiven zapis
61 raise osv.except_osv(_('Warning!'),_('Sale orders have today not been confirmed yet!'))
62 else:
63 production_id = production_id[0]
64
65 #Preverimo je lansiranje ze zagnano
66 process_status = self.pool.get('bakery.process').process_running(cr, uid, '60')
67 if not sale_override and process_status:
68 raise osv.except_osv(_('Warning!'),process_status)
69 else:
70 process_id = self.pool.get('bakery.process').process_start(cr, uid, '60')
71 cr.commit()
72 #------------------------------------------------------------------------------------------------------
73
74 ir_config_parameter = self.pool.get('ir.config_parameter')
75 empty_location_id = safe_eval(ir_config_parameter.get_param(cr, uid, 'stock.empty_location', 'False'))
76
77 stock_moved = self.pool.get('bakery.production').is_stock_moved(cr, uid, '60', context=None)
78 if not stock_moved:
79 #1. Najdemo tocke narocanja in jih umaknemo za navadno lansiranje
80 orderpoint_ids = self.pool.get('stock.warehouse.orderpoint').search(cr, uid, [('product_id.product_tmpl_id.categ_id.id','!=', 4),
81 ('product_id.product_tmpl_id.categ_id.parent_id.id','!=', 4),
82 ('product_min_qty','>',0)
83 ])
84 for orderpoint in self.pool.get('stock.warehouse.orderpoint').browse(cr, uid, orderpoint_ids):
85 self.pool.get('stock.warehouse.orderpoint').write(cr, uid, [orderpoint.id],
86 {'temp_min_qty':orderpoint.product_min_qty,
87 'temp_max_qty':orderpoint.product_max_qty,
88 'product_min_qty':0,
89 'product_max_qty':0,
90 })
91
92 #2. Premaknemo zalogo na zacasno lokacijo
93
94
95 _sql_string0 = """UPDATE stock_move sm
96 SET
97 location_id =
98 case
99 when location_id = 12 then """ + str(empty_location_id) + """
100 else location_id
101 end,
102 location_dest_id =
103 case
104 when location_dest_id = 12 then """ + str(empty_location_id) + """
105 else location_dest_id
106 end
107 where
108 (
109 sm.location_id = 12 or location_dest_id = 12
110 )
111 and
112 (
113 select 1 from product_template pt
114 inner join product_category pc on
115 pc.id = pt.categ_id and
116 pc.parent_id in(34, 38)
117 where pt.id = sm.product_id
118 ) = 1 and sm.basket_status = 2"""
119 cr.execute(_sql_string0)
120
121 else:
122 orderpoint_ids = self.pool.get('stock.warehouse.orderpoint').search(cr, uid, [('product_id.product_tmpl_id.categ_id.id','!=', 4),
123 ('product_id.product_tmpl_id.categ_id.parent_id.id','!=', 4),
124 ('temp_min_qty','>',0)
125 ])
126 for orderpoint in self.pool.get('stock.warehouse.orderpoint').browse(cr, uid, orderpoint_ids):
127 self.pool.get('stock.warehouse.orderpoint').write(cr, uid, [orderpoint.id],
128 {'product_min_qty':orderpoint.temp_min_qty,
129 'product_max_qty':orderpoint.temp_max_qty,
130 'temp_min_qty':0,
131 'temp_max_qty':0,
132 })
133
134 _sql_string01 = """UPDATE stock_move
135 SET
136 location_id =
137 case
138 when location_id = """ + str(empty_location_id) + """ then 12
139 else location_id
140 end,
141 location_dest_id =
142 case
143 when location_dest_id = """ + str(empty_location_id) + """ then 12
144 else location_dest_id
145 end
146 where
147 (
148 location_id = """ + str(empty_location_id) + """ or location_dest_id = """ + str(empty_location_id) + """
149 )"""
150
151
152 cr.execute(_sql_string01)
153 #-------------------------------------------------------------------------------------------
154
155 _sql_string1 = """update mrp_production
156 SET status_testo = 0, status_izdelki = 0
157 WHERE status_testo = 3 or status_izdelki = 3;"""
158 cr.execute(_sql_string1)
159 #-------------------------------------------------------------------------------------------
160
161 _sql_string2 = """update stock_move
162 SET basket_status = 2
163 WHERE basket_status = 3 AND state = 'done';"""
164
165 cr.execute(_sql_string2)
166 #--------------------------------------------------------------------------------------------
167
168 _sql_string2a = """update stock_move
169 SET basket_status = 0
170 WHERE basket_status = 3;"""
171 cr.execute(_sql_string2a)
172 #--------------------------------------------------------------------------------------------
173
174 _sql_string3 = """update stock_move upd
175 set basket_status = 2
176 where
177 not upd.id in
178 (
179
180 select id from stock_move mov
181 where mov.basket_status <> 2 and mov.location_id = 12
182 and exists(
183 select * from stock_picking pic
184 where
185 pic.id = mov.picking_id and
186 pic.type = 'out'
187 )
188
189 ) and basket_status != 2;"""
190 cr.execute(_sql_string3)
191 #--------------------------------------------------------------------------------------------
192 self.pool.get('stock.move').get_qty_delivery_available(cr, uid)
193
194
195 self.pool.get('bakery.process').process_end(cr, uid, '60', process_id, production_id)
196 return{}
197
198procurement_order_move_stock_wizard()
199
0200
=== added file 'mrp_procurement_qty/wizard/procurement_order_move_stock_view.xml'
--- mrp_procurement_qty/wizard/procurement_order_move_stock_view.xml 1970-01-01 00:00:00 +0000
+++ mrp_procurement_qty/wizard/procurement_order_move_stock_view.xml 2014-02-25 17:17:51 +0000
@@ -0,0 +1,34 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <record id="multiple_move_stock_wizard_view" model="ir.ui.view">
5 <field name="name">Move stock and order points</field>
6 <field name="model">procurement.order.move.stock.wizard</field>
7 <field name="arch" type="xml">
8 <form string="Move stock and order points - view" version="7.0">
9 <group>
10 <separator string="Status" colspan="4" />
11 <field name="status_move" />
12 <field name="status" />
13 <field name="override" />
14 </group>
15 <footer>
16 <button name="execute" string="Move stock" type="object" class="oe_highlight"/>
17 or
18 <button special="cancel" string="Cancel" class="oe_link"/>
19 </footer>
20 </form>
21 </field>
22 </record>
23
24 <act_window name="Move stock and order points"
25 res_model="procurement.order.move.stock.wizard"
26 src_model="procurement.order"
27 view_mode="form"
28 target="new"
29 key2="client_action_multi"
30 id="action_move_stock_order_points"/>
31
32 <menuitem action="action_move_stock_order_points" id="menu_move_stock_order_points" parent="procurement.menu_stock_sched" sequence="21"/>
33 </data>
34</openerp>
035
=== modified file 'mrp_procurement_qty/wizard/procurement_order_view.xml'
--- mrp_procurement_qty/wizard/procurement_order_view.xml 2014-02-17 15:12:21 +0000
+++ mrp_procurement_qty/wizard/procurement_order_view.xml 2014-02-25 17:17:51 +0000
@@ -30,6 +30,6 @@
30 key2="client_action_multi"30 key2="client_action_multi"
31 id="action_run_scheduler_multiple_times"/> 31 id="action_run_scheduler_multiple_times"/>
3232
33 <menuitem action="action_run_scheduler_multiple_times" id="menu_run_scheduler_multiple_times" parent="procurement.menu_stock_sched" sequence="20"/>33 <menuitem action="action_run_scheduler_multiple_times" id="menu_run_scheduler_multiple_times" parent="procurement.menu_stock_sched" sequence="22"/>
34 </data>34 </data>
35</openerp>35</openerp>

Subscribers

People subscribed via source and target branches