Merge lp:~openbig/bigconsulting/order_point_calculator into lp:bigconsulting
- order_point_calculator
- Merge into addons
Proposed by
gpa(OpenERP)
Status: | Superseded |
---|---|
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
openbig | Pending | ||
Review via email: mp+32979@code.launchpad.net |
This proposal has been superseded by a proposal from 2010-08-18.
Commit message
Description of the change
changes in the stock order point wizard
To post a comment you must log in.
- 81. By gpa(OpenERP)
-
changes in the stock_orderpoin
t_calculator wizard
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'packing_barcode_check/__terp__.py' |
2 | --- packing_barcode_check/__terp__.py 2010-07-26 15:12:49 +0000 |
3 | +++ packing_barcode_check/__terp__.py 2010-08-18 11:09:42 +0000 |
4 | @@ -31,9 +31,11 @@ |
5 | "license" : "GPL-3", |
6 | "depends" : ["base","product","stock"], |
7 | "init_xml" : [], |
8 | - "update_xml" : ["packing_barcode_check_view.xml", |
9 | + "update_xml" : [ |
10 | "packing_barcode_check_wizard.xml", |
11 | "packing_barcode_check_report.xml", |
12 | + "packing_barcode_check_view.xml", |
13 | + "packing_barcode_check_workflow.xml", |
14 | ], |
15 | "active": False, |
16 | "installable": True |
17 | |
18 | === modified file 'packing_barcode_check/packing_barcode_check.py' |
19 | --- packing_barcode_check/packing_barcode_check.py 2010-08-17 07:47:09 +0000 |
20 | +++ packing_barcode_check/packing_barcode_check.py 2010-08-18 11:09:42 +0000 |
21 | @@ -38,16 +38,23 @@ |
22 | 'scanned_quantity' : scanned_quantity, |
23 | 'to_be_scanned_quantity' : total_quantity - scanned_quantity, |
24 | } |
25 | - |
26 | return res |
27 | |
28 | - |
29 | _columns = { |
30 | 'total_quantity':fields.function(_compute_quantity, method=True, string='Total Quantity', multi='quantity'), |
31 | 'scanned_quantity': fields.function(_compute_quantity, method=True, string='Scanned Quantity', multi='quantity'), |
32 | 'to_be_scanned_quantity':fields.function(_compute_quantity, method=True, string='Unscanned Quantity', multi='quantity'), |
33 | 'tobe_scan_ids':fields.one2many('tobe.scanned.stock', 'tobe_picking_id', 'To Be'), |
34 | 'scaned_ids':fields.one2many('scanned.stock', 'scanned_picking_id', 'Scanned Picking',), |
35 | + 'state': fields.selection([ |
36 | + ('draft', 'Draft'), |
37 | + ('auto', 'Waiting'), |
38 | + ('confirmed', 'Confirmed'), |
39 | + ('assigned', 'Available'), |
40 | + ('scanned', 'Scanned'), |
41 | + ('done', 'Done'), |
42 | + ('cancel', 'Cancelled'), |
43 | + ], 'Status', readonly=True, select=True), |
44 | } |
45 | _defaults = { |
46 | 'scanned_quantity' : lambda *a:0.0, |
47 | @@ -58,6 +65,18 @@ |
48 | move_ids = move_obj.search(cr, uid, [('picking_id','=',ids[0])]) |
49 | move_obj.write(cr, uid, move_ids, {'scaned_qty':0.0}, context) |
50 | return True |
51 | + |
52 | + def test_scanned(self, cr, uid, ids, context={}): |
53 | + for pick in self.browse(cr, uid, ids, context=context): |
54 | + if pick.tobe_scan_ids: |
55 | + return False |
56 | + return True |
57 | + |
58 | + def action_scanned_wkf(self, cr, uid, ids, context={}): |
59 | + for pick in self.browse(cr, uid, ids, context=context): |
60 | + if not pick.tobe_scan_ids: |
61 | + self.write(cr, uid, ids, {'state': 'scanned'}) |
62 | + return True |
63 | |
64 | stock_picking() |
65 | |
66 | |
67 | === modified file 'packing_barcode_check/packing_barcode_check_view.xml' |
68 | --- packing_barcode_check/packing_barcode_check_view.xml 2010-08-17 07:26:17 +0000 |
69 | +++ packing_barcode_check/packing_barcode_check_view.xml 2010-08-18 11:09:42 +0000 |
70 | @@ -38,7 +38,7 @@ |
71 | <field name="backorder_id" select="2" readonly="1"/> |
72 | <field name="origin" select="2" readonly="1"/> |
73 | <label string=""/> |
74 | - <button name="button_reset" string="Reset" type="object"/> |
75 | + <button name="button_reset" states="assigned" string="Reset" type="object"/> |
76 | </group> |
77 | <notebook colspan="4"> |
78 | <page string="Scanning Info"> |
79 | @@ -66,6 +66,8 @@ |
80 | <button name="draft_validate" states="draft" string="Process Now" type="object"/> |
81 | <button name="action_assign" states="confirmed" string="Check Availability" type="object"/> |
82 | <button name="force_assign" states="confirmed" string="Force Availability" type="object"/> |
83 | + <button name="%(id_scan_product)d" states="assigned" string="Scan Packing" type="action"/> |
84 | + <button name="%(stock.partial_picking)d" states="scanned" string="Packing Done" type="action"/> |
85 | <button name="button_cancel" states="assigned,confirmed,draft" string="Cancel"/> |
86 | </group> |
87 | </page> |
88 | @@ -108,7 +110,7 @@ |
89 | </field> |
90 | </record> |
91 | |
92 | - <wizard id="act_selct_picking_open_form" model="stock.picking" name="select.picking" string="Select picking"/> |
93 | + <wizard id="act_selct_picking_open_form" model="stock.picking" name="select.picking" menu="False" string="Select picking"/> |
94 | <menuitem action="act_selct_picking_open_form" id="menu_act_selct_picking_open_form" parent="stock.menu_stock_root" type="wizard"/> |
95 | |
96 | </data> |
97 | |
98 | === modified file 'packing_barcode_check/packing_barcode_check_wizard.xml' |
99 | --- packing_barcode_check/packing_barcode_check_wizard.xml 2010-07-26 15:12:49 +0000 |
100 | +++ packing_barcode_check/packing_barcode_check_wizard.xml 2010-08-18 11:09:42 +0000 |
101 | @@ -1,18 +1,11 @@ |
102 | <?xml version="1.0" encoding="utf-8"?> |
103 | <openerp> |
104 | <data> |
105 | - <wizard |
106 | - string="Select Picking Wizard" |
107 | - model="stock.picking" |
108 | - name="select.picking" |
109 | - menu="False" |
110 | - id="id_select_picking"/> |
111 | - |
112 | <wizard |
113 | string="Scan Product" |
114 | model="stock.picking" |
115 | name="scan.product" |
116 | - menu="True" |
117 | + menu="False" |
118 | id="id_scan_product"/> |
119 | |
120 | </data> |
121 | |
122 | === added file 'packing_barcode_check/packing_barcode_check_workflow.xml' |
123 | --- packing_barcode_check/packing_barcode_check_workflow.xml 1970-01-01 00:00:00 +0000 |
124 | +++ packing_barcode_check/packing_barcode_check_workflow.xml 2010-08-18 11:09:42 +0000 |
125 | @@ -0,0 +1,26 @@ |
126 | +<?xml version="1.0" encoding="utf-8"?> |
127 | +<openerp> |
128 | + <data> |
129 | + |
130 | + <record id="act_scanned" model="workflow.activity"> |
131 | + <field name="wkf_id" ref="stock.wkf_picking"/> |
132 | + <field name="name">scanned</field> |
133 | + <field name="kind">function</field> |
134 | + <field name="action">action_scanned_wkf()</field> |
135 | + </record> |
136 | + |
137 | + <record id="trans_scanned_move" model="workflow.transition"> |
138 | + <field name="act_from" ref="stock.act_assigned"/> |
139 | + <field name="act_to" ref="act_scanned"/> |
140 | + <field name="condition">test_scanned()</field> |
141 | + <field name="signal">button_scanned</field> |
142 | + </record> |
143 | + |
144 | + <record id="stock.trans_scanned_assigned_move" model="workflow.transition"> |
145 | + <field name="act_from" ref="act_scanned"/> |
146 | + <field name="act_to" ref="stock.act_move"/> |
147 | + <field name="signal">button_done</field> |
148 | + </record> |
149 | + |
150 | + </data> |
151 | +</openerp> |
152 | |
153 | === modified file 'packing_barcode_check/wizard/scan_product.py' |
154 | --- packing_barcode_check/wizard/scan_product.py 2010-08-13 14:17:17 +0000 |
155 | +++ packing_barcode_check/wizard/scan_product.py 2010-08-18 11:09:42 +0000 |
156 | @@ -22,6 +22,7 @@ |
157 | import wizard |
158 | import pooler |
159 | import time |
160 | +import netsvc |
161 | from tools.translate import _ |
162 | from osv import osv |
163 | |
164 | @@ -62,10 +63,14 @@ |
165 | _('Unscanned quantity does not match with the product packaging quantity')) |
166 | |
167 | stock_move_obj.write(cr, uid, [move_id],{'scaned_qty':move_data.scaned_qty+quantity}, context=context) |
168 | + wkf_service = netsvc.LocalService("workflow") |
169 | + wkf_service.trg_validate(uid, 'stock.picking', picking_id[0], 'button_scanned', cr) |
170 | + |
171 | return 'init' |
172 | else: |
173 | raise osv.except_osv(_('Warning!'), |
174 | _('Product does not belongs to this picking or already scanned.')) |
175 | + |
176 | return {} |
177 | |
178 | scan_product_lot_form = """<?xml version="1.0"?> |
179 | @@ -103,6 +108,9 @@ |
180 | raise osv.except_osv(_('Warning!'), |
181 | _('Unscanned quantity does not match with the product packaging quantity')) |
182 | move_obj.write(cr, uid, [stock_move_obj.id],{'scaned_qty':stock_move_obj.scaned_qty+quantity}, context=context) |
183 | + wkf_service = netsvc.LocalService("workflow") |
184 | + wkf_service.trg_validate(uid, 'stock.picking', picking_ids[0], 'button_scanned', cr) |
185 | + |
186 | call_product_scan = 2 |
187 | if stock_move_obj.product_qty >= stock_move_obj.scaned_qty+1: |
188 | call_product_scan = 1 |
189 | |
190 | === modified file 'stock_minimum_calculator/wizard/stock_order_point_calculator.py' |
191 | --- stock_minimum_calculator/wizard/stock_order_point_calculator.py 2010-08-17 04:44:06 +0000 |
192 | +++ stock_minimum_calculator/wizard/stock_order_point_calculator.py 2010-08-18 11:09:42 +0000 |
193 | @@ -215,7 +215,7 @@ |
194 | # 1. Calculation of the date date start in one year later than current date |
195 | from_date = (datetime.now() - relativedelta(months=12)).strftime('%Y-%m-%d %H:%M:%S') |
196 | to_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S') |
197 | - |
198 | + |
199 | # 2.1 first find the all the product which fullfill the criteria of the 2.1 |
200 | product_ids = product_obj.search(cr,uid,[('active','=',True),('type','=','product'), |
201 | ('procure_method','=','make_to_stock'), |
202 | @@ -246,8 +246,7 @@ |
203 | if seller_id.name.id == partner_id: |
204 | supplier_lead_time = seller_id.delay |
205 | |
206 | - stock_move_ids = stock_move_obj.search(cr, uid, [('product_id','=',filter_product_id)]) |
207 | - |
208 | + stock_move_ids = stock_move_obj.search(cr, uid, [('product_id','=',filter_product_id),('state','=','done')]) |
209 | average_daily_consumption = 0.0 |
210 | first_stock_move_ids = [] |
211 | # Take the first input date of the stock move where stock move of incoming picking or stock move not have any picking |
212 | @@ -258,16 +257,16 @@ |
213 | first_stock_move_ids.append(first_stock_id) |
214 | else: |
215 | first_stock_move_ids.append(first_stock_id) |
216 | - |
217 | + |
218 | if first_stock_move_ids: |
219 | first_stock_move_id = first_stock_move_ids[0] |
220 | first_input = stock_move_obj.browse(cr, uid, first_stock_move_id, context=context).date_planned |
221 | - |
222 | + |
223 | # Case 1 if first input is less than from date |
224 | if first_input <= from_date: |
225 | - consum_qty = _sale_consume_qty(self, cr, uid, from_date, to_date, 'done', context) |
226 | + consum_qty = _sale_consume_qty(self, cr, uid, filter_product_id, from_date, to_date, 'done', context) |
227 | refund_qty = _refund_qty(self, cr, uid, filter_product_id, from_date, to_date, ['out_refund','in_refund'], context) |
228 | - open_sale_qty = _sale_open_qty(self, cr, uid, filter_product_id, from_date, to_date, ['manual','progress'], context) |
229 | + open_sale_qty = _sale_open_qty(self, cr, uid, filter_product_id, ['manual','progress'], context) |
230 | open_purchase_qty = _purchase_open_qty(self, cr, uid, filter_product_id, 'approved', context) |
231 | pur_diff_day = _date_diff(self, cr, uid, filter_product_id, from_date, to_date, context) |
232 | ### calculation of average_daily_consumption |
233 | @@ -287,20 +286,26 @@ |
234 | average_daily_consumption = (consum_qty - refund_qty + open_sale_qty - open_purchase_qty) / pur_diff_day |
235 | else: |
236 | open_sale_qty = _sale_open_qty(self, cr, uid, filter_product_id, ['manual','progress'], context) |
237 | - open_purchase_qty = _purchase_open_qty(self, cr, uid, filter_product_id, 'approved', context) |
238 | + open_purchase_qty = _purchase_open_qty(self, cr, uid, filter_product_id, 'approved', context) |
239 | + |
240 | + if open_purchase_qty == 0.0 or open_sale_qty == 0.0: |
241 | + continue |
242 | |
243 | # calculation of first open purchase order date |
244 | - open_purchase_ids = purchase_obj.search(cr,uid,[('state','=','approved')]) |
245 | - first_open_purchase_order = min(open_purchase_ids) |
246 | - fst_open_pur_date = purchase_obj.browse(cr, uid, first_open_purchase_order, context=context).date_order |
247 | + open_purchase_ids = purchase_obj.search(cr,uid,[('state','=','approved')]) |
248 | + if open_purchase_ids: |
249 | + first_open_purchase_order = min(open_purchase_ids) |
250 | + fst_open_pur_date = purchase_obj.browse(cr, uid, first_open_purchase_order, context=context).date_order |
251 | |
252 | - # Days difference between to date and first purchase date |
253 | - pur_to_date = time.mktime(time.strptime(to_date,'%Y-%m-%d %H:%M:%S')) |
254 | - pur_open_date = time.mktime(time.strptime(fst_open_pur_date,'%Y-%m-%d')) |
255 | - pur_diff_day = (pur_to_date-pur_open_date)/(3600*24) |
256 | - |
257 | - if pur_diff_day>0: |
258 | - average_daily_consumption = (open_sale_qty - open_purchase_qty)/pur_diff_day |
259 | + # Days difference between to date and first purchase date |
260 | + pur_diff_day = 0.0 |
261 | + if fst_open_pur_date: |
262 | + pur_to_date = time.mktime(time.strptime(to_date,'%Y-%m-%d %H:%M:%S')) |
263 | + pur_open_date = time.mktime(time.strptime(fst_open_pur_date,'%Y-%m-%d')) |
264 | + pur_diff_day = (pur_to_date-pur_open_date)/(3600*24) |
265 | + |
266 | + if pur_diff_day>0: |
267 | + average_daily_consumption = (open_sale_qty - open_purchase_qty)/pur_diff_day |
268 | |
269 | ###### Calculation of plan_average_daily_consumption |
270 | plan_average_daily_consumption = 0.0 |
271 | @@ -327,6 +332,7 @@ |
272 | min_rule_obj.unlink(cr, uid, [stock_rule_id],context=context) |
273 | |
274 | mini_stock_rule_id = min_rule_obj.search(cr,uid,[('warehouse_id','=',data['form']['warehouse_id']),('product_id','=',filter_product_id)]) |
275 | + |
276 | if mini_stock_rule_id: |
277 | for stock_rule_id in mini_stock_rule_id: |
278 | min_rule_obj.write(cr, uid, [stock_rule_id],{'product_min_qty':product_min_qty,'product_max_qty':product_max_qty,},context=context) |