Merge lp:~openerp-dev/openobject-addons/trunk-bug-725908-ksa into lp:openobject-addons

Proposed by Kirti Savalia(OpenERP)
Status: Merged
Approved by: Rucha (Open ERP)
Approved revision: no longer in the source branch.
Merged at revision: 4587
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-725908-ksa
Merge into: lp:openobject-addons
Diff against target: 105 lines (+40/-40)
1 file modified
stock/wizard/stock_fill_inventory.py (+40/-40)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-725908-ksa
Reviewer Review Type Date Requested Status
qdp (OpenERP) Abstain
Kirti Savalia(OpenERP) (community) Needs Resubmitting
OpenERP buildbot (community) Needs Fixing
Rucha (Open ERP) (community) Needs Fixing
Review via email: mp+52519@code.launchpad.net

This proposal supersedes a proposal from 2011-03-04.

Description of the change

set key value in sorting.

To post a comment you must log in.
Revision history for this message
Rucha (Open ERP) (rpa-openerp) : Posted in a previous version of this proposal
review: Needs Fixing
Revision history for this message
Rucha (Open ERP) (rpa-openerp) wrote :

Not working for all child locations,
Improve code and remove unused code

review: Needs Fixing
Revision history for this message
OpenERP buildbot (openerp-buildbot) wrote :

crm_partner_assign/test/test_crm_partner_assign.yml[warning]: AssertionError in Python code : SMTP not configured !
project_timesheet/test/worktask_entry_to_timesheetline_entry.yml[warning]: Assertion "After hr manager's work task" FAILED test: len(timesheet_ids) > 0 values: ! 0 > 0
~/addons/anonymization/anonymization.py:298[pywarn]: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
~/addons/anonymization/anonymization.py:300[pywarn]: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.

review: Needs Fixing
Revision history for this message
OpenERP buildbot (openerp-buildbot) wrote :

crm_partner_assign/test/test_crm_partner_assign.yml[warning]: AssertionError in Python code : SMTP not configured !
project_timesheet/test/worktask_entry_to_timesheetline_entry.yml[warning]: Assertion "After hr manager's work task" FAILED test: len(timesheet_ids) > 0 values: ! 0 > 0
~/addons/anonymization/anonymization.py:298[pywarn]: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
~/addons/anonymization/anonymization.py:300[pywarn]: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.

review: Needs Fixing
Revision history for this message
Kirti Savalia(OpenERP) (ksa-openerp) wrote :

hello mam,
 changes is done as per your given suggestion.

review: Needs Resubmitting
Revision history for this message
qdp (OpenERP) (qdp) wrote :

need to double-check

review: Abstain

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/wizard/stock_fill_inventory.py'
2--- stock/wizard/stock_fill_inventory.py 2011-01-14 00:11:01 +0000
3+++ stock/wizard/stock_fill_inventory.py 2011-03-08 13:38:41 +0000
4@@ -58,61 +58,61 @@
5 @return:
6 """
7 if context is None:
8- context = {}
9+ context = {}
10 inventory_line_obj = self.pool.get('stock.inventory.line')
11 location_obj = self.pool.get('stock.location')
12 product_obj = self.pool.get('product.product')
13 stock_location_obj = self.pool.get('stock.location')
14- if ids and len(ids):
15+ move_obj = self.pool.get('stock.move')
16+ if ids and len(ids):
17 ids = ids[0]
18 else:
19- return {'type': 'ir.actions.act_window_close'}
20+ return {'type': 'ir.actions.act_window_close'}
21 fill_inventory = self.browse(cr, uid, ids, context=context)
22 res = {}
23 res_location = {}
24 if fill_inventory.recursive :
25 location_ids = location_obj.search(cr, uid, [('location_id',
26- 'child_of', fill_inventory.location_id.id)])
27- for location in location_ids :
28- res = location_obj._product_get(cr, uid, location)
29- res_location[location] = res
30+ 'child_of', fill_inventory.location_id.id)], order="id")
31 else:
32- context.update({'compute_child': False})
33- res = location_obj._product_get(cr, uid,
34- fill_inventory.location_id.id, context=context)
35- res_location[fill_inventory.location_id.id] = res
36-
37- product_ids = []
38- for location in res_location.keys():
39- res = res_location[location]
40- for product_id in res.keys():
41- prod = product_obj.browse(cr, uid, product_id, context=context)
42- uom = prod.uom_id.id
43- context.update(uom=uom, compute_child=False)
44- amount = stock_location_obj._product_get(cr, uid,
45- location, [product_id], context=context)[product_id]
46- if(amount):
47+ location_ids = [fill_inventory.location_id.id]
48+
49+ res = {}
50+ flag = False
51+ for location in location_ids:
52+ datas = {}
53+ res[location] = {}
54+ move_ids = move_obj.search(cr, uid, [('location_dest_id','=',location),('state','=','done')], context=context)
55+
56+ for move in move_obj.browse(cr, uid, move_ids, context=context):
57+ lot_id = move.prodlot_id.id
58+ prod_id = move.product_id.id
59+ qty = move.product_qty
60+ location_dest_id = move.location_dest_id.id
61+ if datas.get((prod_id, lot_id)):
62+ qty = datas[(prod_id, lot_id)]['product_qty'] + qty
63+ datas[(prod_id, lot_id)] = {'product_id': prod_id, 'location_id': location_dest_id, 'product_qty': qty, 'product_uom': move.product_id.uom_id.id, 'prod_lot_id': lot_id}
64+ if datas:
65+ flag = True
66+ res[location] = datas
67+
68+ if not flag:
69+ raise osv.except_osv(_('Message !'), _('No product in this location.'))
70+
71+ for i in res.values():
72+ if i.values():
73+ for mydata in i.values():
74+ mydata.update({'inventory_id': context['active_ids'][0]})
75+ domain = []
76 if fill_inventory.set_stock_zero:
77- amount = 0
78- line_ids=inventory_line_obj.search(cr, uid,
79- [('inventory_id', '=', context['active_ids']),
80- ('location_id', '=', location),
81- ('product_id', '=', product_id),
82- ('product_uom', '=', uom),
83- ('product_qty', '=', amount)])
84+ mydata.update({'product_qty': 0})
85+ for k, v in mydata.items():
86+ domain.append((k, '=', v))
87+ line_ids = inventory_line_obj.search(cr, uid, domain)
88+
89 if not len(line_ids):
90- inventory_line = {
91- 'inventory_id': context['active_ids'][0],
92- 'location_id': location,
93- 'product_id': product_id,
94- 'product_uom': uom,
95- 'product_qty': amount
96- }
97- inventory_line_obj.create(cr, uid, inventory_line)
98- product_ids.append(product_id)
99+ inventory_line_obj.create(cr, uid, mydata)
100
101- if(len(product_ids) == 0):
102- raise osv.except_osv(_('Message !'), _('No product in this location.'))
103 return {'type': 'ir.actions.act_window_close'}
104
105 stock_fill_inventory()

Subscribers

People subscribed via source and target branches

to all changes: