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