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
=== modified file 'stock/product.py'
--- stock/product.py 2014-01-21 12:42:43 +0000
+++ stock/product.py 2014-04-10 06:54:13 +0000
@@ -92,7 +92,8 @@
92 journal_id = datas.get('stock_journal', False)92 journal_id = datas.get('stock_journal', False)
93 move_ids = []93 move_ids = []
94 loc_ids = location_obj.search(cr, uid,[('usage','=','internal')])94 loc_ids = location_obj.search(cr, uid,[('usage','=','internal')])
95 for product in self.browse(cr, uid, ids, context=context):95 product = self.browse(cr, uid, ids, context=context)[0]
96 for rec_id in ids:
96 if product.valuation != 'real_time':97 if product.valuation != 'real_time':
97 continue98 continue
98 account_valuation = product.categ_id.property_stock_valuation_account_id99 account_valuation = product.categ_id.property_stock_valuation_account_id
@@ -104,7 +105,7 @@
104 'location': location.id,105 'location': location.id,
105 'compute_child': False106 'compute_child': False
106 })107 })
107108 product = self.browse(cr, uid, rec_id, context=c)
108 qty = product.qty_available109 qty = product.qty_available
109 diff = product.standard_price - new_price110 diff = product.standard_price - new_price
110 if not diff: raise osv.except_osv(_('Error!'), _("No difference between standard price and new price!"))111 if not diff: raise osv.except_osv(_('Error!'), _("No difference between standard price and new price!"))