Merge lp:~openerp-dev/openobject-addons/7.0-opw-606423-han into lp:openobject-addons/7.0

Proposed by Hardik Ansodariya (OpenERP)
Status: Rejected
Rejected by: Martin Trigaux (OpenERP)
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-606423-han
Merge into: lp:openobject-addons/7.0
Diff against target: 22 lines (+3/-2)
1 file modified
stock/product.py (+3/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-606423-han
Reviewer Review Type Date Requested Status
Naresh(OpenERP) Pending
Review via email: mp+215086@code.launchpad.net

Description of the change

The loop in do_change_standard_price used to re-browse the product record based on the location context.

Create a product, average stock valuation and real time accounting.
Let's assume 2 internal locations - Output and Stock
Output has quantity of zero
 Stock has quantity of 10.
Go to product maintenance and click "- update" to update the cost.

It creates journal entries with # of internal location even if quantity is 0.

To post a comment you must log in.
Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Hello,

Thanks for your fix but actually I prefer to avoid recreating a full browse record (and refetching unchanged values in the database).
Instead I have fixed it using a read to the qty_available field only. This allows to keep a global browse in the for loop.
It was merged in 7.0 at revision 10023.

Unmerged revisions

9912. By Hardik Ansodariya (OpenERP)

[FIXED] stock/product.py: Fixed the issue of duplicate journal entries with # of location when updating cost price of product(Maintenace: 606423)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/product.py'
2--- stock/product.py 2014-01-21 12:42:43 +0000
3+++ stock/product.py 2014-04-10 06:54:13 +0000
4@@ -92,7 +92,8 @@
5 journal_id = datas.get('stock_journal', False)
6 move_ids = []
7 loc_ids = location_obj.search(cr, uid,[('usage','=','internal')])
8- for product in self.browse(cr, uid, ids, context=context):
9+ product = self.browse(cr, uid, ids, context=context)[0]
10+ for rec_id in ids:
11 if product.valuation != 'real_time':
12 continue
13 account_valuation = product.categ_id.property_stock_valuation_account_id
14@@ -104,7 +105,7 @@
15 'location': location.id,
16 'compute_child': False
17 })
18-
19+ product = self.browse(cr, uid, rec_id, context=c)
20 qty = product.qty_available
21 diff = product.standard_price - new_price
22 if not diff: raise osv.except_osv(_('Error!'), _("No difference between standard price and new price!"))