Merge lp:~openbig/bigconsulting/order_point_calculator into lp:bigconsulting

Proposed by gpa(OpenERP)
Status: Merged
Merged at revision: 78
Proposed branch: lp:~openbig/bigconsulting/order_point_calculator
Merge into: lp:bigconsulting
Diff against target: 278 lines (+87/-31)
7 files modified
packing_barcode_check/__terp__.py (+3/-1)
packing_barcode_check/packing_barcode_check.py (+21/-2)
packing_barcode_check/packing_barcode_check_view.xml (+4/-2)
packing_barcode_check/packing_barcode_check_wizard.xml (+1/-8)
packing_barcode_check/packing_barcode_check_workflow.xml (+26/-0)
packing_barcode_check/wizard/scan_product.py (+8/-0)
stock_minimum_calculator/wizard/stock_order_point_calculator.py (+24/-18)
To merge this branch: bzr merge lp:~openbig/bigconsulting/order_point_calculator
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+32980@code.launchpad.net

This proposal supersedes a proposal from 2010-08-18.

Description of the change

changes in the stock order point wizard

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'packing_barcode_check/__terp__.py'
--- packing_barcode_check/__terp__.py 2010-07-26 15:12:49 +0000
+++ packing_barcode_check/__terp__.py 2010-08-18 11:09:43 +0000
@@ -31,9 +31,11 @@
31 "license" : "GPL-3",31 "license" : "GPL-3",
32 "depends" : ["base","product","stock"],32 "depends" : ["base","product","stock"],
33 "init_xml" : [],33 "init_xml" : [],
34 "update_xml" : ["packing_barcode_check_view.xml",34 "update_xml" : [
35 "packing_barcode_check_wizard.xml",35 "packing_barcode_check_wizard.xml",
36 "packing_barcode_check_report.xml",36 "packing_barcode_check_report.xml",
37 "packing_barcode_check_view.xml",
38 "packing_barcode_check_workflow.xml",
37 ],39 ],
38 "active": False,40 "active": False,
39 "installable": True41 "installable": True
4042
=== modified file 'packing_barcode_check/packing_barcode_check.py'
--- packing_barcode_check/packing_barcode_check.py 2010-08-17 07:47:09 +0000
+++ packing_barcode_check/packing_barcode_check.py 2010-08-18 11:09:43 +0000
@@ -38,16 +38,23 @@
38 'scanned_quantity' : scanned_quantity,38 'scanned_quantity' : scanned_quantity,
39 'to_be_scanned_quantity' : total_quantity - scanned_quantity,39 'to_be_scanned_quantity' : total_quantity - scanned_quantity,
40 }40 }
41
42 return res41 return res
4342
44
45 _columns = {43 _columns = {
46 'total_quantity':fields.function(_compute_quantity, method=True, string='Total Quantity', multi='quantity'),44 'total_quantity':fields.function(_compute_quantity, method=True, string='Total Quantity', multi='quantity'),
47 'scanned_quantity': fields.function(_compute_quantity, method=True, string='Scanned Quantity', multi='quantity'),45 'scanned_quantity': fields.function(_compute_quantity, method=True, string='Scanned Quantity', multi='quantity'),
48 'to_be_scanned_quantity':fields.function(_compute_quantity, method=True, string='Unscanned Quantity', multi='quantity'),46 'to_be_scanned_quantity':fields.function(_compute_quantity, method=True, string='Unscanned Quantity', multi='quantity'),
49 'tobe_scan_ids':fields.one2many('tobe.scanned.stock', 'tobe_picking_id', 'To Be'),47 'tobe_scan_ids':fields.one2many('tobe.scanned.stock', 'tobe_picking_id', 'To Be'),
50 'scaned_ids':fields.one2many('scanned.stock', 'scanned_picking_id', 'Scanned Picking',),48 'scaned_ids':fields.one2many('scanned.stock', 'scanned_picking_id', 'Scanned Picking',),
49 'state': fields.selection([
50 ('draft', 'Draft'),
51 ('auto', 'Waiting'),
52 ('confirmed', 'Confirmed'),
53 ('assigned', 'Available'),
54 ('scanned', 'Scanned'),
55 ('done', 'Done'),
56 ('cancel', 'Cancelled'),
57 ], 'Status', readonly=True, select=True),
51 }58 }
52 _defaults = {59 _defaults = {
53 'scanned_quantity' : lambda *a:0.0,60 'scanned_quantity' : lambda *a:0.0,
@@ -58,6 +65,18 @@
58 move_ids = move_obj.search(cr, uid, [('picking_id','=',ids[0])])65 move_ids = move_obj.search(cr, uid, [('picking_id','=',ids[0])])
59 move_obj.write(cr, uid, move_ids, {'scaned_qty':0.0}, context)66 move_obj.write(cr, uid, move_ids, {'scaned_qty':0.0}, context)
60 return True67 return True
68
69 def test_scanned(self, cr, uid, ids, context={}):
70 for pick in self.browse(cr, uid, ids, context=context):
71 if pick.tobe_scan_ids:
72 return False
73 return True
74
75 def action_scanned_wkf(self, cr, uid, ids, context={}):
76 for pick in self.browse(cr, uid, ids, context=context):
77 if not pick.tobe_scan_ids:
78 self.write(cr, uid, ids, {'state': 'scanned'})
79 return True
6180
62stock_picking()81stock_picking()
6382
6483
=== modified file 'packing_barcode_check/packing_barcode_check_view.xml'
--- packing_barcode_check/packing_barcode_check_view.xml 2010-08-17 07:26:17 +0000
+++ packing_barcode_check/packing_barcode_check_view.xml 2010-08-18 11:09:43 +0000
@@ -38,7 +38,7 @@
38 <field name="backorder_id" select="2" readonly="1"/>38 <field name="backorder_id" select="2" readonly="1"/>
39 <field name="origin" select="2" readonly="1"/>39 <field name="origin" select="2" readonly="1"/>
40 <label string=""/>40 <label string=""/>
41 <button name="button_reset" string="Reset" type="object"/>41 <button name="button_reset" states="assigned" string="Reset" type="object"/>
42 </group>42 </group>
43 <notebook colspan="4">43 <notebook colspan="4">
44 <page string="Scanning Info">44 <page string="Scanning Info">
@@ -66,6 +66,8 @@
66 <button name="draft_validate" states="draft" string="Process Now" type="object"/>66 <button name="draft_validate" states="draft" string="Process Now" type="object"/>
67 <button name="action_assign" states="confirmed" string="Check Availability" type="object"/>67 <button name="action_assign" states="confirmed" string="Check Availability" type="object"/>
68 <button name="force_assign" states="confirmed" string="Force Availability" type="object"/>68 <button name="force_assign" states="confirmed" string="Force Availability" type="object"/>
69 <button name="%(id_scan_product)d" states="assigned" string="Scan Packing" type="action"/>
70 <button name="%(stock.partial_picking)d" states="scanned" string="Packing Done" type="action"/>
69 <button name="button_cancel" states="assigned,confirmed,draft" string="Cancel"/>71 <button name="button_cancel" states="assigned,confirmed,draft" string="Cancel"/>
70 </group>72 </group>
71 </page> 73 </page>
@@ -108,7 +110,7 @@
108 </field>110 </field>
109 </record>111 </record>
110112
111 <wizard id="act_selct_picking_open_form" model="stock.picking" name="select.picking" string="Select picking"/>113 <wizard id="act_selct_picking_open_form" model="stock.picking" name="select.picking" menu="False" string="Select picking"/>
112 <menuitem action="act_selct_picking_open_form" id="menu_act_selct_picking_open_form" parent="stock.menu_stock_root" type="wizard"/>114 <menuitem action="act_selct_picking_open_form" id="menu_act_selct_picking_open_form" parent="stock.menu_stock_root" type="wizard"/>
113115
114 </data>116 </data>
115117
=== modified file 'packing_barcode_check/packing_barcode_check_wizard.xml'
--- packing_barcode_check/packing_barcode_check_wizard.xml 2010-07-26 15:12:49 +0000
+++ packing_barcode_check/packing_barcode_check_wizard.xml 2010-08-18 11:09:43 +0000
@@ -1,18 +1,11 @@
1<?xml version="1.0" encoding="utf-8"?>1<?xml version="1.0" encoding="utf-8"?>
2<openerp>2<openerp>
3 <data>3 <data>
4 <wizard
5 string="Select Picking Wizard"
6 model="stock.picking"
7 name="select.picking"
8 menu="False"
9 id="id_select_picking"/>
10
11 <wizard4 <wizard
12 string="Scan Product"5 string="Scan Product"
13 model="stock.picking"6 model="stock.picking"
14 name="scan.product"7 name="scan.product"
15 menu="True"8 menu="False"
16 id="id_scan_product"/>9 id="id_scan_product"/>
1710
18 </data>11 </data>
1912
=== added file 'packing_barcode_check/packing_barcode_check_workflow.xml'
--- packing_barcode_check/packing_barcode_check_workflow.xml 1970-01-01 00:00:00 +0000
+++ packing_barcode_check/packing_barcode_check_workflow.xml 2010-08-18 11:09:43 +0000
@@ -0,0 +1,26 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="act_scanned" model="workflow.activity">
6 <field name="wkf_id" ref="stock.wkf_picking"/>
7 <field name="name">scanned</field>
8 <field name="kind">function</field>
9 <field name="action">action_scanned_wkf()</field>
10 </record>
11
12 <record id="trans_scanned_move" model="workflow.transition">
13 <field name="act_from" ref="stock.act_assigned"/>
14 <field name="act_to" ref="act_scanned"/>
15 <field name="condition">test_scanned()</field>
16 <field name="signal">button_scanned</field>
17 </record>
18
19 <record id="stock.trans_scanned_assigned_move" model="workflow.transition">
20 <field name="act_from" ref="act_scanned"/>
21 <field name="act_to" ref="stock.act_move"/>
22 <field name="signal">button_done</field>
23 </record>
24
25 </data>
26</openerp>
027
=== modified file 'packing_barcode_check/wizard/scan_product.py'
--- packing_barcode_check/wizard/scan_product.py 2010-08-13 14:17:17 +0000
+++ packing_barcode_check/wizard/scan_product.py 2010-08-18 11:09:43 +0000
@@ -22,6 +22,7 @@
22import wizard22import wizard
23import pooler23import pooler
24import time24import time
25import netsvc
25from tools.translate import _26from tools.translate import _
26from osv import osv27from osv import osv
2728
@@ -62,10 +63,14 @@
62 _('Unscanned quantity does not match with the product packaging quantity'))63 _('Unscanned quantity does not match with the product packaging quantity'))
6364
64 stock_move_obj.write(cr, uid, [move_id],{'scaned_qty':move_data.scaned_qty+quantity}, context=context)65 stock_move_obj.write(cr, uid, [move_id],{'scaned_qty':move_data.scaned_qty+quantity}, context=context)
66 wkf_service = netsvc.LocalService("workflow")
67 wkf_service.trg_validate(uid, 'stock.picking', picking_id[0], 'button_scanned', cr)
68
65 return 'init'69 return 'init'
66 else:70 else:
67 raise osv.except_osv(_('Warning!'),71 raise osv.except_osv(_('Warning!'),
68 _('Product does not belongs to this picking or already scanned.'))72 _('Product does not belongs to this picking or already scanned.'))
73
69 return {}74 return {}
7075
71scan_product_lot_form = """<?xml version="1.0"?>76scan_product_lot_form = """<?xml version="1.0"?>
@@ -103,6 +108,9 @@
103 raise osv.except_osv(_('Warning!'),108 raise osv.except_osv(_('Warning!'),
104 _('Unscanned quantity does not match with the product packaging quantity')) 109 _('Unscanned quantity does not match with the product packaging quantity'))
105 move_obj.write(cr, uid, [stock_move_obj.id],{'scaned_qty':stock_move_obj.scaned_qty+quantity}, context=context)110 move_obj.write(cr, uid, [stock_move_obj.id],{'scaned_qty':stock_move_obj.scaned_qty+quantity}, context=context)
111 wkf_service = netsvc.LocalService("workflow")
112 wkf_service.trg_validate(uid, 'stock.picking', picking_ids[0], 'button_scanned', cr)
113
106 call_product_scan = 2114 call_product_scan = 2
107 if stock_move_obj.product_qty >= stock_move_obj.scaned_qty+1:115 if stock_move_obj.product_qty >= stock_move_obj.scaned_qty+1:
108 call_product_scan = 1116 call_product_scan = 1
109117
=== modified file 'stock_minimum_calculator/wizard/stock_order_point_calculator.py'
--- stock_minimum_calculator/wizard/stock_order_point_calculator.py 2010-08-17 04:44:06 +0000
+++ stock_minimum_calculator/wizard/stock_order_point_calculator.py 2010-08-18 11:09:43 +0000
@@ -215,7 +215,7 @@
215 # 1. Calculation of the date date start in one year later than current date215 # 1. Calculation of the date date start in one year later than current date
216 from_date = (datetime.now() - relativedelta(months=12)).strftime('%Y-%m-%d %H:%M:%S')216 from_date = (datetime.now() - relativedelta(months=12)).strftime('%Y-%m-%d %H:%M:%S')
217 to_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')217 to_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
218 218
219 # 2.1 first find the all the product which fullfill the criteria of the 2.1219 # 2.1 first find the all the product which fullfill the criteria of the 2.1
220 product_ids = product_obj.search(cr,uid,[('active','=',True),('type','=','product'),220 product_ids = product_obj.search(cr,uid,[('active','=',True),('type','=','product'),
221 ('procure_method','=','make_to_stock'),221 ('procure_method','=','make_to_stock'),
@@ -246,8 +246,7 @@
246 if seller_id.name.id == partner_id:246 if seller_id.name.id == partner_id:
247 supplier_lead_time = seller_id.delay247 supplier_lead_time = seller_id.delay
248 248
249 stock_move_ids = stock_move_obj.search(cr, uid, [('product_id','=',filter_product_id)])249 stock_move_ids = stock_move_obj.search(cr, uid, [('product_id','=',filter_product_id),('state','=','done')])
250
251 average_daily_consumption = 0.0 250 average_daily_consumption = 0.0
252 first_stock_move_ids = []251 first_stock_move_ids = []
253 # Take the first input date of the stock move where stock move of incoming picking or stock move not have any picking 252 # Take the first input date of the stock move where stock move of incoming picking or stock move not have any picking
@@ -258,16 +257,16 @@
258 first_stock_move_ids.append(first_stock_id)257 first_stock_move_ids.append(first_stock_id)
259 else:258 else:
260 first_stock_move_ids.append(first_stock_id)259 first_stock_move_ids.append(first_stock_id)
261260
262 if first_stock_move_ids:261 if first_stock_move_ids:
263 first_stock_move_id = first_stock_move_ids[0]262 first_stock_move_id = first_stock_move_ids[0]
264 first_input = stock_move_obj.browse(cr, uid, first_stock_move_id, context=context).date_planned263 first_input = stock_move_obj.browse(cr, uid, first_stock_move_id, context=context).date_planned
265264
266 # Case 1 if first input is less than from date265 # Case 1 if first input is less than from date
267 if first_input <= from_date:266 if first_input <= from_date:
268 consum_qty = _sale_consume_qty(self, cr, uid, from_date, to_date, 'done', context)267 consum_qty = _sale_consume_qty(self, cr, uid, filter_product_id, from_date, to_date, 'done', context)
269 refund_qty = _refund_qty(self, cr, uid, filter_product_id, from_date, to_date, ['out_refund','in_refund'], context)268 refund_qty = _refund_qty(self, cr, uid, filter_product_id, from_date, to_date, ['out_refund','in_refund'], context)
270 open_sale_qty = _sale_open_qty(self, cr, uid, filter_product_id, from_date, to_date, ['manual','progress'], context) 269 open_sale_qty = _sale_open_qty(self, cr, uid, filter_product_id, ['manual','progress'], context)
271 open_purchase_qty = _purchase_open_qty(self, cr, uid, filter_product_id, 'approved', context) 270 open_purchase_qty = _purchase_open_qty(self, cr, uid, filter_product_id, 'approved', context)
272 pur_diff_day = _date_diff(self, cr, uid, filter_product_id, from_date, to_date, context) 271 pur_diff_day = _date_diff(self, cr, uid, filter_product_id, from_date, to_date, context)
273 ### calculation of average_daily_consumption272 ### calculation of average_daily_consumption
@@ -287,20 +286,26 @@
287 average_daily_consumption = (consum_qty - refund_qty + open_sale_qty - open_purchase_qty) / pur_diff_day286 average_daily_consumption = (consum_qty - refund_qty + open_sale_qty - open_purchase_qty) / pur_diff_day
288 else:287 else:
289 open_sale_qty = _sale_open_qty(self, cr, uid, filter_product_id, ['manual','progress'], context)288 open_sale_qty = _sale_open_qty(self, cr, uid, filter_product_id, ['manual','progress'], context)
290 open_purchase_qty = _purchase_open_qty(self, cr, uid, filter_product_id, 'approved', context)289 open_purchase_qty = _purchase_open_qty(self, cr, uid, filter_product_id, 'approved', context)
290
291 if open_purchase_qty == 0.0 or open_sale_qty == 0.0:
292 continue
291 293
292 # calculation of first open purchase order date 294 # calculation of first open purchase order date
293 open_purchase_ids = purchase_obj.search(cr,uid,[('state','=','approved')]) 295 open_purchase_ids = purchase_obj.search(cr,uid,[('state','=','approved')])
294 first_open_purchase_order = min(open_purchase_ids)296 if open_purchase_ids:
295 fst_open_pur_date = purchase_obj.browse(cr, uid, first_open_purchase_order, context=context).date_order297 first_open_purchase_order = min(open_purchase_ids)
298 fst_open_pur_date = purchase_obj.browse(cr, uid, first_open_purchase_order, context=context).date_order
296 299
297 # Days difference between to date and first purchase date300 # Days difference between to date and first purchase date
298 pur_to_date = time.mktime(time.strptime(to_date,'%Y-%m-%d %H:%M:%S'))301 pur_diff_day = 0.0
299 pur_open_date = time.mktime(time.strptime(fst_open_pur_date,'%Y-%m-%d'))302 if fst_open_pur_date:
300 pur_diff_day = (pur_to_date-pur_open_date)/(3600*24)303 pur_to_date = time.mktime(time.strptime(to_date,'%Y-%m-%d %H:%M:%S'))
301 304 pur_open_date = time.mktime(time.strptime(fst_open_pur_date,'%Y-%m-%d'))
302 if pur_diff_day>0:305 pur_diff_day = (pur_to_date-pur_open_date)/(3600*24)
303 average_daily_consumption = (open_sale_qty - open_purchase_qty)/pur_diff_day306
307 if pur_diff_day>0:
308 average_daily_consumption = (open_sale_qty - open_purchase_qty)/pur_diff_day
304 309
305 ###### Calculation of plan_average_daily_consumption310 ###### Calculation of plan_average_daily_consumption
306 plan_average_daily_consumption = 0.0311 plan_average_daily_consumption = 0.0
@@ -327,6 +332,7 @@
327 min_rule_obj.unlink(cr, uid, [stock_rule_id],context=context)332 min_rule_obj.unlink(cr, uid, [stock_rule_id],context=context)
328 333
329 mini_stock_rule_id = min_rule_obj.search(cr,uid,[('warehouse_id','=',data['form']['warehouse_id']),('product_id','=',filter_product_id)])334 mini_stock_rule_id = min_rule_obj.search(cr,uid,[('warehouse_id','=',data['form']['warehouse_id']),('product_id','=',filter_product_id)])
335
330 if mini_stock_rule_id:336 if mini_stock_rule_id:
331 for stock_rule_id in mini_stock_rule_id:337 for stock_rule_id in mini_stock_rule_id:
332 min_rule_obj.write(cr, uid, [stock_rule_id],{'product_min_qty':product_min_qty,'product_max_qty':product_max_qty,},context=context)338 min_rule_obj.write(cr, uid, [stock_rule_id],{'product_min_qty':product_min_qty,'product_max_qty':product_max_qty,},context=context)

Subscribers

People subscribed via source and target branches