Merge lp:~openbig/bigconsulting/added_changes_as_new_speci into lp:bigconsulting
- added_changes_as_new_speci
- Merge into addons
Proposed by
gpa(OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 15 |
Proposed branch: | lp:~openbig/bigconsulting/added_changes_as_new_speci |
Merge into: | lp:bigconsulting |
Diff against target: |
888 lines (+759/-46) 11 files modified
stock_minimum_calculator/__init__.py (+2/-1) stock_minimum_calculator/__terp__.py (+5/-1) stock_minimum_calculator/stock_minimujm_calculator_wizard.xml (+11/-0) stock_minimum_calculator/stock_minimum_calculator.py (+115/-15) stock_minimum_calculator/stock_minimum_calculator_sequence.xml (+17/-0) stock_minimum_calculator/stock_minimum_calculator_view.xml (+213/-29) stock_minimum_calculator/stock_order_point_calculator.py (+217/-0) stock_minimum_calculator/stock_order_point_calculator_view.xml (+50/-0) stock_minimum_calculator/wizard/__init__.py (+26/-0) stock_minimum_calculator/wizard/seasonal_trend_set.py (+71/-0) stock_minimum_calculator/wizard/seasonal_trend_set_view.xml (+32/-0) |
To merge this branch: | bzr merge lp:~openbig/bigconsulting/added_changes_as_new_speci |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
openbig | Pending | ||
Review via email: mp+27165@code.launchpad.net |
Commit message
Description of the change
Added changes as new specification on stock_minimum_
To post a comment you must log in.
- 14. By gpa(OpenERP)
-
changes on the stock_minimum_
calculator - 15. By gpa(OpenERP)
-
changes on stock_minimum_
calculator optimated lead time - 16. By gpa(OpenERP)
-
changes in stock_minimum_
calculator added constraint on valid - 17. By gpa(OpenERP)
-
modify on stock_minimum_
calcularot - 18. By gpa(OpenERP)
-
added sequence number to minimum rule name
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'stock_minimum_calculator/__init__.py' |
2 | --- stock_minimum_calculator/__init__.py 2010-05-26 14:22:22 +0000 |
3 | +++ stock_minimum_calculator/__init__.py 2010-06-11 07:44:24 +0000 |
4 | @@ -21,5 +21,6 @@ |
5 | ############################################################################## |
6 | |
7 | import stock_minimum_calculator |
8 | - |
9 | +import wizard |
10 | +import stock_order_point_calculator |
11 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
12 | \ No newline at end of file |
13 | |
14 | === modified file 'stock_minimum_calculator/__terp__.py' |
15 | --- stock_minimum_calculator/__terp__.py 2010-05-26 14:22:22 +0000 |
16 | +++ stock_minimum_calculator/__terp__.py 2010-06-11 07:44:24 +0000 |
17 | @@ -31,7 +31,11 @@ |
18 | """, |
19 | "depends": ['stock','mrp'], |
20 | "demo_xml": [], |
21 | - "update_xml": ['stock_minimum_calculator_view.xml' ], |
22 | + "update_xml": ['stock_minimum_calculator_view.xml', |
23 | + "stock_minimujm_calculator_wizard.xml", |
24 | + "stock_order_point_calculator_view.xml", |
25 | + "stock_minimum_calculator_sequence.xml" |
26 | + ], |
27 | "license": "GPL-3", |
28 | "active": False, |
29 | "installable": True, |
30 | |
31 | === added file 'stock_minimum_calculator/stock_minimujm_calculator_wizard.xml' |
32 | --- stock_minimum_calculator/stock_minimujm_calculator_wizard.xml 1970-01-01 00:00:00 +0000 |
33 | +++ stock_minimum_calculator/stock_minimujm_calculator_wizard.xml 2010-06-11 07:44:24 +0000 |
34 | @@ -0,0 +1,11 @@ |
35 | +<?xml version="1.0" encoding="utf-8"?> |
36 | +<openerp> |
37 | + <data> |
38 | + <wizard |
39 | + string="Set Seasonal Trend" |
40 | + model="product.product" |
41 | + name="set_seasonal.trend" |
42 | + menu="True" |
43 | + id="id_set_seasonal_trend"/> |
44 | + </data> |
45 | +</openerp> |
46 | |
47 | === modified file 'stock_minimum_calculator/stock_minimum_calculator.py' |
48 | --- stock_minimum_calculator/stock_minimum_calculator.py 2010-05-26 14:22:22 +0000 |
49 | +++ stock_minimum_calculator/stock_minimum_calculator.py 2010-06-11 07:44:24 +0000 |
50 | @@ -21,20 +21,120 @@ |
51 | ############################################################################## |
52 | from osv import fields, osv |
53 | from tools.translate import _ |
54 | - |
55 | -class stock_minimum_calculator(osv.osv_memory): |
56 | - _name = 'stock.minimum.calculator' |
57 | - |
58 | - def set_default(self, cr, uid, ids, context=None): |
59 | - product_obj = self.pool.get('product.product') |
60 | - min_rule_obj = self.pool.get('stock.warehouse.orderpoint') |
61 | - stock_rule_ids = min_rule_obj.search(cr,uid,[]) |
62 | - FIELDS = ['qty_available','virtual_available','incoming_qty','outgoing_qty'] |
63 | - for rule_record in min_rule_obj.browse(cr, uid, stock_rule_ids, context=context): |
64 | - context.update({'warehouse':rule_record.warehouse_id.id,'location':rule_record.location_id.id}) |
65 | - data = product_obj._product_available(cr,uid,[rule_record.product_id.id],FIELDS,context=context) |
66 | - return {} |
67 | - |
68 | -stock_minimum_calculator() |
69 | +import time |
70 | + |
71 | +class stock_holding_rate(osv.osv): |
72 | + _name = "stock.holding.rate" |
73 | + _columns = { |
74 | + 'rate_id':fields.char("ID",size=64, required=True), |
75 | + 'name':fields.char("Name",size=64, required=True), |
76 | + 'stock_hold_rate':fields.float("Stock Holding Rate"), |
77 | + 'date_start': fields.date('Start Date', required=True), |
78 | + 'date_stop': fields.date('End Date', required=True), |
79 | + 'active': fields.boolean('Active'), |
80 | + 'holding_ids': fields.one2many('supplier.product', 'suppinfo_id', 'Supplier'), |
81 | + } |
82 | +stock_holding_rate() |
83 | + |
84 | + |
85 | +class supplier_product(osv.osv): |
86 | + _name = 'supplier.product' |
87 | + _rec_name = 'partner_id' |
88 | + _columns = { |
89 | + 'suppinfo_id': fields.many2one('stock.holding.rate', 'Holding',), |
90 | + 'partner_id': fields.many2one('res.partner', 'Suplier Information',), |
91 | + 'supp_stock':fields.float("Supplier Stock"), |
92 | + } |
93 | + |
94 | +supplier_product() |
95 | + |
96 | +class res_partner(osv.osv): |
97 | + _inherit = "res.partner" |
98 | + _columns = { |
99 | + 'stock_holding_rate_id':fields.many2one("stock.holding.rate",'Holding Rate'), |
100 | + } |
101 | +res_partner() |
102 | + |
103 | + |
104 | +class supplier_cost_opti_lead_time(osv.osv): |
105 | + _name = "supplier.cost.opti.lead.time" |
106 | + _columns = { |
107 | + 'supp_cost_id':fields.char("ID",size=64, required=True), |
108 | + 'name':fields.char("Name of the rule",size=64, required=True), |
109 | + 'partner_id': fields.many2one('res.partner', 'Suplier'), |
110 | + 'date_start': fields.date('Date', required=True), |
111 | + 'active': fields.boolean('Active'), |
112 | + 'yrl_purchase_rev':fields.float("YRL Purchase Revenue",required=True), |
113 | + 'economic_no_order':fields.float("Economic Number of orders",readonly=True), |
114 | + 'cost_per_del':fields.float("Cost Per Delivery",required=True), |
115 | + 'economic_lead_time':fields.float("Economic Lead Time",readonly=True), |
116 | + 'stock_holding_rate_id':fields.many2one("stock.holding.rate",'Holding Rate',required=True), |
117 | + 'staus': fields.selection([ |
118 | + ('draft','Draft'), |
119 | + ('valid','Valid'), |
120 | + ('cancel','Cancel'), |
121 | + ],'Status',readonly=True), |
122 | + } |
123 | + _defaults = { |
124 | + 'date_start': lambda *a: time.strftime('%Y-%m-%d'), |
125 | + } |
126 | + |
127 | + def action_compute(self, cr, uid, ids, context={}): |
128 | + for id in ids: |
129 | + cost_op = self.browse(cr, uid,id,context=context) |
130 | + economic_numer_orders = (cost_op.yrl_purchase_rev * cost_op.stock_holding_rate_id.stock_hold_rate)/ (2*cost_op.cost_per_del) |
131 | + economic_lead_time = 360 / economic_numer_orders |
132 | + self.write(cr, uid, [id],{'economic_lead_time':economic_lead_time,'economic_no_order':economic_numer_orders}) |
133 | + return True |
134 | + |
135 | + def action_cancel(self, cr, uid, ids, context={}): |
136 | + for o in self.browse(cr, uid, ids): |
137 | + self.write(cr, uid, [o.id], {'staus': 'cancel'}) |
138 | + return True |
139 | + |
140 | + def action_validate(self, cr, uid, ids, context={}): |
141 | + for o in self.browse(cr, uid, ids): |
142 | + already_id = self_obj.search(cr, uid, [('partner_id','=',o.partner_id.id),('id', 'not in', ids),('staus','=','valid')]) |
143 | + if already_id: |
144 | + old_partner_id = self.browse(cr, uid, already_id[0]) |
145 | + if o.partner_id.id == old_partner_id.partner_id.id: |
146 | + raise osv.except_osv(_('Error !'), |
147 | + _('You can not this partner becasue this partner aleready with valid entry')) |
148 | + self.write(cr, uid, [o.id], {'staus': 'valid'}) |
149 | + return True |
150 | + |
151 | +supplier_cost_opti_lead_time() |
152 | + |
153 | +class product_seasonal(osv.osv): |
154 | + _name = 'product.seasonal' |
155 | + _columns = { |
156 | + 'name':fields.char("Seasonal Name",size=64, required=True), |
157 | + 'code':fields.char("Code",size=64, required=True), |
158 | + 'seasonal_factor':fields.float("Seasonal Factor"), |
159 | + } |
160 | + |
161 | +product_seasonal() |
162 | + |
163 | +class product_product(osv.osv): |
164 | + _inherit = "product.product" |
165 | + _columns = { |
166 | + 'seasonal_id':fields.many2one("product.seasonal",'Seasonal Model'), |
167 | + 'plan_avg_consume':fields.float("Plan Average Daily Consumption"), |
168 | + } |
169 | +product_product() |
170 | + |
171 | + |
172 | +class stock_warehosue_orderpoint_period(osv.osv): |
173 | + ### Add for percenatage of the period |
174 | + _name = "stock.warehosue.orderpoint.period" |
175 | + _columns = { |
176 | + 'name':fields.char("Name",size=64,required=True), |
177 | + 'product_id':fields.many2one('product.product', 'Product',required=True), |
178 | + 'partner_id':fields.many2one('res.partner','Partner',required=True), |
179 | + 'period_id' :fields.many2one('account.period',"Period",required=True), |
180 | + 'percentage':fields.float("Percenatage",required=True), |
181 | + } |
182 | + |
183 | +stock_warehosue_orderpoint_period() |
184 | |
185 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
186 | \ No newline at end of file |
187 | |
188 | === added file 'stock_minimum_calculator/stock_minimum_calculator_sequence.xml' |
189 | --- stock_minimum_calculator/stock_minimum_calculator_sequence.xml 1970-01-01 00:00:00 +0000 |
190 | +++ stock_minimum_calculator/stock_minimum_calculator_sequence.xml 2010-06-11 07:44:24 +0000 |
191 | @@ -0,0 +1,17 @@ |
192 | +<?xml version="1.0" encoding="utf-8"?> |
193 | +<openerp> |
194 | + <data noupdate="1"> |
195 | + <!-- Sequences for stock.orderpoint.step2 --> |
196 | + <record id="sequence_stock_op_point" model="ir.sequence.type"> |
197 | + <field name="name">Stock orderpoint step2</field> |
198 | + <field name="code">stock.orderpoint.step2</field> |
199 | + </record> |
200 | + <record id="sequence_stock_op" model="ir.sequence"> |
201 | + <field name="name">Stock orderpoint step2</field> |
202 | + <field name="code">stock.orderpoint.step2</field> |
203 | + <field name="prefix">OP/</field> |
204 | + <field name="padding">5</field> |
205 | + <field name="number_increment">1</field> |
206 | + </record> |
207 | + </data> |
208 | +</openerp> |
209 | |
210 | === modified file 'stock_minimum_calculator/stock_minimum_calculator_view.xml' |
211 | --- stock_minimum_calculator/stock_minimum_calculator_view.xml 2010-05-26 14:22:22 +0000 |
212 | +++ stock_minimum_calculator/stock_minimum_calculator_view.xml 2010-06-11 07:44:24 +0000 |
213 | @@ -1,35 +1,219 @@ |
214 | <?xml version="1.0" encoding="utf-8"?> |
215 | <openerp> |
216 | <data> |
217 | - <record id="view_stock_minimum_calculator_form" model="ir.ui.view"> |
218 | - <field name="name">stock.minimum.calculator.form</field> |
219 | - <field name="model">stock.minimum.calculator</field> |
220 | - <field name="type">form</field> |
221 | - <field name="arch" type="xml"> |
222 | - <form string="Stock Rule Computation"> |
223 | - <separator string="Stock Rule Computation" colspan="4" /> |
224 | - <label align="0.7" colspan="4" string="Would you like to re-calculation Minimum stock Rule?"/> |
225 | - <separator string="" colspan="4" /> |
226 | - <label string ="" colspan="2"/> |
227 | - <button icon="gtk-cancel" special="cancel" string="Cancel" colspan="1"/> |
228 | - <button icon="gtk-ok" string="Re-compute" name="set_default" type="object" colspan="1"/> |
229 | - </form> |
230 | - </field> |
231 | - </record> |
232 | - |
233 | - <record id="action_stock_minimum_calculator" model="ir.actions.act_window"> |
234 | - <field name="name">Stock Order Point</field> |
235 | - <field name="type">ir.actions.act_window</field> |
236 | - <field name="res_model">stock.minimum.calculator</field> |
237 | - <field name="view_type">form</field> |
238 | - <field name="view_mode">tree,form</field> |
239 | - <field name="view_id" ref="view_stock_minimum_calculator_form"/> |
240 | - <field name="target">new</field> |
241 | - </record> |
242 | - |
243 | - <menuitem action="action_stock_minimum_calculator" |
244 | - id="menu_action_stock_minimum_calculator" |
245 | - parent="product.menu_config_product" /> |
246 | + |
247 | + <record id="stock_holding_rate_tree_view" model="ir.ui.view"> |
248 | + <field name="name">stock.holding.rate.tree</field> |
249 | + <field name="model">stock.holding.rate</field> |
250 | + <field name="type">tree</field> |
251 | + <field name="arch" type="xml"> |
252 | + <tree string="Stock Holding Rate"> |
253 | + <field name="name"/> |
254 | + <field name="rate_id"/> |
255 | + <field name="stock_hold_rate"/> |
256 | + <field name="date_start"/> |
257 | + <field name="date_stop"/> |
258 | + <field name="stock_hold_rate"/> |
259 | + </tree> |
260 | + </field> |
261 | + </record> |
262 | + |
263 | + <record id="stock_holding_rate_form_view" model="ir.ui.view"> |
264 | + <field name="name">stock.holding.rate.form</field> |
265 | + <field name="model">stock.holding.rate</field> |
266 | + <field name="type">form</field> |
267 | + <field name="arch" type="xml"> |
268 | + <form string="Stock Holding Rate"> |
269 | + <group colspan="6" col="6"> |
270 | + <field name="name"/> |
271 | + <field name="rate_id"/> |
272 | + <field name="active"/> |
273 | + <field name="date_start"/> |
274 | + <field name="date_stop"/> |
275 | + <field name="stock_hold_rate"/> |
276 | + </group> |
277 | + <field name="holding_ids" nolabel="1" colspan="4" widget="one2many_list"> |
278 | + <tree editable="bottom" string="Supplier"> |
279 | + <field name="partner_id"/> |
280 | + <field name="supp_stock"/> |
281 | + </tree> |
282 | + <form> |
283 | + <field name="partner_id"/> |
284 | + <field name="supp_stock"/> |
285 | + </form> |
286 | + </field> |
287 | + </form> |
288 | + </field> |
289 | + </record> |
290 | + <record id="stock_holding_rate_tree_view_normal_action" model="ir.actions.act_window"> |
291 | + <field name="name">Stock Holding Rate</field> |
292 | + <field name="type">ir.actions.act_window</field> |
293 | + <field name="res_model">stock.holding.rate</field> |
294 | + <field name="view_type">form</field> |
295 | + <field name="view_id" ref="stock_holding_rate_tree_view"/> |
296 | + </record> |
297 | + <menuitem action="stock_holding_rate_tree_view_normal_action" id="menu_stock_holding_rate" parent="stock.menu_stock_configuration"/> |
298 | + |
299 | + <record id="supplier_cost_opti_lead_time_tree_view" model="ir.ui.view"> |
300 | + <field name="name">supplier.cost.opti.lead.time.tree</field> |
301 | + <field name="model">supplier.cost.opti.lead.time</field> |
302 | + <field name="type">tree</field> |
303 | + <field name="arch" type="xml"> |
304 | + <tree string="Supplier Cost Optimated Lead Times"> |
305 | + <field name="supp_cost_id"/> |
306 | + <field name="name"/> |
307 | + <field name="partner_id"/> |
308 | + <field name="date_start"/> |
309 | + <field name="yrl_purchase_rev"/> |
310 | + <field name="economic_no_order"/> |
311 | + <field name="cost_per_del"/> |
312 | + <field name="economic_lead_time"/> |
313 | + <field name="stock_holding_rate_id"/> |
314 | + <field name="staus"/> |
315 | + </tree> |
316 | + </field> |
317 | + </record> |
318 | + |
319 | + <record id="supplier_cost_opti_lead_time_form_view" model="ir.ui.view"> |
320 | + <field name="name">supplier.cost.opti.lead.time.form</field> |
321 | + <field name="model">supplier.cost.opti.lead.time</field> |
322 | + <field name="type">form</field> |
323 | + <field name="arch" type="xml"> |
324 | + <form string="Supplier Cost Optimated Lead Times"> |
325 | + <group colspan="6" col="6"> |
326 | + <field name="name"/> |
327 | + <field name="supp_cost_id"/> |
328 | + <field name="active"/> |
329 | + <field name="partner_id"/> |
330 | + <field name="date_start"/> |
331 | + </group> |
332 | + <group colspan="2" col="2"> |
333 | + <separator colspan="4" string="Automatic Declaration"/> |
334 | + <field name="yrl_purchase_rev"/> |
335 | + <field name="cost_per_del"/> |
336 | + <field name="stock_holding_rate_id"/> |
337 | + </group> |
338 | + <group colspan="2" col="2"> |
339 | + <separator colspan="4" string="Economic Number of orders"/> |
340 | + <field name="economic_no_order"/> |
341 | + <field name="economic_lead_time"/> |
342 | + <button name="action_compute" string="Calculate Lead Time" type="object"/> |
343 | + </group> |
344 | + <field name="staus"/> |
345 | + <button name="action_cancel" string="Cancel" type="object"/> |
346 | + <button name="action_validate" string="Valid" type="object"/> |
347 | + </form> |
348 | + </field> |
349 | + </record> |
350 | + <record id="supplier_cost_opti_lead_time_normal_action" model="ir.actions.act_window"> |
351 | + <field name="name">Supplier Cost Optimated Lead Times</field> |
352 | + <field name="type">ir.actions.act_window</field> |
353 | + <field name="res_model">supplier.cost.opti.lead.time</field> |
354 | + <field name="view_type">form</field> |
355 | + <field name="view_id" ref="supplier_cost_opti_lead_time_tree_view"/> |
356 | + </record> |
357 | + <menuitem action="supplier_cost_opti_lead_time_normal_action" id="menu_supplier_cost_opti_lead_time" parent="stock.menu_stock_configuration"/> |
358 | + |
359 | + |
360 | + |
361 | + <record id="product_seasonal_tree_view" model="ir.ui.view"> |
362 | + <field name="name">product.seasonal.tree</field> |
363 | + <field name="model">product.seasonal</field> |
364 | + <field name="type">tree</field> |
365 | + <field name="arch" type="xml"> |
366 | + <tree string="Product Seasonal"> |
367 | + <field name="name"/> |
368 | + <field name="code"/> |
369 | + <field name="seasonal_factor"/> |
370 | + </tree> |
371 | + </field> |
372 | + </record> |
373 | + |
374 | + <record id="product_seasonal_form_view" model="ir.ui.view"> |
375 | + <field name="name">product.seasonal.form</field> |
376 | + <field name="model">product.seasonal</field> |
377 | + <field name="type">form</field> |
378 | + <field name="arch" type="xml"> |
379 | + <form string="Product Seasonal"> |
380 | + <field name="name"/> |
381 | + <field name="code"/> |
382 | + <field name="seasonal_factor"/> |
383 | + </form> |
384 | + </field> |
385 | + </record> |
386 | + <record id="product_seasonal_normal_action" model="ir.actions.act_window"> |
387 | + <field name="name">Product Seasonal</field> |
388 | + <field name="type">ir.actions.act_window</field> |
389 | + <field name="res_model">product.seasonal</field> |
390 | + <field name="view_type">form</field> |
391 | + <field name="view_id" ref="product_seasonal_tree_view"/> |
392 | + </record> |
393 | + <menuitem action="product_seasonal_normal_action" id="menu_product_seasonal" parent="stock.menu_stock_configuration"/> |
394 | + |
395 | + <record model="ir.ui.view" id="view_supplier_holding_rate_form1"> |
396 | + <field name="name">res.partner.form</field> |
397 | + <field name="model">res.partner</field> |
398 | + <field name="inherit_id" ref="stock.view_partner_property_form"/> |
399 | + <field name="type">form</field> |
400 | + <field name="arch" type="xml"> |
401 | + <field name="property_stock_supplier" position="after"> |
402 | + <field name="stock_holding_rate_id" /> |
403 | + </field> |
404 | + </field> |
405 | + </record> |
406 | + <record model="ir.ui.view" id="view_supplier_holding_rate_form"> |
407 | + <field name="name">product.product.form</field> |
408 | + <field name="model">product.product</field> |
409 | + <field name="inherit_id" ref="product.product_normal_form_view"/> |
410 | + <field name="type">form</field> |
411 | + <field name="arch" type="xml"> |
412 | + <field name="company_id" position="after"> |
413 | + <field name="seasonal_id" /> |
414 | + <field name="plan_avg_consume" /> |
415 | + </field> |
416 | + </field> |
417 | + </record> |
418 | + |
419 | +<!-- Add for percenatage of the period --> |
420 | + <record id="stock_warehosue_orderpoint_period_tree_view" model="ir.ui.view"> |
421 | + <field name="name">stock.warehosue.orderpoint.period.tree</field> |
422 | + <field name="model">stock.warehosue.orderpoint.period</field> |
423 | + <field name="type">tree</field> |
424 | + <field name="arch" type="xml"> |
425 | + <tree string="Period Percenatage"> |
426 | + <field name="name"/> |
427 | + <field name="product_id"/> |
428 | + <field name="partner_id"/> |
429 | + <field name="period_id"/> |
430 | + <field name="percentage"/> |
431 | + </tree> |
432 | + </field> |
433 | + </record> |
434 | + |
435 | + <record id="stock_warehosue_orderpoint_period_form_view" model="ir.ui.view"> |
436 | + <field name="name">stock.warehosue.orderpoint.period.form</field> |
437 | + <field name="model">stock.warehosue.orderpoint.period</field> |
438 | + <field name="type">form</field> |
439 | + <field name="arch" type="xml"> |
440 | + <form string="Period Percenatage"> |
441 | + <field name="name"/> |
442 | + <field name="product_id"/> |
443 | + <field name="partner_id"/> |
444 | + <field name="period_id"/> |
445 | + <field name="percentage"/> |
446 | + </form> |
447 | + </field> |
448 | + </record> |
449 | + <record id="stock_warehosue_orderpoint_period_normal_action" model="ir.actions.act_window"> |
450 | + <field name="name">Period Percenatage</field> |
451 | + <field name="type">ir.actions.act_window</field> |
452 | + <field name="res_model">stock.warehosue.orderpoint.period</field> |
453 | + <field name="view_type">form</field> |
454 | + <field name="view_id" ref="stock_warehosue_orderpoint_period_tree_view"/> |
455 | + </record> |
456 | + |
457 | + <menuitem action="stock_warehosue_orderpoint_period_normal_action" id="menu_period_supplier" parent="stock.menu_stock_configuration"/> |
458 | + |
459 | |
460 | </data> |
461 | </openerp> |
462 | \ No newline at end of file |
463 | |
464 | === added file 'stock_minimum_calculator/stock_order_point_calculator.py' |
465 | --- stock_minimum_calculator/stock_order_point_calculator.py 1970-01-01 00:00:00 +0000 |
466 | +++ stock_minimum_calculator/stock_order_point_calculator.py 2010-06-11 07:44:24 +0000 |
467 | @@ -0,0 +1,217 @@ |
468 | +# -*- coding: utf-8 -*- |
469 | +############################################################################## |
470 | +# |
471 | +# OpenERP, Open Source Management Solution |
472 | +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). |
473 | +# |
474 | +# This program is free software: you can redistribute it and/or modify |
475 | +# it under the terms of the GNU Affero General Public License as |
476 | +# published by the Free Software Foundation, either version 3 of the |
477 | +# License, or (at your option) any later version. |
478 | +# |
479 | +# This program is distributed in the hope that it will be useful, |
480 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
481 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
482 | +# GNU Affero General Public License for more details. |
483 | +# |
484 | +# You should have received a copy of the GNU Affero General Public License |
485 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
486 | +# |
487 | +############################################################################## |
488 | +from osv import fields, osv |
489 | +import time |
490 | +from tools.translate import _ |
491 | + |
492 | +class stock_orderpoint_step1(osv.osv_memory): |
493 | + |
494 | + _name="stock.orderpoint.step1" |
495 | + _columns = { |
496 | + 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse',required=True), |
497 | + 'deactive': fields.boolean('Deactive Existing Rules'), |
498 | + 'delactive': fields.boolean('Delete Exiting Rules(for this warehosue)'), |
499 | + } |
500 | + |
501 | + def _de_next(self, cr, uid, ids, context=None): |
502 | + |
503 | + mod_obj = self.pool.get('ir.model.data') |
504 | + product_obj = self.pool.get('product.product') |
505 | + min_rule_obj = self.pool.get('stock.warehouse.orderpoint') |
506 | + form = self.read(cr, uid, ids, [])[0] |
507 | + |
508 | + stock_rule_ids = min_rule_obj.search(cr,uid,[('warehouse_id','=',form['warehouse_id'])]) |
509 | + |
510 | + if form['deactive']: |
511 | + for stock_rule_id in min_rule_obj.browse(cr, uid, stock_rule_ids, context=context): |
512 | + min_rule_obj.write(cr, uid, [stock_rule_id.id], {'active':False}, context=context) |
513 | + |
514 | + elif form['delactive']: |
515 | + for stock_rule_id in min_rule_obj.browse(cr, uid, stock_rule_ids, context=context): |
516 | + min_rule_obj.unlink(cr, uid, [stock_rule_id.id],context=context) |
517 | + |
518 | + |
519 | + model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_stock_orderpoint_step2')], context=context) |
520 | + resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] |
521 | + return { |
522 | + 'name': _('Stock Orderpoint Step2'), |
523 | + 'context': context, |
524 | + 'view_type': 'form', |
525 | + 'view_mode': 'form', |
526 | + 'res_model': 'stock.orderpoint.step2', |
527 | + 'views': [(resource_id,'form')], |
528 | + 'type': 'ir.actions.act_window', |
529 | + 'target': 'new', |
530 | + } |
531 | +stock_orderpoint_step1() |
532 | + |
533 | + |
534 | +class stock_orderpoint_step2(osv.osv_memory): |
535 | + |
536 | + _name="stock.orderpoint.step2" |
537 | + _columns = { |
538 | + 'min_qty_calculation': fields.selection([('optimal_stock_coverage', 'Optimal Stock Coverage'), |
539 | + ('normal_stock_coverage', 'Normal Stock Coverage'), |
540 | + ], 'Method Calculation Minimum Qty',required=True), |
541 | + 'max_qty_calculation': fields.selection([('optimal_stock_coverage', 'Optimal Stock Coverage'), |
542 | + ('normal_stock_coverage', 'Normal Stock Coverage'), |
543 | + ], 'Method Calculation Maximum Qty',required=True), |
544 | + } |
545 | + _defaults = { |
546 | + 'min_qty_calculation': lambda *a: 'optimal_stock_coverage', |
547 | + 'max_qty_calculation': lambda *a: 'optimal_stock_coverage', |
548 | + } |
549 | + |
550 | + def _next_calculate(self, cr, uid, ids, context=None): |
551 | + |
552 | + purchase_obj = self.pool.get('purchase.order') |
553 | + sale_obj = self.pool.get('sale.order') |
554 | + product_obj = self.pool.get('product.product') |
555 | + supp_obj = self.pool.get("product.supplierinfo") |
556 | + supp_cost_opt_obj = self.pool.get("supplier.cost.opti.lead.time") |
557 | + wizard_obj = self.pool.get("stock.orderpoint.step1") |
558 | + min_rule_obj = self.pool.get('stock.warehouse.orderpoint') |
559 | + order_period_obj = self.pool.get("stock.warehosue.orderpoint.period") |
560 | + |
561 | + form = self.read(cr, uid, ids, [])[0] |
562 | + |
563 | + purchase_ids = purchase_obj.search(cr,uid,[]) |
564 | + start_pur_id = min(purchase_ids) |
565 | + last_pur_id = max(purchase_ids) |
566 | + |
567 | + ############# Calculation of purchase Quantity upto today |
568 | + purchase_qty = 0.0 |
569 | + if purchase_ids: |
570 | + for pur_id in purchase_ids: |
571 | + purchase_data = purchase_obj.browse(cr,uid,pur_id) |
572 | + for line in purchase_data.order_line: |
573 | + purchase_qty += line.product_qty |
574 | + |
575 | + |
576 | + ##### Calculation of sale order Quantity of open orders |
577 | + sale_qty = 0.0 |
578 | + sale_ids = self.pool.get('sale.order').search(cr, uid, [('state','in',['manual','progress'])]) |
579 | + if sale_ids: |
580 | + for sale_id in sale_ids: |
581 | + sale_data = self.pool.get('sale.order').browse(cr,uid,sale_id) |
582 | + for line in sale_data.order_line: |
583 | + sale_qty += line.product_uom_qty |
584 | + |
585 | + |
586 | + ##################calculation of date difference between first and last purchase order |
587 | + first_purchase_date = purchase_obj.browse(cr,uid,start_pur_id).date_order |
588 | + last_purchase_date = purchase_obj.browse(cr,uid,last_pur_id).date_order |
589 | + first_date = time.mktime(time.strptime(first_purchase_date,'%Y-%m-%d')) |
590 | + last_date = time.mktime(time.strptime(last_purchase_date,'%Y-%m-%d')) |
591 | + diff_day = (last_date-first_date)/(3600*24) |
592 | + |
593 | + ##### Calculation of purchase lead time |
594 | + purchase_lead_time = 0.0 |
595 | + company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id |
596 | + purchase_lead_time = company.po_lead |
597 | + |
598 | + ##### Calculation of supplier lead time |
599 | + product_id = product_obj.browse(cr, uid, context['id'], context) |
600 | + supplier_lead_time = 0.0 |
601 | + if product_id: |
602 | + for supp in product_id.seller_ids: |
603 | + sup = supp_obj.browse(cr, uid, supp.id, context) |
604 | + supplier_lead_time = sup.delay |
605 | + |
606 | + |
607 | + ##### Calculation of average_daily_consumption |
608 | + average_daily_consumption = 0.0 |
609 | + if purchase_ids and diff_day > 0.0: |
610 | + average_daily_consumption = (sale_qty + purchase_qty )/diff_day |
611 | + else: |
612 | + plan_consume = product_id.plan_avg_consume |
613 | + average_daily_consumption = plan_consume |
614 | + ######### calculation of safety stock |
615 | + safety_stock = purchase_qty / len(purchase_ids) |
616 | + |
617 | + ### calculation of Economic lead time (days) |
618 | + cost_op_id = supp_cost_opt_obj.search(cr, uid, [('partner_id','=',sup.name.id)]) |
619 | + economic_lead_days = 0.0 |
620 | + economic_numer_orders = 0.0 |
621 | + economic_lead_time = 0.0 |
622 | + if cost_op_id: |
623 | + cost_op = supp_cost_opt_obj.browse(cr, uid,cost_op_id[0]) |
624 | + economic_numer_orders = cost_op.economic_no_order |
625 | + economic_lead_time = cost_op.economic_lead_time |
626 | + economic_lead_days = economic_lead_time * 30 #Economic leaddays: field economic leadtime from supplier.leadtimes * 30 |
627 | + |
628 | + ### Calculation of the percentage of this days period |
629 | + future_seasonal_fac = 0.0 |
630 | + periods = self.pool.get('account.period').find(cr, uid) |
631 | + for period in periods: |
632 | + trend_id = order_period_obj.search(cr, uid, [('period_id','=',period)]) |
633 | + if trend_id: |
634 | + per = order_period_obj.browse(cr, uid,trend_id[0]).percentage |
635 | + future_seasonal_fac = economic_lead_days + purchase_lead_time / per |
636 | + |
637 | + #### Calculation of seasonal Factor |
638 | + |
639 | + #??????seasonal factor = percentage of product.seasonaltrend for future period of follwing date: |
640 | + #today + economic lead days + purchase lead time / "percentage of this days period" |
641 | + seasonal_fac = 0.0 |
642 | + seasonal_fac = product_id.seasonal_id.seasonal_factor |
643 | + |
644 | + |
645 | + ### Calculation for minimum quantity |
646 | + optimal_stock_coverage = 0.0 |
647 | + normal_stock_coverage = 0.0 |
648 | + if form['min_qty_calculation'] == 'optimal_stock_coverage': |
649 | + optimal_stock_coverage = average_daily_consumption * seasonal_fac * (economic_lead_days + purchase_lead_time) / safety_stock |
650 | + else: |
651 | + normal_stock_coverage = average_daily_consumption * (supplier_lead_time + purchase_lead_time)/safety_stock |
652 | + |
653 | + |
654 | + ### Calculation for maximum quantity |
655 | + optimal_stock_coverage_max = 0.0 |
656 | + normal_stock_coverage_max = 0.0 |
657 | + if form['max_qty_calculation'] == 'optimal_stock_coverage': |
658 | + optimal_stock_coverage_max = (average_daily_consumption * seasonal_fac * (economic_lead_days + purchase_lead_time)) |
659 | + else: |
660 | + normal_stock_coverage_max = average_daily_consumption * (supplier_lead_time + purchase_lead_time) |
661 | + |
662 | + ids = wizard_obj.search(cr, uid, []) |
663 | + |
664 | + wizz_id = wizard_obj.browse(cr, uid, ids[0]) |
665 | + max1 = 'max' |
666 | + name = self.pool.get('ir.sequence').get(cr, uid, 'stock.orderpoint.step2') |
667 | + |
668 | + self.pool.get('stock.warehouse.orderpoint').create(cr, uid, { |
669 | + 'name': name, |
670 | + 'active': True, |
671 | + 'warehouse_id': wizz_id.warehouse_id.id, |
672 | + 'location_id': product_id.property_stock_inventory.id, |
673 | + 'product_id': context['id'], |
674 | + 'product_min_qty': optimal_stock_coverage or normal_stock_coverage, |
675 | + 'product_max_qty': optimal_stock_coverage_max or normal_stock_coverage_max, |
676 | + 'qty_multiple':1, |
677 | + 'product_uom':product_id.uom_id.id, |
678 | + 'logic':'max' |
679 | + } ) |
680 | + return {} |
681 | + |
682 | +stock_orderpoint_step2() |
683 | + |
684 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
685 | \ No newline at end of file |
686 | |
687 | === added file 'stock_minimum_calculator/stock_order_point_calculator_view.xml' |
688 | --- stock_minimum_calculator/stock_order_point_calculator_view.xml 1970-01-01 00:00:00 +0000 |
689 | +++ stock_minimum_calculator/stock_order_point_calculator_view.xml 2010-06-11 07:44:24 +0000 |
690 | @@ -0,0 +1,50 @@ |
691 | +<?xml version="1.0" encoding="utf-8"?> |
692 | +<openerp> |
693 | + <data> |
694 | + <record id="view_account_invoice_pay" model="ir.ui.view"> |
695 | + <field name="name">stock.orderpoint.step1.form</field> |
696 | + <field name="model">stock.orderpoint.step1</field> |
697 | + <field name="type">form</field> |
698 | + <field name="arch" type="xml"> |
699 | + <form string="Wizard Order Point Calculator Step1 - Choose Warehouse and Updating Settings"> |
700 | + <group colspan="4" > |
701 | + <field name="warehouse_id"/> |
702 | + <field name="deactive"/> |
703 | + <field name="delactive"/> |
704 | + </group> |
705 | + <group colspan="4" col="6"> |
706 | + <label string ="" colspan="2"/> |
707 | + <button icon="gtk-cancel" special="cancel" string="Cancel"/> |
708 | + <button icon="gtk-execute" string="Next Step" name="_de_next" type="object"/> |
709 | + </group> |
710 | + </form> |
711 | + </field> |
712 | + </record> |
713 | + |
714 | + <act_window name="Orderpoint Calculator" |
715 | + res_model="stock.orderpoint.step1" |
716 | + src_model="product.product" |
717 | + view_mode="form" |
718 | + target="new" |
719 | + context="{'id': active_id}" |
720 | + id="action_view_stock_orderpoint_step1"/> |
721 | + |
722 | + <record id="view_stock_orderpoint_step2" model="ir.ui.view"> |
723 | + <field name="name">stock.orderpoint.step2.form</field> |
724 | + <field name="model">stock.orderpoint.step2</field> |
725 | + <field name="type">form</field> |
726 | + <field name="arch" type="xml"> |
727 | + <form string="Wizard Order Point Calculator Step2 - Choose Method"> |
728 | + <field name="min_qty_calculation"/> |
729 | + <field name="max_qty_calculation" /> |
730 | + <group colspan="4" col="6"> |
731 | + <button icon="gtk-cancel" special="cancel" string="Cancel"/> |
732 | + <button icon="gtk-execute" string="Next Step" name="_next_calculate" type="object"/> |
733 | + </group> |
734 | + </form> |
735 | + </field> |
736 | + </record> |
737 | + |
738 | + |
739 | + </data> |
740 | +</openerp> |
741 | \ No newline at end of file |
742 | |
743 | === added directory 'stock_minimum_calculator/wizard' |
744 | === added file 'stock_minimum_calculator/wizard/__init__.py' |
745 | --- stock_minimum_calculator/wizard/__init__.py 1970-01-01 00:00:00 +0000 |
746 | +++ stock_minimum_calculator/wizard/__init__.py 2010-06-11 07:44:24 +0000 |
747 | @@ -0,0 +1,26 @@ |
748 | +# -*- encoding: utf-8 -*- |
749 | +############################################################################## |
750 | +# |
751 | +# OpenERP, Open Source Management Solution |
752 | +# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
753 | +# $Id$ |
754 | +# |
755 | +# This program is free software: you can redistribute it and/or modify |
756 | +# it under the terms of the GNU General Public License as published by |
757 | +# the Free Software Foundation, either version 3 of the License, or |
758 | +# (at your option) any later version. |
759 | +# |
760 | +# This program is distributed in the hope that it will be useful, |
761 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
762 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
763 | +# GNU General Public License for more details. |
764 | +# |
765 | +# You should have received a copy of the GNU General Public License |
766 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
767 | +# |
768 | +############################################################################## |
769 | + |
770 | +import seasonal_trend_set |
771 | + |
772 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
773 | + |
774 | |
775 | === added file 'stock_minimum_calculator/wizard/seasonal_trend_set.py' |
776 | --- stock_minimum_calculator/wizard/seasonal_trend_set.py 1970-01-01 00:00:00 +0000 |
777 | +++ stock_minimum_calculator/wizard/seasonal_trend_set.py 2010-06-11 07:44:24 +0000 |
778 | @@ -0,0 +1,71 @@ |
779 | +# -*- coding: utf-8 -*- |
780 | +############################################################################## |
781 | +# |
782 | +# OpenERP, Open Source Management Solution |
783 | +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). |
784 | +# |
785 | +# This program is free software: you can redistribute it and/or modify |
786 | +# it under the terms of the GNU Affero General Public License as |
787 | +# published by the Free Software Foundation, either version 3 of the |
788 | +# License, or (at your option) any later version. |
789 | +# |
790 | +# This program is distributed in the hope that it will be useful, |
791 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
792 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
793 | +# GNU Affero General Public License for more details. |
794 | +# |
795 | +# You should have received a copy of the GNU Affero General Public License |
796 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
797 | +# |
798 | +############################################################################## |
799 | + |
800 | +import wizard |
801 | +import pooler |
802 | +import time |
803 | +from tools.translate import _ |
804 | + |
805 | +seasonal_trend_form = """<?xml version="1.0"?> |
806 | +<form string="Seasonal Product Trend "> |
807 | + <field name="trend_seasonal_id"/> |
808 | + <field name="active"/> |
809 | +</form>""" |
810 | + |
811 | +seasonal_trend_fields = { |
812 | + 'trend_seasonal_id': {'string': 'Seasonal Model', 'type': 'many2one', 'relation': 'product.seasonal', 'required': True}, |
813 | + 'active': {'string':'Replace Models', 'type':'boolean'}, |
814 | + } |
815 | + |
816 | +def _set_seasonal(self, cr, uid, data, context): |
817 | + |
818 | + product_obj = pooler.get_pool(cr.dbname).get('product.product') |
819 | + form = data['form'] |
820 | + |
821 | + if form['active']: |
822 | + for id in data['ids']: |
823 | + product_obj.write(cr, uid, id, {'seasonal_id':form['trend_seasonal_id']}, context=context) |
824 | + else: |
825 | + product_obj.write(cr, uid, data['id'], {'seasonal_id':form['trend_seasonal_id']}, context=context) |
826 | + |
827 | + return {} |
828 | + |
829 | + |
830 | +class product_seasonal_trend(wizard.interface): |
831 | + states = { |
832 | + 'init' : { |
833 | + 'actions' : [], |
834 | + 'result' : {'type' : 'form', |
835 | + 'arch' : seasonal_trend_form, |
836 | + 'fields' : seasonal_trend_fields, |
837 | + 'state' : [('end', 'Cancel'),('set_seasonal', 'Ok') ]} |
838 | + }, |
839 | + 'set_seasonal' : { |
840 | + 'actions' : [], |
841 | + 'result' : {'type' : 'action', |
842 | + 'action' : _set_seasonal, |
843 | + 'state' : 'end'} |
844 | + } |
845 | + } |
846 | +product_seasonal_trend("set_seasonal.trend") |
847 | + |
848 | + |
849 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
850 | \ No newline at end of file |
851 | |
852 | === added file 'stock_minimum_calculator/wizard/seasonal_trend_set_view.xml' |
853 | --- stock_minimum_calculator/wizard/seasonal_trend_set_view.xml 1970-01-01 00:00:00 +0000 |
854 | +++ stock_minimum_calculator/wizard/seasonal_trend_set_view.xml 2010-06-11 07:44:24 +0000 |
855 | @@ -0,0 +1,32 @@ |
856 | +<?xml version="1.0" encoding="utf-8"?> |
857 | +<openerp> |
858 | + <data> |
859 | + |
860 | + <record id="view_stock_order_rule" model="ir.ui.view"> |
861 | + <field name="name">product.seasonal.trend.form</field> |
862 | + <field name="model">product.seasonal.trend</field> |
863 | + <field name="type">form</field> |
864 | + <field name="arch" type="xml"> |
865 | + <form string="Set Seasonal Trend"> |
866 | + <field name="trend_seasonal_id" /> |
867 | + <field name="active" /> |
868 | + <group colspan="4" col="6"> |
869 | + <button icon="gtk-cancel" special="cancel" string="Cancel"/> |
870 | + <button icon="gtk-execute" string="OK" name="_set_seasonal" type="object"/> |
871 | + </group> |
872 | + </form> |
873 | + </field> |
874 | + </record> |
875 | + |
876 | + <act_window |
877 | + res_model = "product.seasonal.trend" |
878 | + src_model = "product.product" |
879 | + view_type = "form" |
880 | + view_mode = "form" |
881 | + name= "Set Seasonal Trend" |
882 | + target="new" |
883 | + context="{'id': active_id}" |
884 | + id="action_product_seasonal_trend"/> |
885 | + |
886 | + </data> |
887 | +</openerp> |
888 | \ No newline at end of file |