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